• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • widgets
htmlstatusbar.cpp
Go to the documentation of this file.
1 /* -*- c++ -*-
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  Copyright (c) 2013 Laurent Montel <montel@kde.org>
8 
9  KMail is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License, version 2, as
11  published by the Free Software Foundation.
12 
13  KMail is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22  In addition, as a special exception, the copyright holders give
23  permission to link the code of this program with any edition of
24  the Qt library by Trolltech AS, Norway (or with modified versions
25  of Qt that use the same license as Qt), and distribute linked
26  combinations including the two. You must obey the GNU General
27  Public License in all respects for all of the code used other than
28  Qt. If you modify this file, you may extend this exception to
29  your version of the file, but you are not obligated to do so. If
30  you do not wish to do so, delete this exception statement from
31  your version.
32 */
33 
34 #include "htmlstatusbar.h"
35 #include "settings/globalsettings.h"
36 
37 #include "messagecore/settings/globalsettings.h"
38 
39 #include <klocale.h>
40 #include <kconfiggroup.h>
41 
42 #include <QMouseEvent>
43 
44 using namespace MessageViewer;
45 
46 HtmlStatusBar::HtmlStatusBar(QWidget * parent)
47  : QLabel( parent ),
48  mMode( Util::Normal )
49 {
50  setAlignment( Qt::AlignHCenter | Qt::AlignTop );
51  setAutoFillBackground( true );
52  update();
53 }
54 
55 HtmlStatusBar::~HtmlStatusBar() {}
56 
57 void HtmlStatusBar::update()
58 {
59  QPalette pal = palette();
60  pal.setColor( backgroundRole(), bgColor() );
61  pal.setColor( foregroundRole(), fgColor() );
62  setPalette( pal );
63  setText( message() );
64  setToolTip( toolTip() );
65 }
66 
67 void HtmlStatusBar::setNormalMode()
68 {
69  setMode( Util::Normal );
70 }
71 
72 void HtmlStatusBar::setHtmlMode()
73 {
74  setMode( Util::Html );
75 }
76 
77 void HtmlStatusBar::setMultipartPlainMode()
78 {
79  setMode( Util::MultipartPlain );
80 }
81 
82 void HtmlStatusBar::setMultipartHtmlMode()
83 {
84  setMode( Util::MultipartHtml );
85 }
86 
87 void HtmlStatusBar::setMode( Util::HtmlMode m, UpdateMode mode )
88 {
89  mMode = m;
90  if ( mode == Update )
91  update();
92 }
93 
94 void HtmlStatusBar::mousePressEvent( QMouseEvent * event )
95 {
96  if ( event->button() == Qt::LeftButton ) {
97  emit clicked();
98  }
99 }
100 
101 QString HtmlStatusBar::message() const {
102  switch ( mode() ) {
103  case Util::Html: // bold: "HTML Message"
104  case Util::MultipartHtml:
105  return i18nc( "'HTML Message' with html linebreaks between each letter and in bold text.",
106  "<qt><b><br />H<br />T<br />M<br />L<br /> "
107  "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</b></qt>" );
108  case Util::Normal: // normal: "No HTML Message"
109  return i18nc("'No HTML Message' with html linebreaks between each letter.",
110  "<qt><br />N<br />o<br /> "
111  "<br />H<br />T<br />M<br />L<br /> "
112  "<br />M<br />e<br />s<br />s<br />a<br />g<br />e</qt>" );
113  case Util::MultipartPlain: // normal: "Plain Message"
114  return i18nc("'Plain Message' with html linebreaks between each letter.",
115  "<qt><br />P<br />l<br />a<br />i<br />n<br /> "
116  "<br />M<br />e<br />s<br />s<br />a<br />g<br />e<br /></qt>" );
117  default:
118  return QString();
119  }
120 }
121 
122 QString HtmlStatusBar::toolTip() const
123 {
124  switch ( mode() )
125  {
126  case Util::Html:
127  case Util::MultipartHtml:
128  case Util::MultipartPlain:
129  return i18n( "Click to toggle between HTML and plain text." );
130  default:
131  case Util::Normal:
132  break;
133  }
134 
135  return QString();
136 }
137 
138 QColor HtmlStatusBar::fgColor() const
139 {
140  KConfigGroup conf( GlobalSettings::self()->config(), "Reader" );
141  QColor defaultColor, color;
142  switch ( mode() ) {
143  case Util::Html:
144  case Util::MultipartHtml:
145  defaultColor = Qt::white;
146  color = defaultColor;
147  if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
148  color = conf.readEntry( "ColorbarForegroundHTML", defaultColor );
149  }
150  return color;
151  case Util::Normal:
152  case Util::MultipartPlain:
153  defaultColor = Qt::black;
154  color = defaultColor;
155  if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
156  color = conf.readEntry( "ColorbarForegroundPlain", defaultColor );
157  }
158  return color;
159  default:
160  return Qt::black;
161  }
162 }
163 
164 QColor HtmlStatusBar::bgColor() const {
165  KConfigGroup conf( GlobalSettings::self()->config(), "Reader" );
166 
167  QColor defaultColor, color;
168  switch ( mode() ) {
169  case Util::Html:
170  case Util::MultipartHtml:
171  defaultColor = Qt::black;
172  color = defaultColor;
173  if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
174  color = conf.readEntry( "ColorbarBackgroundHTML", defaultColor );
175  }
176  return color;
177  case Util::Normal:
178  case Util::MultipartPlain:
179  defaultColor = Qt::lightGray;
180  color = defaultColor;
181  if ( !MessageCore::GlobalSettings::self()->useDefaultColors() ) {
182  color = conf.readEntry( "ColorbarBackgroundPlain", defaultColor );
183  }
184  return color;
185  default:
186  return Qt::white;
187  }
188 }
189 
190 #include "htmlstatusbar.moc"
globalsettings.h
MessageViewer::HtmlStatusBar::Update
Definition: htmlstatusbar.h:67
MessageViewer::HtmlStatusBar::HtmlStatusBar
HtmlStatusBar(QWidget *parent=0)
Definition: htmlstatusbar.cpp:46
MessageViewer::Util::HtmlMode
HtmlMode
Describes the type of the displayed message.
Definition: util.h:73
MessageViewer::Util::MultipartPlain
A multipart/alternative message, the plain text part is currently displayed.
Definition: util.h:76
MessageViewer::HtmlStatusBar::setMode
void setMode(Util::HtmlMode m, UpdateMode mode=Update)
Switch to mode m.
Definition: htmlstatusbar.cpp:87
MessageViewer::HtmlStatusBar::setNormalMode
void setNormalMode()
Switch to "normal mode".
Definition: htmlstatusbar.cpp:67
QWidget
MessageViewer::HtmlStatusBar::update
void update()
Definition: htmlstatusbar.cpp:57
htmlstatusbar.h
MessageViewer::HtmlStatusBar::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition: htmlstatusbar.cpp:94
MessageViewer::GlobalSettings::self
static GlobalSettings * self()
Definition: globalsettings.cpp:34
MessageViewer::HtmlStatusBar::setMultipartHtmlMode
void setMultipartHtmlMode()
Switch to "multipart html mode".
Definition: htmlstatusbar.cpp:82
MessageViewer::Util::Normal
A normal plaintext message, non-multipart.
Definition: util.h:74
MessageViewer::Util::Html
A HTML message, non-multipart.
Definition: util.h:75
MessageViewer::HtmlStatusBar::clicked
void clicked()
The user has clicked the status bar.
QLabel
MessageViewer::HtmlStatusBar::mode
Util::HtmlMode mode() const
Definition: htmlstatusbar.h:74
MessageViewer::HtmlStatusBar::UpdateMode
UpdateMode
Definition: htmlstatusbar.h:65
MessageViewer::HtmlStatusBar::setMultipartPlainMode
void setMultipartPlainMode()
Switch to "multipart plain mode".
Definition: htmlstatusbar.cpp:77
MessageViewer::HtmlStatusBar::setHtmlMode
void setHtmlMode()
Definition: htmlstatusbar.cpp:72
MessageViewer::HtmlStatusBar::~HtmlStatusBar
~HtmlStatusBar()
Definition: htmlstatusbar.cpp:55
MessageViewer::Util::MultipartHtml
A multipart/altervative message, the HTML part is currently displayed.
Definition: util.h:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal