File indexing completed on 2025-03-09 04:54:44
0001 /* -*- c++ -*- 0002 htmlstatusbar.h 0003 0004 This file is part of KMail, the KDE mail client. 0005 SPDX-FileCopyrightText: 2002 Ingo Kloecker <kloecker@kde.org> 0006 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include "messageviewer/messageviewerutil.h" 0013 #include <MimeTreeParser/Util> 0014 #include <QLabel> 0015 class QMouseEvent; 0016 0017 namespace MessageViewer 0018 { 0019 /** 0020 * @short The HTML statusbar widget for use with the reader. 0021 * 0022 * The HTML status bar is a small widget that acts as an indicator 0023 * for the message content. It can be in one of four modes: 0024 * 0025 * <dl> 0026 * <dt><code>Normal</code></dt> 0027 * <dd>Default. No HTML.</dd> 0028 * <dt><code>Html</code></dt> 0029 * <dd>HTML content is being shown. Since HTML mails can mimic all sorts 0030 * of KMail markup in the reader, this provides out-of-band information 0031 * about the presence of (rendered) HTML.</dd> 0032 * <dt><code>MultipartPlain</code></dt> 0033 * <dd>Viewed as plain text with HTML part also available.</dd> 0034 * <dt><code>MultipartHtml</code></dt> 0035 * <dd>Viewed as Html with plain text part also available.</dd> 0036 * </dl> 0037 * 0038 * @author Ingo Kloecker <kloecker@kde.org>, Marc Mutz <mutz@kde.org> 0039 **/ 0040 class HtmlStatusBar : public QLabel 0041 { 0042 Q_OBJECT 0043 public: 0044 enum UpdateMode { 0045 NoUpdate, 0046 Update, 0047 }; 0048 0049 explicit HtmlStatusBar(QWidget *parent = nullptr); 0050 ~HtmlStatusBar() override; 0051 0052 /** @return current mode. */ 0053 [[nodiscard]] MimeTreeParser::Util::HtmlMode mode() const; 0054 [[nodiscard]] bool isHtml() const; 0055 [[nodiscard]] bool isNormal() const; 0056 0057 // Update the status bar, for example when the color scheme changed. 0058 void update(); 0059 0060 void setAvailableModes(const QList<MimeTreeParser::Util::HtmlMode> &availableModes); 0061 [[nodiscard]] const QList<MimeTreeParser::Util::HtmlMode> &availableModes(); 0062 0063 public Q_SLOTS: 0064 void setHtmlMode(); 0065 /** Switch to "normal mode". */ 0066 void setNormalMode(); 0067 /** Switch to mode @p m */ 0068 void setMode(MimeTreeParser::Util::HtmlMode m, MessageViewer::HtmlStatusBar::UpdateMode mode = Update); 0069 0070 Q_SIGNALS: 0071 /** The user has clicked the status bar. */ 0072 void clicked(); 0073 0074 protected: 0075 void mousePressEvent(QMouseEvent *event) override; 0076 0077 private: 0078 QString message() const; 0079 QString toolTip() const; 0080 QColor bgColor() const; 0081 QColor fgColor() const; 0082 0083 MimeTreeParser::Util::HtmlMode mMode; 0084 QList<MimeTreeParser::Util::HtmlMode> mAvailableModes; 0085 }; 0086 }