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
|
// 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 "qqstylekitstorage_p.h"
QT_BEGIN_NAMESPACE
class QQuickPalette;
class QQStyleKitVariation;
class QQStyleKitPropertyResolver;
class QQStyleKitReader : public QQStyleKitControlProperties
{
Q_OBJECT
Q_PROPERTY(QQStyleKitExtendedControlType type READ type WRITE setType NOTIFY typeChanged 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(StyleKitReader)
public:
enum ControlType {
Unspecified = 100000,
Control,
AbstractButton,
Button,
CheckBox,
ComboBox,
FlatButton,
Slider,
SpinBox,
SwitchControl,
SearchField,
TextArea,
TextField,
TextInput,
RadioButton,
ItemDelegate,
Popup,
Menu,
Dialog,
Pane,
Page,
Frame
};
Q_ENUM(ControlType)
enum class AlternateState {
Alternate1,
Alternate2
};
Q_ENUM(AlternateState)
QQStyleKitReader(QObject *parent = nullptr);
~QQStyleKitReader();
QQStyleKitExtendedControlType type() const;
void setType(QQStyleKitExtendedControlType 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);
bool vertical() const;
void setVertical(bool vertical);
bool highlighted() const;
void setHighlighted(bool highlighted);
QFont font() const;
void setFont(const QFont &font);
QQStyleKitControlProperties *global() const;
QVariant readStyleProperty(PropertyStorageId key) const;
void writeStyleProperty(PropertyStorageId key, const QVariant &value);
void clearLocalStorage();
QQSK::State controlState() const;
static void setTransitionEnabled(bool enabled);
static bool transitionEnabled();
static void resetAll();
void updateFontFromTheme();
static QList<QQStyleKitReader *> s_allReaders;
signals:
void typeChanged();
void customTypeChanged();
void propertiesChanged();
void enabledChanged();
void focusedChanged();
void checkedChanged();
void hoveredChanged();
void pressedChanged();
void paletteChanged();
void verticalChanged();
void highlightedChanged();
void fontChanged();
private:
void updateControl();
void populateLocalStorage();
bool dontEmitChangedSignals() const;
QQuickStateGroup *stateGroup();
QQmlComponent *createControlChangesComponent() const;
QQmlComponent *createDelegateChangesComponent(const QString &delegateName) const;
void instantiatePropertyChanges(QQmlComponent *comp);
void maybeTrackDelegates();
private:
Q_DISABLE_COPY(QQStyleKitReader)
/* The reason we have a QQStyleKitExtendedControlType 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. */
QQStyleKitExtendedControlType m_type = ControlType::Unspecified;
bool m_dontEmitChangedSignals: 1;
bool m_effectiveVariationsDirty: 1;
QQuickPalette m_palette;
QFont m_font;
mutable QQStyleKitPropertyStorage m_storage;
AlternateState m_alternateState = AlternateState::Alternate1;
QQSK::State m_state = QQSK::StateFlag::NoState;
QQuickStateGroup *m_stateGroup = nullptr;
QQSK::Delegates m_trackedDelegates = QQSK::Delegate::NoDelegate;
QPointer<QQStyleKitReader> m_parentReader;
QList<QPointer<QQStyleKitVariation>> m_effectiveInAppVariations;
QList<QPointer<QQStyleKitVariation>> m_effectiveInStyleVariations;
QQStyleKitControlProperties m_global;
static QMap<QString, QQmlComponent *> s_propertyChangesComponents;
friend class QQStyleKitControlProperties;
friend class QQStyleKitPropertyResolver;
friend class QQStyleKitPropertyGroup;
};
QT_END_NAMESPACE
#endif // QQSTYLEKITREADER_P_H
|