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 <config-messageviewer.h>
35 #include "htmlstatusbar.h"
36 #include "globalsettings.h"
38 #include "messagecore/globalsettings.h"
42 #include <kconfiggroup.h>
43 #include <kapplication.h>
48 #include <QMouseEvent>
50 using namespace MessageViewer
;
52 HtmlStatusBar::HtmlStatusBar( QWidget
* parent
, const char * name
, Qt::WFlags f
)
53 : QLabel( parent
, f
),
56 setObjectName( name
);
57 setAlignment( Qt::AlignHCenter
| Qt::AlignTop
);
58 setAutoFillBackground( true );
62 HtmlStatusBar::~HtmlStatusBar() {}
64 void HtmlStatusBar::update()
66 QPalette pal
= palette();
67 pal
.setColor( backgroundRole(), bgColor() );
68 pal
.setColor( foregroundRole(), fgColor() );
71 setToolTip( toolTip() );
74 void HtmlStatusBar::setNormalMode()
76 setMode( Util::Normal
);
79 void HtmlStatusBar::setHtmlMode()
81 setMode( Util::Html
);
84 void HtmlStatusBar::setMultipartPlainMode()
86 setMode( Util::MultipartPlain
);
89 void HtmlStatusBar::setMultipartHtmlMode()
91 setMode( Util::MultipartHtml
);
94 void HtmlStatusBar::setMode( Util::HtmlMode m
, UpdateMode mode
)
101 void HtmlStatusBar::mousePressEvent( QMouseEvent
* event
)
103 if ( event
->button() == Qt::LeftButton
) {
108 QString
HtmlStatusBar::message() const {
110 case Util::Html
: // bold: "HTML Message"
111 case Util::MultipartHtml
:
112 return i18nc( "'HTML Message' with html linebreaks between each letter and in bold text.",
113 "<qt><b><br />H<br />T<br />M<br />L<br /> "
114 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</b></qt>" );
115 case Util::Normal
: // normal: "No HTML Message"
116 return i18nc("'No HTML Message' with html linebreaks between each letter.",
117 "<qt><br />N<br />o<br /> "
118 "<br />H<br />T<br />M<br />L<br /> "
119 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</qt>" );
120 case Util::MultipartPlain
: // normal: "Plain Message"
121 return i18nc("'Plain Message' with html linebreaks between each letter.",
122 "<qt><br />P<br />l<br />a<br />i<br />n<br /> "
123 "<br />M<br />e<br />s<br />s<br />a<br />g<br />e<br /></qt>" );
129 QString
HtmlStatusBar::toolTip() const
134 case Util::MultipartHtml
:
135 case Util::MultipartPlain
:
136 return i18n( "Click to toggle between HTML and plain text." );
145 QColor
HtmlStatusBar::fgColor() const
147 KConfigGroup
conf( GlobalSettings::self()->config(), "Reader" );
148 QColor defaultColor
, color
;
151 case Util::MultipartHtml
:
152 defaultColor
= Qt::white
;
153 color
= defaultColor
;
154 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
155 color
= conf
.readEntry( "ColorbarForegroundHTML", defaultColor
);
159 case Util::MultipartPlain
:
160 defaultColor
= Qt::black
;
161 color
= defaultColor
;
162 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
163 color
= conf
.readEntry( "ColorbarForegroundPlain", defaultColor
);
171 QColor
HtmlStatusBar::bgColor() const {
172 KConfigGroup
conf( GlobalSettings::self()->config(), "Reader" );
174 QColor defaultColor
, color
;
177 case Util::MultipartHtml
:
178 defaultColor
= Qt::black
;
179 color
= defaultColor
;
180 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
181 color
= conf
.readEntry( "ColorbarBackgroundHTML", defaultColor
);
185 case Util::MultipartPlain
:
186 defaultColor
= Qt::lightGray
;
187 color
= defaultColor
;
188 if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
189 color
= conf
.readEntry( "ColorbarBackgroundPlain", defaultColor
);
197 #include "htmlstatusbar.moc"