kmail

htmlstatusbar.cpp
1 /*
2  htmlstatusbar.cpp
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2002 Ingo Kloecker <kloecker@kde.org>
6  Copyright (c) 2003 Marc Mutz <mutz@kde.org>
7 
8  KMail is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License, version 2, as
10  published by the Free Software Foundation.
11 
12  KMail is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  TQt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 #endif
36 
37 #include "htmlstatusbar.h"
38 
39 #ifndef KMAIL_TESTING
40 #include "kmkernel.h"
41 #else
42 #include <tdeapplication.h>
43 #endif
44 
45 #include <tdelocale.h>
46 #include <tdeconfig.h>
47 
48 #include <tqcolor.h>
49 #include <tqstring.h>
50 
51 KMail::HtmlStatusBar::HtmlStatusBar( TQWidget * parent, const char * name, WFlags f )
52  : TQLabel( parent, name, f ),
53  mMode( Normal )
54 {
55  setAlignment( AlignHCenter|AlignTop );
56  // Don't force a minimum height to the reader widget
57  setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Ignored ) );
58  upd();
59 }
60 
61 KMail::HtmlStatusBar::~HtmlStatusBar() {}
62 
63 void KMail::HtmlStatusBar::upd() {
64  setEraseColor( bgColor() );
65  setPaletteForegroundColor( fgColor() );
66  setText( message() );
67 }
68 
70  setMode( Normal );
71 }
72 
74  setMode( Html );
75 }
76 
78  setMode( Neutral );
79 }
80 
82  if ( m == mode() )
83  return;
84  mMode = m;
85  upd();
86 }
87 
88 TQString KMail::HtmlStatusBar::message() const {
89  switch ( mode() ) {
90  case Html: // bold: "HTML Message"
91  return i18n( "<qt><b><br>H<br>T<br>M<br>L<br> "
92  "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</b></qt>" );
93  case Normal: // normal: "No HTML Message"
94  return i18n( "<qt><br>N<br>o<br> "
95  "<br>H<br>T<br>M<br>L<br> "
96  "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</qt>" );
97  default:
98  case Neutral:
99  return TQString();
100  }
101 }
102 
103 namespace {
104  inline TDEConfig * config() {
105 #ifndef KMAIL_TESTING
106  return KMKernel::config();
107 #else
108  return kApp->config();
109 #endif
110  }
111 }
112 
113 TQColor KMail::HtmlStatusBar::fgColor() const {
114  TDEConfigGroup conf( config(), "Reader" );
115  switch ( mode() ) {
116  case Html:
117  return conf.readColorEntry( "ColorbarForegroundHTML", &TQt::white );
118  case Normal:
119  return conf.readColorEntry( "ColorbarForegroundPlain", &TQt::black );
120  default:
121  case Neutral:
122  return TQt::black;
123  }
124 }
125 
126 TQColor KMail::HtmlStatusBar::bgColor() const {
127  TDEConfigGroup conf( config(), "Reader" );
128 
129  switch ( mode() ) {
130  case Html:
131  return conf.readColorEntry( "ColorbarBackgroundHTML", &TQt::black );
132  case Normal:
133  return conf.readColorEntry( "ColorbarBackgroundPlain", &TQt::lightGray );
134  default:
135  case Neutral:
136  return TQt::white;
137  }
138 }
139 
140 #include "htmlstatusbar.moc"
void setNeutralMode()
Switch to "neutral" mode (currently == normal mode).
void setHtmlMode()
Switch to "html mode".
void setNormalMode()
Switch to "normal mode".
void setMode(Mode m)
Switch to mode m.