Messagelib

csshelperbase.h
1 /* -*- c++ -*-
2  csshelper.h
3 
4  This file is part of KMail, the KDE mail client.
5  SPDX-FileCopyrightText: 2003 Marc Mutz <[email protected]>
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #ifndef MIMETREEPARSER_CSSHELPERBASE_H
11 #define MIMETREEPARSER_CSSHELPERBASE_H
12 
13 #include "messageviewer_export.h"
14 
15 #include <QColor>
16 #include <QFont>
17 
18 class QString;
19 class QPaintDevice;
20 
21 namespace MessageViewer {
22 class HeaderStylePlugin;
26 class MESSAGEVIEWER_EXPORT CSSHelperBase
27 {
28 public:
33  explicit CSSHelperBase(const QPaintDevice *pd);
34  virtual ~CSSHelperBase();
35 
38  virtual QString htmlHead(bool fixedFont = false) const;
39 
41  Q_REQUIRED_RESULT QString cssDefinitions(bool fixedFont = false) const;
42 
45  Q_REQUIRED_RESULT QString quoteFontTag(int level) const;
48  Q_REQUIRED_RESULT QString nonQuotedFontTag() const;
49 
50  Q_REQUIRED_RESULT QFont bodyFont(bool fixedFont = false, bool printing = false) const;
51 
52  void setBodyFont(const QFont &font);
53  void setPrintFont(const QFont &font);
54 
56  Q_REQUIRED_RESULT QColor quoteColor(int level) const;
57  Q_REQUIRED_RESULT QString quoteColorName(int level) const;
58 
59  Q_REQUIRED_RESULT QColor pgpWarnColor() const;
60 
61  Q_REQUIRED_RESULT QString addEndBlockQuote(int numberBlock) const;
62  Q_REQUIRED_RESULT QString addStartBlockQuote(int numberBlock) const;
63 
64  Q_REQUIRED_RESULT QString extraScreenCss(const QString &headerFont) const;
65  Q_REQUIRED_RESULT QString extraPrintCss(const QString &headerFont) const;
66  Q_REQUIRED_RESULT QString extraCommonCss(const QString &headerFont) const;
67 
68  void setHeaderPlugin(const HeaderStylePlugin *headerPlugin);
69 
70  enum InlineMessageType {
71  Positive,
72  Information,
73  Warning,
74  Error,
75  MESSAGE_TYPE_COUNT
76  };
77 
78 protected:
81  void recalculatePGPColors();
82 
83 protected:
84  QFont mBodyFont;
85  QFont mPrintFont;
86  QFont mFixedFont;
87  QFont mFixedPrintFont;
88  QFont mQuoteFont;
89  QColor mQuoteColor[3];
90  bool mRecycleQuoteColors = false;
91  bool mShrinkQuotes = false;
92  bool mUseBrowserColor = false;
93  QColor mForegroundColor;
94  QColor mLinkColor;
95  QColor mBackgroundColor;
96  // colors for PGP (Frame, Header, HeaderText, Body)
97  QColor cPgpOk1F;
98  QColor cPgpOk1H;
99  QColor cPgpOk1HT;
100  QColor cPgpOk1B;
101  QColor cPgpOk0F;
102  QColor cPgpOk0H;
103  QColor cPgpOk0HT;
104  QColor cPgpOk0B;
105  QColor cPgpWarnF;
106  QColor cPgpWarnH;
107  QColor cPgpWarnHT;
108  QColor cPgpWarnB;
109  QColor cPgpErrF;
110  QColor cPgpErrH;
111  QColor cPgpErrHT;
112  QColor cPgpErrB;
113  QColor cPgpEncrF;
114  QColor cPgpEncrH;
115  QColor cPgpEncrHT;
116  QColor cPgpEncrB;
117 
118  // colors for inline message boxes, see KMessageWidget or Kirigami::InlineMessage
119  QColor cInlineMessage[MESSAGE_TYPE_COUNT];
120 
121  QString imgShowUrl;
122  QString imgHideUrl;
123 
124 private:
125  QString quoteCssDefinition() const;
126  int fontSize(bool fixed, bool print = false) const;
127  // returns CSS rules specific to the print media type
128  QString printCssDefinitions(bool fixed) const;
129  // returns CSS rules specific to the screen media type
130  QString screenCssDefinitions(const CSSHelperBase *helper, bool fixed) const;
131  // returns CSS rules common to both screen and print media types
132  QString commonCssDefinitions() const;
133  QString fullAddressList() const;
134  QString linkColorDefinition() const;
135  QString defaultScreenHeaderFont() const;
136  QString defaultPrintHeaderFont() const;
137 
138  const QPaintDevice *mPaintDevice = nullptr;
139  const HeaderStylePlugin *mHeaderPlugin = nullptr;
140 };
141 }
142 
143 #endif
The CSSHelperBase class.
Definition: csshelperbase.h:26
The HeaderStylePlugin class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:19:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.