KWidgetsAddons

kfontchooser.h
1 /*
2  SPDX-FileCopyrightText: 1997 Bernd Johannes Wuebben <[email protected]>
3  SPDX-FileCopyrightText: 1999 Preston Brown <[email protected]>
4  SPDX-FileCopyrightText: 1999 Mario Weilguni <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 #ifndef K_FONT_CHOOSER_H
9 #define K_FONT_CHOOSER_H
10 
11 #include <kwidgetsaddons_export.h>
12 #include <QWidget>
13 
14 class QFont;
15 class QStringList;
16 
33 class KWIDGETSADDONS_EXPORT KFontChooser : public QWidget
34 {
35  Q_OBJECT
36  Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontSelected USER true)
37  Q_PROPERTY(QColor color READ color WRITE setColor)
38  Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
39  Q_PROPERTY(Qt::CheckState sizeIsRelative READ sizeIsRelative WRITE setSizeIsRelative)
40  Q_PROPERTY(QString sampleText READ sampleText WRITE setSampleText)
41 
42 public:
46  enum FontColumn {
47  FamilyList = 0x01,
48  StyleList = 0x02,
49  SizeList = 0x04
50  };
51 
56  enum FontDiff {
57  NoFontDiffFlags = 0,
58  FontDiffFamily = 1,
59  FontDiffStyle = 2,
60  FontDiffSize = 4,
61  AllFontDiffs = FontDiffFamily | FontDiffStyle | FontDiffSize
62  };
66  Q_DECLARE_FLAGS(FontDiffFlags, FontDiff)
67 
68 
72  enum DisplayFlag {
73  NoDisplayFlags = 0,
74  FixedFontsOnly = 1,
75  DisplayFrame = 2,
77  ShowDifferences = 4,
78  };
82  Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
83 
84 
113  explicit KFontChooser(QWidget *parent = nullptr,
114  const DisplayFlags &flags = DisplayFrame,
115  const QStringList &fontList = QStringList(),
116  int visibleListSize = 8,
117  Qt::CheckState *sizeIsRelativeState = nullptr);
118 
122  ~KFontChooser() override;
123 
135  void enableColumn(int column, bool state);
136 
144  void setFont(const QFont &font, bool onlyFixed = false);
145 
150  FontDiffFlags fontDiffFlags() const;
151 
155  QFont font() const;
156 
160  void setColor(const QColor &col);
161 
166  QColor color() const;
167 
171  void setBackgroundColor(const QColor &col);
172 
177  QColor backgroundColor() const;
178 
185  void setSizeIsRelative(Qt::CheckState relative);
186 
191  Qt::CheckState sizeIsRelative() const;
192 
196  QString sampleText() const;
197 
208  void setSampleText(const QString &text);
209 
215  void setSampleBoxVisible(bool visible);
216 
225  FixedWidthFonts = 0x01,
231  ScalableFonts = 0x02,
237  SmoothScalableFonts = 0x04
238  };
239 
247  static void getFontList(QStringList &list, uint fontListCriteria);
248 
252  QSize sizeHint(void) const override;
253 
254 Q_SIGNALS:
258  void fontSelected(const QFont &font);
259 
260 private:
261  class Private;
262  Private *const d;
263 
265 
266  Q_PRIVATE_SLOT(d, void _k_family_chosen_slot(const QString &))
267  Q_PRIVATE_SLOT(d, void _k_size_chosen_slot(const QString &))
268  Q_PRIVATE_SLOT(d, void _k_style_chosen_slot(const QString &))
269  Q_PRIVATE_SLOT(d, void _k_displaySample(const QFont &font))
270  Q_PRIVATE_SLOT(d, void _k_size_value_slot(double))
271 };
272 
273 Q_DECLARE_OPERATORS_FOR_FLAGS(KFontChooser::DisplayFlags)
274 
275 #endif
FontDiff
Flags for selecting which font attributes to change.
Definition: kfontchooser.h:56
FontColumn
Displayed columns.
Definition: kfontchooser.h:46
DisplayFlag
Flags for selecting what is displayed in the widget.
Definition: kfontchooser.h:72
Q_PROPERTY(...)
virtual QSize sizeHint() const const
Q_DISABLE_COPY(Class)
A font selection widget.
Definition: kfontchooser.h:33
FontListCriteria
The selection criteria for the font families shown in the dialog.
Definition: kfontchooser.h:220
CheckState
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 22:42:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.