Messagelib

htmlstatusbar.h
1 /* -*- c++ -*-
2  htmlstatusbar.h
3 
4  This file is part of KMail, the KDE mail client.
5  SPDX-FileCopyrightText: 2002 Ingo Kloecker <[email protected]>
6  SPDX-FileCopyrightText: 2003 Marc Mutz <[email protected]>
7 
8  SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 #pragma once
11 
12 #include "messageviewer/messageviewerutil.h"
13 #include <MimeTreeParser/Util>
14 #include <QLabel>
15 class QMouseEvent;
16 
17 namespace MessageViewer
18 {
19 /**
20  * @short The HTML statusbar widget for use with the reader.
21  *
22  * The HTML status bar is a small widget that acts as an indicator
23  * for the message content. It can be in one of four modes:
24  *
25  * <dl>
26  * <dt><code>Normal</code></dt>
27  * <dd>Default. No HTML.</dd>
28  * <dt><code>Html</code></dt>
29  * <dd>HTML content is being shown. Since HTML mails can mimic all sorts
30  * of KMail markup in the reader, this provides out-of-band information
31  * about the presence of (rendered) HTML.</dd>
32  * <dt><code>MultipartPlain</code></dt>
33  * <dd>Viewed as plain text with HTML part also available.</dd>
34  * <dt><code>MultipartHtml</code></dt>
35  * <dd>Viewed as Html with plain text part also available.</dd>
36  * </dl>
37  *
38  * @author Ingo Kloecker <[email protected]>, Marc Mutz <[email protected]>
39  **/
40 class HtmlStatusBar : public QLabel
41 {
42  Q_OBJECT
43 public:
44  enum UpdateMode {
45  NoUpdate,
46  Update,
47  };
48 
49  explicit HtmlStatusBar(QWidget *parent = nullptr);
50  ~HtmlStatusBar() override;
51 
52  /** @return current mode. */
53  Q_REQUIRED_RESULT MimeTreeParser::Util::HtmlMode mode() const;
54  Q_REQUIRED_RESULT bool isHtml() const;
55  Q_REQUIRED_RESULT bool isNormal() const;
56 
57  // Update the status bar, for example when the color scheme changed.
58  void update();
59 
60  void setAvailableModes(const QList<MimeTreeParser::Util::HtmlMode> &availableModes);
61  Q_REQUIRED_RESULT const QList<MimeTreeParser::Util::HtmlMode> &availableModes();
62 
63 public Q_SLOTS:
64  void setHtmlMode();
65  /** Switch to "normal mode". */
66  void setNormalMode();
67  /** Switch to mode @p m */
68  void setMode(MimeTreeParser::Util::HtmlMode m, MessageViewer::HtmlStatusBar::UpdateMode mode = Update);
69 
70 Q_SIGNALS:
71  /** The user has clicked the status bar. */
72  void clicked();
73 
74 protected:
75  void mousePressEvent(QMouseEvent *event) override;
76 
77 private:
78  QString message() const;
79  QString toolTip() const;
80  QColor bgColor() const;
81  QColor fgColor() const;
82 
85 };
86 }
Q_OBJECTQ_OBJECT
void setMode(MimeTreeParser::Util::HtmlMode m, MessageViewer::HtmlStatusBar::UpdateMode mode=Update)
Switch to mode m.
Q_SLOTSQ_SLOTS
void clicked()
The user has clicked the status bar.
HtmlMode
Describes the type of the displayed message.
Q_SIGNALSQ_SIGNALS
The HTML statusbar widget for use with the reader.
Definition: htmlstatusbar.h:40
MimeTreeParser::Util::HtmlMode mode() const
virtual bool event(QEvent *e) override
void setNormalMode()
Switch to "normal mode".
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Mar 24 2023 04:08:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.