digiKam
dfontproperties.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-12-23
7  * Description : a widget to change font properties.
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 1996 by Bernd Johannes Wuebben <wuebben at kde dot org>
11  * Copyright (c) 1999 by Preston Brown <pbrown at kde dot org>
12  * Copyright (c) 1999 by Mario Weilguni <mweilguni at kde dot org>
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General
16  * Public License as published by the Free Software Foundation;
17  * either version 2, or (at your option)
18  * any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * ============================================================ */
26 
27 #ifndef DIGIKAM_DFONT_PROPERTIES_H
28 #define DIGIKAM_DFONT_PROPERTIES_H
29 
30 // Qt includes
31 
32 #include <QWidget>
33 #include <QColor>
34 #include <QFont>
35 #include <QStringList>
36 
37 // Local includes
38 
39 #include "digikam_export.h"
40 
41 class QFont;
42 
43 namespace Digikam
44 {
45 
46 class DIGIKAM_EXPORT DFontProperties : public QWidget
47 {
48  Q_OBJECT
49  Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontSelected USER true)
50  Q_PROPERTY(QColor color READ color WRITE setColor)
51  Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
52  Q_PROPERTY(Qt::CheckState sizeIsRelative READ sizeIsRelative WRITE setSizeIsRelative)
53  Q_PROPERTY(QString sampleText READ sampleText WRITE setSampleText)
54 
55 public:
56 
63  {
64  FamilyList = 0x01,
65  StyleList = 0x02,
66  SizeList = 0x04
67  };
68 
74  enum FontDiff
75  {
76  NoFontDiffFlags = 0,
77  FontDiffFamily = 1,
78  FontDiffStyle = 2,
79  FontDiffSize = 4,
80  AllFontDiffs = FontDiffFamily | FontDiffStyle | FontDiffSize
81  };
82  Q_DECLARE_FLAGS(FontDiffFlags, FontDiff)
83 
84 
90  {
91  NoDisplayFlags = 0,
92  FixedFontsOnly = 1,
93  DisplayFrame = 2,
94  ShowDifferences = 4
95  };
96  Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
97 
98 
110  {
111  FixedWidthFonts = 0x01,
112  ScalableFonts = 0x02,
113  SmoothScalableFonts = 0x04
114  };
115 
116 public:
117 
136  explicit DFontProperties(QWidget* const parent = nullptr,
137  const DisplayFlags& flags = DisplayFrame,
138  const QStringList& fontList = QStringList(),
139  int visibleListSize = 8,
140  Qt::CheckState* const sizeIsRelativeState = nullptr);
141 
145  ~DFontProperties() override;
146 
158  void enableColumn(int column, bool state);
159 
171  void makeColumnVisible(int column, bool state);
172 
182  void setFont(const QFont& font, bool onlyFixed = false);
183 
188  FontDiffFlags fontDiffFlags() const;
189 
193  QFont font() const;
194 
198  void setColor(const QColor& col);
199 
204  QColor color() const;
205 
209  void setBackgroundColor(const QColor& col);
210 
215  QColor backgroundColor() const;
216 
223  void setSizeIsRelative(Qt::CheckState relative);
224 
229  Qt::CheckState sizeIsRelative() const;
230 
234  QString sampleText() const;
235 
246  void setSampleText(const QString& text);
247 
253  void setSampleBoxVisible(bool visible);
254 
262  static void getFontList(QStringList& list, uint fontListCriteria);
263 
267  QSize sizeHint(void) const override;
268 
269 Q_SIGNALS:
270 
274  void fontSelected(const QFont& font);
275 
276 private:
277 
278  class Private;
279  Private* const d;
280 
281  Q_DISABLE_COPY(DFontProperties)
282 
283  Q_PRIVATE_SLOT(d, void _d_toggled_checkbox())
284  Q_PRIVATE_SLOT(d, void _d_family_chosen_slot(const QString&))
285  Q_PRIVATE_SLOT(d, void _d_size_chosen_slot(const QString&))
286  Q_PRIVATE_SLOT(d, void _d_style_chosen_slot(const QString&))
287  Q_PRIVATE_SLOT(d, void _d_displaySample(const QFont& font))
288  Q_PRIVATE_SLOT(d, void _d_size_value_slot(double))
289 };
290 
291 Q_DECLARE_OPERATORS_FOR_FLAGS(DFontProperties::DisplayFlags)
292 
293 } // namespace Digikam
294 
295 #endif // DIGIKAM_DFONT_PROPERTIES_H
Definition: dfontproperties.h:47
FontColumn
Definition: dfontproperties.h:63
void fontSelected(const QFont &font)
FontListCriteria
Definition: dfontproperties.h:110
FontDiff
Definition: dfontproperties.h:75
DisplayFlag
Definition: dfontproperties.h:90
Definition: datefolderview.cpp:43