kmail Library API Documentation

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Qt library by Trolltech AS, Norway (or with modified versions 00024 of Qt that use the same license as Qt), 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 Qt. 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 <qcolor.h> 00049 #include <qstring.h> 00050 00051 KMail::HtmlStatusBar::HtmlStatusBar( QWidget * parent, const char * name, WFlags f ) 00052 : QLabel( parent, name, f ), 00053 mMode( Normal ) 00054 { 00055 setAlignment( AlignHCenter|AlignTop ); 00056 upd(); 00057 } 00058 00059 KMail::HtmlStatusBar::~HtmlStatusBar() {} 00060 00061 void KMail::HtmlStatusBar::upd() { 00062 setEraseColor( bgColor() ); 00063 setPaletteForegroundColor( fgColor() ); 00064 setText( message() ); 00065 } 00066 00067 void KMail::HtmlStatusBar::setNormalMode() { 00068 setMode( Normal ); 00069 } 00070 00071 void KMail::HtmlStatusBar::setHtmlMode() { 00072 setMode( Html ); 00073 } 00074 00075 void KMail::HtmlStatusBar::setNeutralMode() { 00076 setMode( Neutral ); 00077 } 00078 00079 void KMail::HtmlStatusBar::setMode( Mode m ) { 00080 if ( m == mode() ) 00081 return; 00082 mMode = m; 00083 upd(); 00084 } 00085 00086 QString KMail::HtmlStatusBar::message() const { 00087 switch ( mode() ) { 00088 case Html: // bold: "HTML Message" 00089 return i18n( "<qt><b><br>H<br>T<br>M<br>L<br> " 00090 "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</b></qt>" ); 00091 case Normal: // normal: "No HTML Message" 00092 return i18n( "<qt><br>N<br>o<br> " 00093 "<br>H<br>T<br>M<br>L<br> " 00094 "<br>M<br>e<br>s<br>s<br>a<br>g<br>e</qt>" ); 00095 default: 00096 case Neutral: 00097 return QString::null; 00098 } 00099 } 00100 00101 namespace { 00102 inline KConfig * config() { 00103 #ifndef KMAIL_TESTING 00104 return KMKernel::config(); 00105 #else 00106 return kApp->config(); 00107 #endif 00108 } 00109 } 00110 00111 QColor KMail::HtmlStatusBar::fgColor() const { 00112 KConfigGroup conf( config(), "Reader" ); 00113 switch ( mode() ) { 00114 case Html: 00115 return conf.readColorEntry( "ColorbarForegroundHTML", &Qt::white ); 00116 case Normal: 00117 return conf.readColorEntry( "ColorbarForegroundPlain", &Qt::black ); 00118 default: 00119 case Neutral: 00120 return Qt::black; 00121 } 00122 } 00123 00124 QColor KMail::HtmlStatusBar::bgColor() const { 00125 KConfigGroup conf( config(), "Reader" ); 00126 00127 switch ( mode() ) { 00128 case Html: 00129 return conf.readColorEntry( "ColorbarBackgroundHTML", &Qt::black ); 00130 case Normal: 00131 return conf.readColorEntry( "ColorbarBackgroundPlain", &Qt::lightGray ); 00132 default: 00133 case Neutral: 00134 return Qt::white; 00135 } 00136 } 00137 00138 #include "htmlstatusbar.moc"
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:45 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003