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
qqstylekitreader_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QQSTYLEKITREADER_P_H
6#define QQSTYLEKITREADER_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 <QtQml/QtQml>
20#include <QtQuick/private/qquickpalette_p.h>
21
25
26#include <QtCore/qcompare.h>
27
29
30class QQuickPalette;
33
34class Q_LABSSTYLEKIT_EXPORT QQStyleKitReader : public QQStyleKitControlProperties, public QQmlParserStatus
35{
36 Q_OBJECT
37 Q_INTERFACES(QQmlParserStatus)
38 Q_PROPERTY(QQStyleKitExtendableControlType controlType READ controlType WRITE setControlType NOTIFY controlTypeChanged FINAL)
39 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
40 Q_PROPERTY(bool focused READ focused WRITE setFocused NOTIFY focusedChanged FINAL)
41 Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged FINAL)
42 Q_PROPERTY(bool hovered READ hovered WRITE setHovered NOTIFY hoveredChanged FINAL)
43 Q_PROPERTY(bool pressed READ pressed WRITE setPressed NOTIFY pressedChanged FINAL)
44 Q_PROPERTY(bool vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL)
45 Q_PROPERTY(bool highlighted READ highlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
46 Q_PROPERTY(QFont font READ font NOTIFY fontChanged FINAL)
47 Q_PROPERTY(QQuickPalette *palette READ palette WRITE setPalette NOTIFY paletteChanged FINAL)
48 Q_PROPERTY(QQStyleKitControlProperties *global READ global CONSTANT FINAL)
49
50 QML_NAMED_ELEMENT(StyleReader)
51
52public:
53 enum ControlType {
54 Unspecified = 100000,
55 Control,
56 AbstractButton,
57 ApplicationWindow,
58 BusyIndicator,
59 Button,
60 CheckBox,
61 CheckDelegate,
62 ComboBox,
63 Container,
64 DayOfWeekRow,
65 DelayButton,
66 Dial,
67 Dialog,
68 DialogButtonBox,
69 Drawer,
70 FlatButton,
71 HeaderViewDelegate,
72 ProgressBar,
73 ScrollBar,
74 ScrollIndicator,
75 ScrollView,
76 Slider,
77 SpinBox,
78 SplitView,
79 SwipeDelegate,
80 SwitchControl,
81 SwitchDelegate,
82 SearchField,
83 TabBar,
84 TabButton,
85 TableViewDelegate,
86 TextArea,
87 TextField,
88 TextInput,
89 ToolBar,
90 ToolButton,
91 ToolSeparator,
92 ToolTip,
93 TreeViewDelegate,
94 Tumbler,
95 RadioButton,
96 RadioDelegate,
97 RoundButton,
98 ItemDelegate,
99 Popup,
100 Menu,
101 MenuBar,
102 MenuBarItem,
103 MenuItem,
104 MenuSeparator,
105 MonthGrid,
106 Pane,
107 Page,
108 PageIndicator,
109 Frame,
110 Label,
111 GroupBox,
112 WeekNumberColumn
113 };
114 Q_ENUM(ControlType)
115
116 enum class AlternateState {
117 Alternate1,
118 Alternate2
119 };
120 Q_ENUM(AlternateState)
121
122 QQStyleKitReader(QObject *parent = nullptr);
123 ~QQStyleKitReader();
124
125 QQStyleKitExtendableControlType controlType() const;
126 void setControlType(QQStyleKitExtendableControlType type);
127#ifdef QT_DEBUG
128 ControlType typeAsControlType() const;
129#endif
130
131 bool hovered() const;
132 void setHovered(bool hovered);
133
134 bool enabled() const;
135 void setEnabled(bool enabled);
136
137 bool focused() const;
138 void setFocused(bool focused);
139
140 bool checked() const;
141 void setChecked(bool checked);
142
143 bool pressed() const;
144 void setPressed(bool pressed);
145
146 QQuickPalette *palette() const;
147 void setPalette(QQuickPalette *palette);
148 QPalette effectivePalette() const;
149
150 bool vertical() const;
151 void setVertical(bool vertical);
152
153 bool highlighted() const;
154 void setHighlighted(bool highlighted);
155
156 QQStyleKitStyle *explicitStyle() const;
157 void setExplicitStyle(QQStyleKitStyle *style);
158
159 QFont font() const;
160
161 QQStyleKitControlProperties *global() const;
162
163 QVariant readStyleProperty(PropertyStorageId key) const;
164 void writeStyleProperty(PropertyStorageId key, const QVariant &value);
165 void clearLocalStorage();
166
167 QQSK::State controlState() const;
168
169 void setControlTypeAndState(QQStyleKitExtendableControlType controlType, QQSK::State flags,
170 bool applyStateChange = true);
171
172 QObject *target() const;
173 void setTarget(QObject *target);
174
175 // Called by componentComplete()
176 // Factored out so the widget style can call it
177 void setCompleted(bool completed);
178
179 bool transitionsEnabled() const;
180 void setTransitionsEnabled(bool enabled);
181
182 static void resetReadersForStyle(const QQStyleKitStyle *style);
183
184 static QList<QQStyleKitReader *> s_allReaders;
185
186signals:
187 void controlTypeChanged();
188 void customTypeChanged();
189 void propertiesChanged();
190 void enabledChanged();
191 void focusedChanged();
192 void checkedChanged();
193 void hoveredChanged();
194 void pressedChanged();
195 void paletteChanged();
196 void verticalChanged();
197 void highlightedChanged();
198 void fontChanged();
199
200private slots:
201 void onPaletteChanged();
202
203protected:
204 void classBegin() override {}
205 void componentComplete() override;
206
207private:
208 void updateControl(bool applyStateChange = true);
209 void populateLocalStorage();
210 bool dontEmitChangedSignals() const;
211
212 QQuickStateGroup *stateGroup();
213 QQmlComponent *createControlChangesComponent() const;
214 QQmlComponent *createDelegateChangesComponent(const QString &delegateName) const;
215 void instantiatePropertyChanges(QQmlComponent *comp);
216 void maybeTrackDelegates();
217
218 bool rebuildEffectivePalette();
219 bool rebuildEffectiveFont();
220
221private:
222 Q_DISABLE_COPY(QQStyleKitReader)
223
224 /* The reason we have a QQStyleKitExtendableControlType in addition to
225 * QQStyleKitReader::ControlType, is that we allow the style to define controls types
226 * in the style beyond the types we offer in Qt Quick Controls. The predefined controls
227 * (QQStyleKitReader::ControlType) have types that starts at 100000 (ControlType::Unspecified),
228 * and any number before that is available for use for defining custom controls. */
229 QQStyleKitExtendableControlType m_type = ControlType::Unspecified;
230
231 bool m_dontEmitChangedSignals: 1;
232 bool m_effectiveVariationsDirty: 1;
233 bool m_transitionsEnabled: 1;
234 bool m_completed: 1;
235
236 QPointer<QQuickPalette> m_palette;
237 QPalette m_effectivePalette;
238 QFont m_font;
239 bool m_fontDirty = true;
240 quint64 m_lastTextFontOverridesSignature = 0;
241 mutable QQStyleKitPropertyStorage m_storage;
242 AlternateState m_alternateState = AlternateState::Alternate1;
243 QQSK::State m_state = QQSK::StateFlag::Unspecified;
244 QQuickStateGroup *m_stateGroup = nullptr;
245 QQSK::Delegates m_trackedDelegates = QQSK::Delegate::NoDelegate;
246
247 QPointer<QObject> m_target;
248 QPointer<QQStyleKitStyle> m_explicitStyle;
249 QPointer<QQStyleKitReader> m_parentReader;
250 QList<QPointer<QQStyleKitVariation>> m_effectiveVariations;
251
252 QQStyleKitControlProperties m_global;
253
254 using PropertyChangesComponents = QMap<std::pair<Qt::totally_ordered_wrapper<QQmlEngine*>, QString>, QPointer<QQmlComponent>>;
255 static PropertyChangesComponents s_propertyChangesComponents;
256
257 friend class QQStyleKitControlProperties;
258 friend class QQStyleKitPropertyResolver;
259 friend class QQStyleKitPropertyGroup;
260};
261
262QT_END_NAMESPACE
263
264#endif // QQSTYLEKITREADER_P_H
void filterChanged()
QString filter() const
void setFilter(const QString &filter)
void setControl(QQuickItem *item)
static Q_INVOKABLE bool insideControl(const QObject *child)
Combined button and popup list for selecting options.