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