1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFONTDIALOG_H
5#define QFONTDIALOG_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtGui/qwindowdefs.h>
9#include <QtGui/qfont.h>
10
11#include <QtWidgets/qdialog.h>
12
13QT_REQUIRE_CONFIG(fontdialog);
14
15QT_BEGIN_NAMESPACE
16
17class QFontDialogPrivate;
18
19class Q_WIDGETS_EXPORT QFontDialog : public QDialog
20{
21 Q_OBJECT
22 Q_DECLARE_PRIVATE(QFontDialog)
23 Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
24 Q_PROPERTY(FontDialogOptions options READ options WRITE setOptions)
25
26public:
27 enum FontDialogOption {
28 NoButtons = 0x00000001,
29 DontUseNativeDialog = 0x00000002,
30 ScalableFonts = 0x00000004,
31 NonScalableFonts = 0x00000008,
32 MonospacedFonts = 0x00000010,
33 ProportionalFonts = 0x00000020
34 };
35 Q_ENUM(FontDialogOption)
36
37 Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
38
39 explicit QFontDialog(QWidget *parent = nullptr);
40 explicit QFontDialog(const QFont &initial, QWidget *parent = nullptr);
41 ~QFontDialog();
42
43 void setCurrentFont(const QFont &font);
44 QFont currentFont() const;
45
46 QFont selectedFont() const;
47
48 void setOption(FontDialogOption option, bool on = true);
49 bool testOption(FontDialogOption option) const;
50 void setOptions(FontDialogOptions options);
51 FontDialogOptions options() const;
52
53 using QDialog::open;
54 void open(QObject *receiver, const char *member);
55
56 void setVisible(bool visible) override;
57
58 static QFont getFont(bool *ok, QWidget *parent = nullptr);
59 static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = nullptr, const QString &title = QString(),
60 FontDialogOptions options = FontDialogOptions());
61
62Q_SIGNALS:
63 void currentFontChanged(const QFont &font);
64 void fontSelected(const QFont &font);
65
66protected:
67 void changeEvent(QEvent *event) override;
68 void done(int result) override;
69 bool eventFilter(QObject *object, QEvent *event) override;
70
71private:
72 Q_DISABLE_COPY(QFontDialog)
73
74 Q_PRIVATE_SLOT(d_func(), void _q_sizeChanged(const QString &))
75 Q_PRIVATE_SLOT(d_func(), void _q_familyHighlighted(int))
76 Q_PRIVATE_SLOT(d_func(), void _q_writingSystemHighlighted(int))
77 Q_PRIVATE_SLOT(d_func(), void _q_styleHighlighted(int))
78 Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
79 Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
80};
81
82Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
83
84QT_END_NAMESPACE
85
86#endif // QFONTDIALOG_H
87

source code of qtbase/src/widgets/dialogs/qfontdialog.h