Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqstylekitpropertypath_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
QQSTYLEKITPROPERTYPATH_P_H
6
#
define
QQSTYLEKITPROPERTYPATH_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
"qqstylekitglobal_p.h"
20
21
/* Each style property in StyleKit needs a unique PropertyStorageId that can be used as
22
* a key in the map that stores its value. To compute such an ID, we must consider the
23
* property's full nested path, since properties like 'background.color' and
24
* 'background.border.color' refer to different values.
25
*
26
* Because a property may have multiple values depending on the control's state and
27
* subtype, we distinguish between a property's path ID and its storage ID. The path
28
* ID represents the portion of the property path that does not vary during lookups.
29
* For example, in the full path:
30
*
31
* "button.pressed.indicator.up.background.color"
32
*
33
* the portion that is invariant is:
34
*
35
* "indicator.background.color"
36
*
37
* The other parts of the path—such as the control type ('button'), the state ('pressed'),
38
* and the subtype ('up')—are resolved dynamically by the propagation engine. During lookup,
39
* the engine substitutes these components in decreasing order of specificity. For instance:
40
*
41
* - If the property is not found on 'button', it falls back to 'abstractButton'.
42
* - If it is not found in the 'pressed' state, it falls back to 'normal'.
43
* - If it is not found in the 'up' subtype, it falls back to 'indicator'.
44
*
45
* These varying components are prepended in sequence by the propagation engine to form
46
* the final PropertyStorageId, which uniquely identifies the stored value in the map.
47
*
48
* Note that a property path may also include groups known as Options. These are not part
49
* of the Path ID or the Storage ID; they are simply flags used by QQStyleKitPropertyResolver
50
* to control how a property should be read.
51
*
52
* In general, the structure of a property path is:
53
*
54
* control.options.states.subtype.nested_group_path.property
55
*
56
* However, for API convenience, subtypes are written inside the delegate they belong to.
57
* For example, although the storage path is "spinBox.up.indicator.background.color", the
58
* style syntax is "spinBox.indicator.up.background.color". */
59
60
QT_BEGIN_NAMESPACE
61
62
class
QQStyleKitPropertyGroup;
63
64
using
PropertyPathId = quint32;
65
using
PropertyStorageId = quint32;
66
using
QQStyleKitExtendableControlType = quint32;
67
using
QQStyleKitPropertyStorage = QHash<PropertyStorageId, QVariant>;
68
69
constexpr
PropertyPathId
maxPropertyStorageSpaceSize
= std::numeric_limits<PropertyPathId>::max();
70
constexpr
PropertyPathId
nestedGroupCount
= PropertyPathId(QQSK::PropertyGroup::PATH_ID_GROUP_COUNT);
71
constexpr
PropertyPathId
maxStateCombinationCount
= PropertyPathId(QQSK::StateFlag::MAX_STATE);
72
constexpr
PropertyPathId
stateStorageSpaceSize
= maxPropertyStorageSpaceSize / maxStateCombinationCount;
73
constexpr
PropertyPathId
subtypeCount
= PropertyPathId(QQSK::PropertyPathFlag::DelegateSubtype2) - PropertyPathId(QQSK::PropertyPathFlag::DelegateSubtype0) + 1;
74
constexpr
PropertyPathId
nestedGroupsStartSize
= maxPropertyStorageSpaceSize / (
maxStateCombinationCount
* subtypeCount);
75
constexpr
PropertyPathId
subtypeStorageSpaceSize
= maxPropertyStorageSpaceSize / (
subtypeCount
* maxStateCombinationCount);
76
77
struct
QQStyleKitPropertyGroupSpace
{
78
PropertyPathId
size
= 0;
79
PropertyPathId
start
= 0;
80
};
81
82
class
QQStyleKitPropertyPath
{
83
Q_GADGET
84
85
public
:
86
enum
class
Flag
{
87
ExcludeSubtype
,
88
IncludeSubtype
89
};
90
Q_ENUM(Flag)
91
92
QQStyleKitPropertyPath
() : m_property(QQSK::Property::NoProperty), m_groupStart(0) {}
93
QQStyleKitPropertyPath
(
94
const
QQStyleKitPropertyGroup
*
group
,
95
QQSK
::
Property
property
=
QQSK
::
Property
::
NoProperty
,
96
Flag
flag
=
Flag
::
IncludeSubtype
);
97
98
inline
QQSK
::
Property
property
()
const
{
return
m_property
; }
99
inline
QString
toString
()
const
{
return
pathIdToPathString
(
pathId
()); }
100
101
static
QString
pathIdToPathString
(
PropertyPathId
pathId
);
102
static
QString
storageIdToPathString
(PropertyStorageId storageId);
103
104
inline
PropertyPathId
pathId
()
const
105
{
106
/* The path ID is the property's identifier when its group path is taken
107
* into account. Each property inside QQStyleKitControlProperties has a unique
108
* path ID. For example, both 'background.color' and 'indicator.color' use the
109
* same QQSK::Property (Color), but they still have different path IDs.
110
* Whether or not to include the subtype, and therefore prepend it in front of
111
* the group path, was decided already in the constructor. */
112
return
m_groupStart + PropertyPathId(m_property);
113
}
114
115
inline
QQSK
::
PropertyGroup
subType
()
const
116
{
117
return
extractSubtype
(
m_groupStart
);
118
}
119
120
inline
PropertyStorageId
createStorageId
(
QQSK
::
State
state
)
const
121
{
122
/* To compute the fully qualified property ID used as a key in a storage map
123
* (QMap) that holds its value, we need to prefix the path ID with the state ID,
124
* since the same path can have different values in different states.
125
* Because StateFlag::Normal == 1, we subtract 1 so that the address space for
126
* properties in the Normal state starts at 0. */
127
Q_ASSERT
(
state
!=
QQSK
::
StateFlag
::
Unspecified
);
128
const
PropertyPathId
stateIndex
=
PropertyPathId
(
state
) - 1;
129
const
PropertyPathId
stateStart
=
stateIndex
*
stateStorageSpaceSize
;
130
return
stateStart
+
pathId
();
131
}
132
133
static
inline
QQSK
::
PropertyGroup
extractSubtype
(
PropertyPathId
pathId
)
134
{
135
/* The subtype occupies its own slab at the start of the path ID space, so the
136
* subtype index is recovered by dividing the path ID by the slab size. Both the
137
* group start and the full path ID lie within the same slab, so the result is the
138
* same whether or not the property is included. */
139
const
PropertyPathId
subtypeIndex
=
pathId
/
subtypeStorageSpaceSize
;
140
return
QQSK
::
PropertyGroup
(
int
(
QQSK
::
PropertyGroup
::
DelegateSubtype0
) +
int
(
subtypeIndex
));
141
}
142
143
static
inline
QQSK
::
State
extractState
(
PropertyStorageId
storageId
)
144
{
145
/* Reverse the storageId function above, and return the state from the
146
* given PropertyStorageId. The state occupies the most significant portion
147
* of storageId. Adding 1 reverses the -1 applied in storageId() when encoding
148
* the state. */
149
const
PropertyPathId
stateIndex
=
storageId
/
stateStorageSpaceSize
;
150
return
QQSK
::
State
(
stateIndex
+ 1);
151
}
152
153
static
inline
PropertyPathId
extractPropertyPathId
(
PropertyStorageId
storageId
,
154
QQStyleKitPropertyPath
::
Flag
flag
=
QQStyleKitPropertyPath
::
Flag
::
IncludeSubtype
)
155
{
156
/* Reverse the storageId function above, and return the path ID from the
157
* given PropertyStorageId. The state is stripped by taking the remainder,
158
* leaving the path ID including the subtype. When ExcludeSubtype, the subtype
159
* slab is stripped with a second remainder operation. */
160
if
(
flag
==
Flag
::
IncludeSubtype
)
161
return
storageId
%
stateStorageSpaceSize
;
162
else
163
return
(
storageId
%
stateStorageSpaceSize
) %
subtypeStorageSpaceSize
;
164
}
165
166
private
:
167
QQSK
::
Property
m_property
;
168
PropertyPathId
m_groupStart
;
169
170
static
QHash<PropertyPathId, QString> s_cachedPathStrings;
171
};
172
173
QT_END_NAMESPACE
174
175
#
endif
// QQSTYLEKITPROPERTYPATH_P_H
QQStyleKitBorderProperties
Definition
qqstylekitcontrolproperties_p.h:153
QQStyleKitControlProperties
Definition
qqstylekitcontrolproperties_p.h:603
QQStyleKitDelegateContainer
Definition
qqstylekitdelegatecontainer_p.h:27
QQStyleKitDelegateContainer::delegateStyle
QQStyleKitDelegateProperties * delegateStyle() const
Definition
qqstylekitdelegatecontainer.cpp:28
QQStyleKitDelegateContainer::~QQStyleKitDelegateContainer
~QQStyleKitDelegateContainer() override
Definition
qqstylekitdelegatecontainer.cpp:19
QQStyleKitDelegateContainer::componentComplete
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
Definition
qqstylekitdelegatecontainer.cpp:210
QQStyleKitDelegateContainer::quickControl
QObject * quickControl() const
Definition
qqstylekitdelegatecontainer.cpp:51
QQStyleKitDelegateContainer::setQuickControl
void setQuickControl(QObject *control)
Definition
qqstylekitdelegatecontainer.cpp:56
QQStyleKitDelegateContainer::quickControlChanged
void quickControlChanged()
QQStyleKitDelegateContainer::delegateInstanceChanged
void delegateInstanceChanged()
QQStyleKitDelegateContainer::geometryChange
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
Definition
qqstylekitdelegatecontainer.cpp:276
QQStyleKitDelegateContainer::setDelegateStyle
void setDelegateStyle(QQStyleKitDelegateProperties *delegateProperties)
Definition
qqstylekitdelegatecontainer.cpp:33
QQStyleKitDelegateContainer::delegateInstance
QQuickItem * delegateInstance() const
Definition
qqstylekitdelegatecontainer.cpp:64
QQStyleKitDelegateProperties
Definition
qqstylekitcontrolproperties_p.h:237
QQStyleKitHandleProperties
Definition
qqstylekitcontrolproperties_p.h:405
QQStyleKitImageProperties
Definition
qqstylekitcontrolproperties_p.h:121
QQStyleKitIndicatorProperties
Definition
qqstylekitcontrolproperties_p.h:436
QQStyleKitIndicatorWithSubTypes
Definition
qqstylekitcontrolproperties_p.h:467
QQStyleKitPropertyGroup
Definition
qqstylekitcontrolproperties_p.h:41
QQStyleKitPropertyGroup::setStyleProperty
bool setStyleProperty(QQSK::Property property, T value)
Definition
qqstylekitcontrolproperties_p.h:70
QQStyleKitPropertyGroup::m_groupSpace
QQStyleKitPropertyGroupSpace m_groupSpace
Definition
qqstylekitcontrolproperties_p.h:110
QQStyleKitPropertyGroup::styleProperty
T styleProperty(QQSK::Property property, QQSK::Property alternative=QQSK::Property::NoProperty) const
Definition
qqstylekitcontrolproperties_p.h:55
QQStyleKitPropertyGroup::lazyCreateGroup
T * lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const
Definition
qqstylekitcontrolproperties.cpp:991
QQStyleKitPropertyGroup::forEachRelevantStyleReader
void forEachRelevantStyleReader(const QQStyleKitControl *control, const std::function< void(QQStyleKitReader *reader)> &f) const
Definition
qqstylekitcontrolproperties.cpp:1028
QQStyleKitPropertyGroup::handleStylePropertyChanged
void handleStylePropertyChanged(void(SUBCLASS::*changedSignal)())
Definition
qqstylekitcontrolproperties.cpp:1081
QQStyleKitPropertyGroup::forEachExistingNestedGroup
virtual void forEachExistingNestedGroup(const std::function< void(QQStyleKitPropertyGroup *)> &f) const
Definition
qqstylekitcontrolproperties.cpp:1182
QQStyleKitPropertyGroup::handleStylePropertiesChanged
void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals)
Definition
qqstylekitcontrolproperties.cpp:1086
QQStyleKitPropertyGroup::isDefined
bool isDefined(QQSK::Property property) const
Definition
qqstylekitcontrolproperties_p.h:76
QQStyleKitPropertyGroup::controlProperties
QQStyleKitControlProperties * controlProperties() const
Definition
qqstylekitcontrolproperties.cpp:979
QQStyleKitPropertyGroup::isControlProperties
bool isControlProperties() const
Definition
qqstylekitcontrolproperties_p.h:90
QQStyleKitPropertyPath
Definition
qqstylekitpropertypath_p.h:82
QQStyleKitPropertyPath::pathId
PropertyPathId pathId() const
Definition
qqstylekitpropertypath_p.h:104
QQStyleKitPropertyPath::storageIdToPathString
static QString storageIdToPathString(PropertyStorageId storageId)
Definition
qqstylekitpropertypath.cpp:89
QQStyleKitShadowProperties
Definition
qqstylekitcontrolproperties_p.h:180
QQStyleKitTextProperties
Definition
qqstylekitcontrolproperties_p.h:513
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
subtypeStorageSpaceSize
constexpr PropertyPathId subtypeStorageSpaceSize
Definition
qqstylekitpropertypath_p.h:75
stateStorageSpaceSize
constexpr PropertyPathId stateStorageSpaceSize
Definition
qqstylekitpropertypath_p.h:72
maxPropertyStorageSpaceSize
constexpr PropertyPathId maxPropertyStorageSpaceSize
Definition
qqstylekitpropertypath_p.h:69
nestedGroupCount
constexpr PropertyPathId nestedGroupCount
Definition
qqstylekitpropertypath_p.h:70
maxStateCombinationCount
constexpr PropertyPathId maxStateCombinationCount
Definition
qqstylekitpropertypath_p.h:71
nestedGroupsStartSize
constexpr PropertyPathId nestedGroupsStartSize
Definition
qqstylekitpropertypath_p.h:74
subtypeCount
constexpr PropertyPathId subtypeCount
Definition
qqstylekitpropertypath_p.h:73
QQStyleKitPropertyGroupSpace
Definition
qqstylekitpropertypath_p.h:77
QQStyleKitPropertyGroupSpace::start
PropertyPathId start
Definition
qqstylekitpropertypath_p.h:79
QQStyleKitPropertyGroupSpace::size
PropertyPathId size
Definition
qqstylekitpropertypath_p.h:78
qtdeclarative
src
labs
stylekit
qqstylekitpropertypath_p.h
Generated on
for Qt by
1.18.0