1 | // Copyright (C) 2021 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 QQUICKFONTDIALOGIMPL_P_H |
5 | #define QQUICKFONTDIALOGIMPL_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/qfontdatabase.h> |
19 | #include <QtQuick/private/qquicklistview_p.h> |
20 | #include <QtQuick/private/qquicktextedit_p.h> |
21 | #include <QtQuickTemplates2/private/qquicktextfield_p.h> |
22 | #include <QtQuickTemplates2/private/qquickcombobox_p.h> |
23 | #include <QtQuickTemplates2/private/qquickcheckbox_p.h> |
24 | #include <QtQuickTemplates2/private/qquickdialog_p.h> |
25 | #include "qtquickdialogs2quickimplglobal_p.h" |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QQuickDialogButtonBox; |
30 | |
31 | class QQuickFontDialogImplAttached; |
32 | class QQuickFontDialogImplAttachedPrivate; |
33 | class QQuickFontDialogImplPrivate; |
34 | |
35 | class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickFontDialogImpl : public QQuickDialog |
36 | { |
37 | Q_OBJECT |
38 | Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged FINAL) |
39 | QML_NAMED_ELEMENT(FontDialogImpl) |
40 | QML_ATTACHED(QQuickFontDialogImplAttached) |
41 | QML_ADDED_IN_VERSION(6, 2) |
42 | |
43 | public: |
44 | explicit QQuickFontDialogImpl(QObject *parent = nullptr); |
45 | |
46 | static QQuickFontDialogImplAttached *qmlAttachedProperties(QObject *object); |
47 | |
48 | QSharedPointer<QFontDialogOptions> options() const; |
49 | void setOptions(const QSharedPointer<QFontDialogOptions> &options); |
50 | |
51 | QFont currentFont() const; |
52 | void setCurrentFont(const QFont &font, bool selectInListViews = false); |
53 | |
54 | void init(); |
55 | |
56 | Q_SIGNALS: |
57 | void optionsChanged(); |
58 | void currentFontChanged(const QFont &font); |
59 | |
60 | private: |
61 | void keyReleaseEvent(QKeyEvent *event) override; |
62 | void focusOutEvent(QFocusEvent *event) override; |
63 | |
64 | Q_DISABLE_COPY(QQuickFontDialogImpl) |
65 | Q_DECLARE_PRIVATE(QQuickFontDialogImpl) |
66 | }; |
67 | |
68 | class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickFontDialogImplAttached : public QObject |
69 | { |
70 | Q_OBJECT |
71 | Q_PROPERTY(QQuickListView *familyListView READ familyListView WRITE setFamilyListView |
72 | NOTIFY familyListViewChanged) |
73 | Q_PROPERTY(QQuickListView *styleListView READ styleListView WRITE setStyleListView |
74 | NOTIFY styleListViewChanged) |
75 | Q_PROPERTY(QQuickListView *sizeListView READ sizeListView WRITE setSizeListView |
76 | NOTIFY sizeListViewChanged) |
77 | Q_PROPERTY(QQuickTextEdit *sampleEdit READ sampleEdit WRITE setSampleEdit |
78 | NOTIFY sampleEditChanged) |
79 | Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox WRITE setButtonBox |
80 | NOTIFY buttonBoxChanged) |
81 | Q_PROPERTY(QQuickComboBox *writingSystemComboBox READ writingSystemComboBox |
82 | WRITE setWritingSystemComboBox NOTIFY writingSystemComboBoxChanged) |
83 | Q_PROPERTY(QQuickCheckBox *underlineCheckBox READ underlineCheckBox WRITE setUnderlineCheckBox |
84 | NOTIFY underlineCheckBoxChanged) |
85 | Q_PROPERTY(QQuickCheckBox *strikeoutCheckBox READ strikeoutCheckBox WRITE setStrikeoutCheckBox |
86 | NOTIFY strikeoutCheckBoxChanged) |
87 | |
88 | Q_PROPERTY(QQuickTextField *familyEdit READ familyEdit WRITE setFamilyEdit |
89 | NOTIFY familyEditChanged) |
90 | Q_PROPERTY(QQuickTextField *styleEdit READ styleEdit WRITE setStyleEdit NOTIFY styleEditChanged) |
91 | Q_PROPERTY(QQuickTextField *sizeEdit READ sizeEdit WRITE setSizeEdit NOTIFY sizeEditChanged) |
92 | |
93 | Q_MOC_INCLUDE(<QtQuickTemplates2 / private / qquickdialogbuttonbox_p.h>) |
94 | |
95 | public: |
96 | explicit QQuickFontDialogImplAttached(QObject *parent = nullptr); |
97 | |
98 | QQuickListView *familyListView() const; |
99 | void setFamilyListView(QQuickListView *familyListView); |
100 | |
101 | QQuickListView *styleListView() const; |
102 | void setStyleListView(QQuickListView *styleListView); |
103 | |
104 | QQuickListView *sizeListView() const; |
105 | void setSizeListView(QQuickListView *sizeListView); |
106 | |
107 | QQuickTextEdit *sampleEdit() const; |
108 | void setSampleEdit(QQuickTextEdit *sampleEdit); |
109 | |
110 | QQuickDialogButtonBox *buttonBox() const; |
111 | void setButtonBox(QQuickDialogButtonBox *buttonBox); |
112 | |
113 | QQuickComboBox *writingSystemComboBox() const; |
114 | void setWritingSystemComboBox(QQuickComboBox *writingSystemComboBox); |
115 | |
116 | QQuickCheckBox *underlineCheckBox() const; |
117 | void setUnderlineCheckBox(QQuickCheckBox *underlineCheckBox); |
118 | |
119 | QQuickCheckBox *strikeoutCheckBox() const; |
120 | void setStrikeoutCheckBox(QQuickCheckBox *strikethroughCheckBox); |
121 | |
122 | QQuickTextField *familyEdit() const; |
123 | void setFamilyEdit(QQuickTextField *familyEdit); |
124 | |
125 | QQuickTextField *styleEdit() const; |
126 | void setStyleEdit(QQuickTextField *styleEdit); |
127 | |
128 | QQuickTextField *sizeEdit() const; |
129 | void setSizeEdit(QQuickTextField *sizeEdit); |
130 | |
131 | Q_SIGNALS: |
132 | void buttonBoxChanged(); |
133 | void familyListViewChanged(); |
134 | void styleListViewChanged(); |
135 | void sizeListViewChanged(); |
136 | void sampleEditChanged(); |
137 | void writingSystemComboBoxChanged(); |
138 | void underlineCheckBoxChanged(); |
139 | void strikeoutCheckBoxChanged(); |
140 | void familyEditChanged(); |
141 | void styleEditChanged(); |
142 | void sizeEditChanged(); |
143 | |
144 | public: |
145 | void searchFamily(const QString &s) { searchListView(s, listView: familyListView()); } |
146 | void searchStyle(const QString &s) { searchListView(s, listView: styleListView()); } |
147 | void clearSearch(); |
148 | |
149 | void updateFamilies(); |
150 | void selectFontInListViews(const QFont &font); |
151 | |
152 | private: |
153 | void updateStyles(); |
154 | void updateSizes(); |
155 | |
156 | void _q_familyChanged(); |
157 | void _q_styleChanged(); |
158 | void _q_sizeEdited(); |
159 | void _q_sizeChanged(); |
160 | void _q_updateSample(); |
161 | |
162 | void _q_writingSystemChanged(int index); |
163 | |
164 | void searchListView(const QString &s, QQuickListView *listView); |
165 | |
166 | QFontDatabase::WritingSystem m_writingSystem; |
167 | QString m_selectedFamily; |
168 | QString m_selectedStyle; |
169 | QString m_search; |
170 | int m_selectedSize; |
171 | bool m_smoothlyScalable; |
172 | bool m_ignoreFamilyUpdate; |
173 | bool m_ignoreStyleUpdate; |
174 | |
175 | Q_DISABLE_COPY(QQuickFontDialogImplAttached) |
176 | Q_DECLARE_PRIVATE(QQuickFontDialogImplAttached) |
177 | }; |
178 | |
179 | QT_END_NAMESPACE |
180 | |
181 | QML_DECLARE_TYPE(QQuickFontDialogImpl) |
182 | |
183 | #endif // QQUICKFONTDIALOGIMPL_P_H |
184 | |