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 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
65
66 Q_DISABLE_COPY(QQuickFontDialogImpl)
67 Q_DECLARE_PRIVATE(QQuickFontDialogImpl)
68};
69
70class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFontDialogImplAttached : public QObject
71{
72 Q_OBJECT
73 Q_PROPERTY(QQuickListView *familyListView READ familyListView WRITE setFamilyListView
74 NOTIFY familyListViewChanged)
75 Q_PROPERTY(QQuickListView *styleListView READ styleListView WRITE setStyleListView
76 NOTIFY styleListViewChanged)
77 Q_PROPERTY(QQuickListView *sizeListView READ sizeListView WRITE setSizeListView
78 NOTIFY sizeListViewChanged)
79 Q_PROPERTY(QQuickTextEdit *sampleEdit READ sampleEdit WRITE setSampleEdit
80 NOTIFY sampleEditChanged)
81 Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox WRITE setButtonBox
82 NOTIFY buttonBoxChanged)
83 Q_PROPERTY(QQuickComboBox *writingSystemComboBox READ writingSystemComboBox
84 WRITE setWritingSystemComboBox NOTIFY writingSystemComboBoxChanged)
85 Q_PROPERTY(QQuickCheckBox *underlineCheckBox READ underlineCheckBox WRITE setUnderlineCheckBox
86 NOTIFY underlineCheckBoxChanged)
87 Q_PROPERTY(QQuickCheckBox *strikeoutCheckBox READ strikeoutCheckBox WRITE setStrikeoutCheckBox
88 NOTIFY strikeoutCheckBoxChanged)
89
90 Q_PROPERTY(QQuickTextField *familyEdit READ familyEdit WRITE setFamilyEdit
91 NOTIFY familyEditChanged)
92 Q_PROPERTY(QQuickTextField *styleEdit READ styleEdit WRITE setStyleEdit NOTIFY styleEditChanged)
93 Q_PROPERTY(QQuickTextField *sizeEdit READ sizeEdit WRITE setSizeEdit NOTIFY sizeEditChanged)
94
95 Q_MOC_INCLUDE(<QtQuickTemplates2 / private / qquickdialogbuttonbox_p.h>)
96
97public:
98 explicit QQuickFontDialogImplAttached(QObject *parent = nullptr);
99
100 QQuickListView *familyListView() const;
101 void setFamilyListView(QQuickListView *familyListView);
102
103 QQuickListView *styleListView() const;
104 void setStyleListView(QQuickListView *styleListView);
105
106 QQuickListView *sizeListView() const;
107 void setSizeListView(QQuickListView *sizeListView);
108
109 QQuickTextEdit *sampleEdit() const;
110 void setSampleEdit(QQuickTextEdit *sampleEdit);
111
112 QQuickDialogButtonBox *buttonBox() const;
113 void setButtonBox(QQuickDialogButtonBox *buttonBox);
114
115 QQuickComboBox *writingSystemComboBox() const;
116 void setWritingSystemComboBox(QQuickComboBox *writingSystemComboBox);
117
118 QQuickCheckBox *underlineCheckBox() const;
119 void setUnderlineCheckBox(QQuickCheckBox *underlineCheckBox);
120
121 QQuickCheckBox *strikeoutCheckBox() const;
122 void setStrikeoutCheckBox(QQuickCheckBox *strikethroughCheckBox);
123
124 QQuickTextField *familyEdit() const;
125 void setFamilyEdit(QQuickTextField *familyEdit);
127 QQuickTextField *styleEdit() const;
128 void setStyleEdit(QQuickTextField *styleEdit);
130 QQuickTextField *sizeEdit() const;
131 void setSizeEdit(QQuickTextField *sizeEdit);
133Q_SIGNALS:
134 void buttonBoxChanged();
135 void familyListViewChanged();
136 void styleListViewChanged();
137 void sizeListViewChanged();
138 void sampleEditChanged();
139 void writingSystemComboBoxChanged();
140 void underlineCheckBoxChanged();
141 void strikeoutCheckBoxChanged();
142 void familyEditChanged();
143 void styleEditChanged();
144 void sizeEditChanged();
145
146public:
147 void searchFamily(const QString &s) { searchListView(s, familyListView()); }
148 void searchStyle(const QString &s) { searchListView(s, styleListView()); }
149 void clearSearch();
150
151 void updateFamilies();
152 void selectFontInListViews(const QFont &font);
153
154private:
155 void updateStyles();
156 void updateSizes();
157
158 void _q_familyChanged();
159 void _q_styleChanged();
160 void _q_sizeEdited();
161 void _q_sizeChanged();
162 void _q_updateSample();
163
164 void _q_writingSystemChanged(int index);
165
166 void searchListView(const QString &s, QQuickListView *listView);
167
168 QFontDatabase::WritingSystem m_writingSystem;
169 QString m_selectedFamily;
170 QString m_selectedStyle;
171 QString m_search;
172 int m_selectedSize;
173 bool m_smoothlyScalable;
174 bool m_ignoreFamilyUpdate;
175 bool m_ignoreStyleUpdate;
176
177 Q_DISABLE_COPY(QQuickFontDialogImplAttached)
178 Q_DECLARE_PRIVATE(QQuickFontDialogImplAttached)
179};
180
181QT_END_NAMESPACE
182
183#endif // QQUICKFONTDIALOGIMPL_P_H
void handleClick(QQuickAbstractButton *button) override
QQuickFontDialogImplAttached * attachedOrWarn()
Combined button and popup list for selecting options.
static int findFamilyInModel(const QString &selectedFamily, const QStringList &model)
static int findStyleInModel(const QString &selectedStyle, const QStringList &model)