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>
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.
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.
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
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 Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), 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 Qt. 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
33 #include "htmlstatusbar.h"
34 #include "globalsettings.h"
36 #include "messagecore/globalsettings.h"
40 #include <kconfiggroup.h>
41 #include <kapplication.h>
46 #include <QMouseEvent>
48 using namespace MessageViewer
;
50 HtmlStatusBar::HtmlStatusBar( QWidget
* parent
, const char * name
, Qt::WFlags f
)
51 : QLabel( parent
, f
),
54 setObjectName( name
);
55 setAlignment( Qt::AlignHCenter
| Qt::AlignTop
);
56 setAutoFillBackground( true );
60 HtmlStatusBar::~HtmlStatusBar() {}
62 void HtmlStatusBar::update()
64 QPalette pal
= palette();
65 pal
.setColor( backgroundRole(), bgColor() );
66 pal
.setColor( foregroundRole(), fgColor() );
69 setToolTip( toolTip() );
72 void HtmlStatusBar::setNormalMode()
74 setMode( Util::Normal
);
77 void HtmlStatusBar::setHtmlMode()
79 setMode( Util::Html
);
82 void HtmlStatusBar::setMultipartPlainMode()
84 setMode( Util::MultipartPlain
);
87 void HtmlStatusBar::setMultipartHtmlMode()
89 setMode( Util::MultipartHtml
);
92 void HtmlStatusBar::setMode( Util::HtmlMode m
, UpdateMode mode
)
99 void HtmlStatusBar::mousePressEvent( QMouseEvent
* event
)
101 if ( event
->button() == Qt::LeftButton
) {
106 QString
HtmlStatusBar::message() const {
108 case Util::Html
: // bold: "HTML Message"
109 case Util::MultipartHtml
:
110 return i18nc( "'HTML Message' with html linebreaks between each letter.",
111 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</b></qt>" );
112 case Util::Normal
: // normal: "No HTML Message"
113 return i18nc("'No HTML Message' with html linebreaks between each letter.",
114 "<qt><br />N<br />o<br /> "
115 "<br />H<br />T<br />M<br />L<br /> "
116 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</qt>" );
117 case Util::MultipartPlain
: // normal: "Plain Message"
118 return i18nc("'Plain Message' with html linebreaks between each letter.",
119 "<qt><br />P<br />l<br />a<br />i<br />n<br /> "
120 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e<br /></qt>" );
126 QString
HtmlStatusBar::toolTip() const
131 case Util::MultipartHtml
:
132 case Util::MultipartPlain
:
133 return i18n( "Click to toggle between HTML and plain text." );
142 QColor
HtmlStatusBar::fgColor() const
144 KConfigGroup
conf( GlobalSettings::self()->config(), "Reader" );
145 QColor defaultColor
, color
;
148 case Util::MultipartHtml
:
149 defaultColor
= Qt::white
;
150 color
= defaultColor
;
151 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
152 color
= conf
.readEntry( "ColorbarForegroundHTML", defaultColor
);
156 case Util::MultipartPlain
:
157 defaultColor
= Qt::black
;
158 color
= defaultColor
;
159 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
160 color
= conf
.readEntry( "ColorbarForegroundPlain", defaultColor
);
168 QColor
HtmlStatusBar::bgColor() const {
169 KConfigGroup
conf( GlobalSettings::self()->config(), "Reader" );
171 QColor defaultColor
, color
;
174 case Util::MultipartHtml
:
175 defaultColor
= Qt::black
;
176 color
= defaultColor
;
177 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
178 color
= conf
.readEntry( "ColorbarBackgroundHTML", defaultColor
);
182 case Util::MultipartPlain
:
183 defaultColor
= Qt::lightGray
;
184 color
= defaultColor
;
185 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
186 color
= conf
.readEntry( "ColorbarBackgroundPlain", defaultColor
);
194 #include "htmlstatusbar.moc"