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