htmlstatusbar.cpp
00001 /* -*- c++ -*- 00002 htmlstatusbar.cpp 00003 00004 This file is part of KMail, the KDE mail client. 00005 Copyright (c) 2002 Ingo Kloecker <kloecker@kde.org> 00006 Copyright (c) 2003 Marc Mutz <mutz@kde.org> 00007 00008 KMail is free software; you can redistribute it and/or modify it 00009 under the terms of the GNU General Public License, version 2, as 00010 published by the Free Software Foundation. 00011 00012 KMail is distributed in the hope that it will be useful, but 00013 WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 In addition, as a special exception, the copyright holders give 00022 permission to link the code of this program with any edition of 00023 the TQt library by Trolltech AS, Norway (or with modified versions 00024 of TQt that use the same license as TQt), and distribute linked 00025 combinations including the two. You must obey the GNU General 00026 Public License in all respects for all of the code used other than 00027 TQt. If you modify this file, you may extend this exception to 00028 your version of the file, but you are not obligated to do so. If 00029 you do not wish to do so, delete this exception statement from 00030 your version. 00031 */ 00032 00033 #ifdef HAVE_CONFIG_H 00034 #include <config.h> 00035 #endif 00036 00037 #include "htmlstatusbar.h" 00038 00039 #ifndef KMAIL_TESTING 00040 #include "kmkernel.h" 00041 #else 00042 #include <kapplication.h> 00043 #endif 00044 00045 #include <klocale.h> 00046 #include <kconfig.h> 00047 00048 #include <tqcolor.h> 00049 #include <tqstring.h> 00050 00051 KMail::HtmlStatusBar::HtmlStatusBar( TQWidget * parent, const char * name, WFlags f ) 00052 : TQLabel( parent, name, f ), 00053 mMode( Normal ) 00054 { 00055 setAlignment( AlignHCenter|AlignTop ); 00056 // Don't force a minimum height to the reader widget 00057 setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Ignored ) ); 00058 upd(); 00059 } 00060 00061 KMail::HtmlStatusBar::~HtmlStatusBar() {} 00062 00063 void KMail::HtmlStatusBar::upd() { 00064 setEraseColor( bgColor() ); 00065 setPaletteForegroundColor( fgColor() ); 00066 setText( message() ); 00067 } 00068 00069 void KMail::HtmlStatusBar::setNormalMode() { 00070 setMode( Normal ); 00071 } 00072 00073 void KMail::HtmlStatusBar::setHtmlMode() { 00074 setMode( Html ); 00075 } 00076 00077 void KMail::HtmlStatusBar::setNeutralMode() { 00078 setMode( Neutral ); 00079 } 00080 00081 void KMail::HtmlStatusBar::setMode( Mode m ) { 00082 if ( m == mode() ) 00083 return; 00084 mMode = m; 00085 upd(); 00086 } 00087 00088 TQString KMail::HtmlStatusBar::message() const { 00089 switch ( mode() ) { 00090 case Html: // bold: "HTML Message" 00091 return i18n( "<qt><b><br>H<br>T<br>M<br>L<br> " 00092 "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</b></qt>" ); 00093 case Normal: // normal: "No HTML Message" 00094 return i18n( "<qt><br>N<br>o<br> " 00095 "<br>H<br>T<br>M<br>L<br> " 00096 "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</qt>" ); 00097 default: 00098 case Neutral: 00099 return TQString(); 00100 } 00101 } 00102 00103 namespace { 00104 inline KConfig * config() { 00105 #ifndef KMAIL_TESTING 00106 return KMKernel::config(); 00107 #else 00108 return kApp->config(); 00109 #endif 00110 } 00111 } 00112 00113 TQColor KMail::HtmlStatusBar::fgColor() const { 00114 KConfigGroup conf( config(), "Reader" ); 00115 switch ( mode() ) { 00116 case Html: 00117 return conf.readColorEntry( "ColorbarForegroundHTML", &TQt::white ); 00118 case Normal: 00119 return conf.readColorEntry( "ColorbarForegroundPlain", &TQt::black ); 00120 default: 00121 case Neutral: 00122 return TQt::black; 00123 } 00124 } 00125 00126 TQColor KMail::HtmlStatusBar::bgColor() const { 00127 KConfigGroup conf( config(), "Reader" ); 00128 00129 switch ( mode() ) { 00130 case Html: 00131 return conf.readColorEntry( "ColorbarBackgroundHTML", &TQt::black ); 00132 case Normal: 00133 return conf.readColorEntry( "ColorbarBackgroundPlain", &TQt::lightGray ); 00134 default: 00135 case Neutral: 00136 return TQt::white; 00137 } 00138 } 00139 00140 #include "htmlstatusbar.moc"