diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/labs/stylekit/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrol_p.h | 4 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrolproperties.cpp | 164 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrolproperties_p.h | 65 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitcontrolstate.cpp | 4 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitdebug_p.h | 2 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitglobal.cpp | 64 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitglobal_p.h | 87 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitpropertyresolver.cpp | 139 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitpropertyresolver_p.h | 7 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitreader.cpp | 4 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitreader_p.h | 3 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitstorage.cpp | 21 | ||||
| -rw-r--r-- | src/labs/stylekit/qqstylekitstorage_p.h | 49 |
14 files changed, 299 insertions, 315 deletions
diff --git a/src/labs/stylekit/CMakeLists.txt b/src/labs/stylekit/CMakeLists.txt index 1bd7841de0..8d537a2e28 100644 --- a/src/labs/stylekit/CMakeLists.txt +++ b/src/labs/stylekit/CMakeLists.txt @@ -23,7 +23,6 @@ qt_internal_add_qml_module(QtQuickStyleKit qqstylekitfont_p.h qqstylekitfont.cpp qqstylekitpropertyresolver_p.h qqstylekitpropertyresolver.cpp qqstylekitreader_p.h qqstylekitreader.cpp - qqstylekitstorage_p.h qqstylekitstorage.cpp qqstylekitstyle_p.h qqstylekitstyle.cpp qqstylekittheme_p.h qqstylekittheme.cpp qqstylekitstyleandthemebase_p.h qqstylekitstyleandthemebase.cpp diff --git a/src/labs/stylekit/qqstylekitcontrol_p.h b/src/labs/stylekit/qqstylekitcontrol_p.h index 548b390c0f..0a66d806a7 100644 --- a/src/labs/stylekit/qqstylekitcontrol_p.h +++ b/src/labs/stylekit/qqstylekitcontrol_p.h @@ -17,8 +17,8 @@ // #include <QtQml/QtQml> +#include "qqstylekitglobal_p.h" #include "qqstylekitcontrolstate_p.h" -#include "qqstylekitstorage_p.h" #include "qqstylekitreader_p.h" QT_BEGIN_NAMESPACE @@ -49,7 +49,7 @@ private: QList<QQStyleKitVariation *> m_variations; mutable QQStyleKitPropertyStorage m_storage; - QQSK::State m_writtenStates = QQSK::StateFlag::NoState; + QQSK::State m_writtenStates = QQSK::StateFlag::Unspecified; friend class QQStyleKitPropertyResolver; friend class QQStyleKitControls; diff --git a/src/labs/stylekit/qqstylekitcontrolproperties.cpp b/src/labs/stylekit/qqstylekitcontrolproperties.cpp index 42aed5342a..1d884279c0 100644 --- a/src/labs/stylekit/qqstylekitcontrolproperties.cpp +++ b/src/labs/stylekit/qqstylekitcontrolproperties.cpp @@ -11,12 +11,74 @@ QT_BEGIN_NAMESPACE // ************* QQStyleKitPropertyGroup **************** -QQStyleKitPropertyGroup::QQStyleKitPropertyGroup(QQSK::PropertyGroup group, QObject *parent) +QQStyleKitPropertyGroup::QQStyleKitPropertyGroup(QQSK::PropertyGroup, QObject *parent) : QObject(parent) - , m_group(group) { } +PropertyPathId QQStyleKitPropertyGroup::propertyPathId(QQSK::Property property, PropertyPathId::Flag flag) const +{ + if (flag == PropertyPathId::Flag::IncludeSubtype) { + if (m_pathFlags.testFlag(QQSK::PropertyPathFlag::DelegateSubtype1)) + return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype1); + else if (m_pathFlags.testFlag(QQSK::PropertyPathFlag::DelegateSubtype2)) + return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype2); + } + return PropertyPathId(property, m_groupSpace.start, QQSK::PropertyGroup::DelegateSubtype0); +} + +QQStyleKitControlProperties *QQStyleKitPropertyGroup::controlProperties() const +{ + if (isControlProperties()) { + Q_ASSERT(qobject_cast<const QQStyleKitControlProperties *>(this)); + auto *self = const_cast<QQStyleKitPropertyGroup *>(this); + return static_cast<QQStyleKitControlProperties *>(self); + } + Q_ASSERT(qobject_cast<const QQStyleKitControlProperties *>(parent())); + return static_cast<QQStyleKitControlProperties *>(parent()); +} + +template<typename T> +T *QQStyleKitPropertyGroup::lazyCreateGroup(T * const &ptr, QQSK::PropertyGroup group) const +{ + T *nestedGroup = QQSK::lazyCreate(ptr, controlProperties(), group); + + // Nested groups inherit path flags from their parents + nestedGroup->m_pathFlags = m_pathFlags; + + if (group == QQSK::PropertyGroup::DelegateSubtype1) { + /* Subtypes, like states, are not part of a property's path ID—they belong to the + * storage ID instead. They are therefore prefixed later, during lookup, when + * propagation determines which value to read. + * For now, we simply record which subtype this group (and any nested groups) is + * associated with. The subtype will then be taken into account later when reading + * properties from the group. Setting aside space for the sub types was already + * taken care of during the construction of the root QQStyleKitControlProperties. */ + nestedGroup->m_pathFlags.setFlag(QQSK::PropertyPathFlag::DelegateSubtype1); + nestedGroup->m_groupSpace = m_groupSpace; + } else if (group == QQSK::PropertyGroup::DelegateSubtype2) { + nestedGroup->m_pathFlags.setFlag(QQSK::PropertyPathFlag::DelegateSubtype2); + nestedGroup->m_groupSpace = m_groupSpace; + } else { + /* Calculate the available property ID space for the nested group. This is done by + * dividing the available space inside _this_ group on the number of potential groups + * that _this_ group can potentially contain. */ + constexpr PropertyPathId_t groupCount = PropertyPathId_t(QQSK::PropertyGroup::PATH_ID_GROUP_COUNT); + const PropertyPathId_t nestedGroupIndex = PropertyPathId_t(group); + const PropertyPathId_t nestedGroupSize = m_groupSpace.size / groupCount; + nestedGroup->m_groupSpace.size = nestedGroupSize; + nestedGroup->m_groupSpace.start = m_groupSpace.start + (nestedGroupIndex * nestedGroupSize); + /* Ensure that we haven’t exhausted the available PropertyPathId space. There must be + * enough room remaining to assign IDs for all properties defined in QQSK::Property. + * If this assertion triggers, consider switching to a wider PropertyPathId_t type or + * optimizing how the space is allocated. For example, certain nested paths (such as + * control.handle.indicator) can never occur, yet we currently reserve INNER_GROUP_COUNT + * for every nesting level, which is wasteful. */ + Q_ASSERT(nestedGroupSize >= PropertyPathId_t(QQSK::Property::COUNT)); + } + return nestedGroup; +} + /* This macro will check if the caller has the same group path as \a GROUP_PATH. * This is needed since a QQSK::Property (e.g Color) can sometimes be a * property in several different subclasses of QQStyleKitPropertyGroup. @@ -57,8 +119,7 @@ void QQStyleKitPropertyGroup::handleStylePropertiesChanged(CHANGED_SIGNALS... ch "SUBCLASS must inherit QQStyleKitPropertyGroup"); auto *group = static_cast<SUBCLASS *>(this); - const QQStyleKitControlProperties *root = controlProperties(); - const QQSK::Subclass objectWrittenTo = root->subclass(); + const QQSK::Subclass objectWrittenTo = controlProperties()->subclass(); if (objectWrittenTo == QQSK::Subclass::QQStyleKitState) { ((group->*changedSignals)(), ...); @@ -80,53 +141,6 @@ void QQStyleKitPropertyGroup::handleStylePropertiesChanged(CHANGED_SIGNALS... ch Q_UNREACHABLE(); } -const QQStyleKitControlProperties *QQStyleKitPropertyGroup::controlProperties() const -{ - const QQStyleKitPropertyGroup *group = this; - while (!group->isControlProperties()) { - group = static_cast<QQStyleKitPropertyGroup *>(group->parent()); - Q_ASSERT(group); - } - return group->asControlProperties(); -} - -std::tuple< - const QQStyleKitControlProperties *, - const QQSK::PropertyGroup, - const QQSK::PathFlags> -QQStyleKitPropertyGroup::inspectGroupPath() const -{ - /* The path of a property can sometimes contain groups that are hints to the property - * resolver. E.g in the path 'QQStyleKitReader.global.handle.first.padding', 'global' - * hints that the property should be read directly from the style, circumventing the local - * cache that stores interpolated transition values. 'first' hints that the group is inside - * a sub type, which will affect how the style reader handles propagation. */ - QQSK::PathFlags pathFlags = QQSK::PathFlag::NoFlag; - QQSK::PropertyGroup subType = QQSK::PropertyGroup::NoGroup; - - const QQStyleKitPropertyGroup *group = this; - while (!group->isControlProperties()) { - if (group->m_group == QQSK::PropertyGroup::DelegateSubType1) - subType = QQSK::PropertyGroup::DelegateSubType1; - else if (group->m_group == QQSK::PropertyGroup::DelegateSubType2) - subType = QQSK::PropertyGroup::DelegateSubType2; - else if (group->m_group == QQSK::PropertyGroup::globalFlag) - pathFlags |= QQSK::PathFlag::StyleDirect; - - group = group->parentGroup(); - Q_ASSERT(group); - } - - const auto *controlProperties = group->asControlProperties(); - return std::make_tuple(controlProperties, subType, pathFlags); -} - -const QQStyleKitControlProperties *QQStyleKitPropertyGroup::asControlProperties() const -{ - Q_ASSERT(isControlProperties()); - return static_cast<const QQStyleKitControlProperties *>(this); -} - void QQStyleKitPropertyGroup::emitChangedForAllStylePropertiesRecursive() { /* This function will emit changed signals for all style properties in the @@ -162,14 +176,12 @@ void QQStyleKitPropertyGroup::emitChangedForAllStylePropertiesRecursive() bool QQStyleKitPropertyGroup::shouldEmitLocally() { - const QQStyleKitControlProperties *root = controlProperties(); - return !root->asQQStyleKitReader()->dontEmitChangedSignals(); + return !controlProperties()->asQQStyleKitReader()->dontEmitChangedSignals(); } bool QQStyleKitPropertyGroup::shouldEmitGlobally() { - const QQStyleKitControlProperties *root = controlProperties(); - QQStyleKitStyle *parentStyle = root->style(); + QQStyleKitStyle *parentStyle = controlProperties()->style(); if (!parentStyle) return false; @@ -188,7 +200,7 @@ bool QQStyleKitPropertyGroup::shouldEmitGlobally() // ************* QQStyleKitImageProperties **************** -QQStyleKitImageProperties::QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitImageProperties::QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitPropertyGroup(group, parent) { } @@ -239,7 +251,7 @@ void QQStyleKitImageProperties::setFillMode(QQuickImage::FillMode fillMode) // ************* QQStyleKitBorderProperties **************** -QQStyleKitBorderProperties::QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitBorderProperties::QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitPropertyGroup(group, parent) { } @@ -279,7 +291,7 @@ void QQStyleKitBorderProperties::setColor(const QColor &color) // ************* QQStyleKitShadowProperties **************** -QQStyleKitShadowProperties::QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitShadowProperties::QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitPropertyGroup(group, parent) { } @@ -385,7 +397,7 @@ void QQStyleKitShadowProperties::setDelegate(QQmlComponent *delegate) // ************* QQStyleKitDelegateProperties **************** -QQStyleKitDelegateProperties::QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitDelegateProperties::QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitPropertyGroup(group, parent) { } @@ -681,25 +693,25 @@ QQStyleKitImageProperties *QQStyleKitDelegateProperties::image() const // ************* QQStyleKitHandleProperties **************** -QQStyleKitHandleProperties::QQStyleKitHandleProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitHandleProperties::QQStyleKitHandleProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitDelegateProperties(group, parent) { } QQStyleKitDelegateProperties *QQStyleKitHandleProperties::first() const { - return lazyCreateGroup(m_first, QQSK::PropertyGroup::DelegateSubType1); + return lazyCreateGroup(m_first, QQSK::PropertyGroup::DelegateSubtype1); } QQStyleKitDelegateProperties *QQStyleKitHandleProperties::second() const { - return lazyCreateGroup(m_second, QQSK::PropertyGroup::DelegateSubType2); + return lazyCreateGroup(m_second, QQSK::PropertyGroup::DelegateSubtype2); } // ************* QQStyleKitIndicatorProperties **************** QQStyleKitIndicatorProperties::QQStyleKitIndicatorProperties( - QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) + QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitDelegateProperties(group, parent) { } @@ -721,7 +733,7 @@ QQStyleKitDelegateProperties *QQStyleKitIndicatorProperties::foreground() const // ************* QQStyleKitIndicatorWithSubTypes **************** QQStyleKitIndicatorWithSubTypes::QQStyleKitIndicatorWithSubTypes( - QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) + QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitDelegateProperties(group, parent) { } @@ -741,16 +753,16 @@ QQStyleKitDelegateProperties *QQStyleKitIndicatorWithSubTypes::foreground() cons QQStyleKitIndicatorProperties *QQStyleKitIndicatorWithSubTypes::up() const { - return lazyCreateGroup(m_up, QQSK::PropertyGroup::DelegateSubType1); + return lazyCreateGroup(m_up, QQSK::PropertyGroup::DelegateSubtype1); } QQStyleKitIndicatorProperties *QQStyleKitIndicatorWithSubTypes::down() const { - return lazyCreateGroup(m_down, QQSK::PropertyGroup::DelegateSubType2); + return lazyCreateGroup(m_down, QQSK::PropertyGroup::DelegateSubtype2); } // ************* QQStyleKitTextProperties **************** -QQStyleKitTextProperties::QQStyleKitTextProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent) +QQStyleKitTextProperties::QQStyleKitTextProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent) : QQStyleKitPropertyGroup(group, parent) { } @@ -822,6 +834,24 @@ void QQStyleKitTextProperties::setPointSize(qreal pointSize) QQStyleKitControlProperties::QQStyleKitControlProperties(QQSK::PropertyGroup group, QObject *parent) : QQStyleKitPropertyGroup(group, parent) { + /* Calculate the free space storage ID space that can accommodate all unique style + * properties that may be applied to a control. Since we'll prepend different states + * and subtypes during the property propagation lookup phase later, we need to reserve + * ID space for them both already now. More docs about the property space is written in + * the implementation of PropertyPathId. */ + m_groupSpace.size = nestedGroupsStartSize; + m_groupSpace.start = 0; + + if (group == QQSK::PropertyGroup::GlobalFlag) { + /* A property path may include pseudo-groups that offers a convenient API for + * reading properties with specific options applied. The 'global' group is one such + * pseudo-group. When it is prefixed to a property path, it indicates that the property + * should be read directly from the style, bypassing any active transitions that might + * otherwise affect its value. + * Note: The global group should be ignored when computing a PropertyPathId_t, as it + * only affect _where_ the property should be read from, not its ID. */ + m_pathFlags.setFlag(QQSK::PropertyPathFlag::Global); + } } QQStyleKitStyle *QQStyleKitControlProperties::style() const diff --git a/src/labs/stylekit/qqstylekitcontrolproperties_p.h b/src/labs/stylekit/qqstylekitcontrolproperties_p.h index 5a1cf28120..7e9f863823 100644 --- a/src/labs/stylekit/qqstylekitcontrolproperties_p.h +++ b/src/labs/stylekit/qqstylekitcontrolproperties_p.h @@ -44,14 +44,7 @@ class QQStyleKitPropertyGroup: public QObject public: QQStyleKitPropertyGroup(QQSK::PropertyGroup group, QObject *parent); - inline bool isControlProperties() const { return m_group == QQSK::PropertyGroup::Control; } - inline bool isPathFlag() const { return m_group == QQSK::PropertyGroup::globalFlag; } - inline bool isDelegateSubType() const { - return m_group == QQSK::PropertyGroup::DelegateSubType1 || - m_group == QQSK::PropertyGroup::DelegateSubType2; - } - - inline QQSK::PropertyGroup group() const { return m_group; } + PropertyPathId propertyPathId(QQSK::Property property, PropertyPathId::Flag flag) const; template<typename T> inline T styleProperty( @@ -75,6 +68,11 @@ public: return QQStyleKitPropertyResolver::writeStyleProperty(this, property, QVariant::fromValue(value)); } + inline bool isDefined(QQSK::Property property) const + { + return QQStyleKitPropertyResolver::readStyleProperty(this, property).isValid(); + } + template<typename SUBCLASS> inline void handleStylePropertyChanged(void (SUBCLASS::*changedSignal)()); @@ -82,38 +80,27 @@ public: inline void handleStylePropertiesChanged(CHANGED_SIGNALS... changedSignals); template <typename T> - inline T *lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const + T *lazyCreateGroup(T *const &ptr, QQSK::PropertyGroup group) const; + + inline bool isControlProperties() const { - return QQSK::lazyCreate(ptr, this, group); + /* Only QQStyleKitControlProperties (as opposed to the nested delegates) have properties + * with an ID at the bottom of the available space. The exception is the global flag, which + * inherits the groupSpace from the control. */ + return m_groupSpace.start == 0 && m_pathFlags != QQSK::PropertyPathFlag::Global; } + QQStyleKitControlProperties *controlProperties() const; + inline QQSK::PropertyPathFlags pathFlags() const { return m_pathFlags; } void emitChangedForAllStylePropertiesRecursive(); - const QQStyleKitControlProperties *controlProperties() const; - - std::tuple< - const QQStyleKitControlProperties *, - const QQSK::PropertyGroup, - const QQSK::PathFlags> inspectGroupPath() const; - - inline QQStyleKitPropertyGroup *parentGroup() const { - Q_ASSERT(!parent() || qobject_cast<QQStyleKitPropertyGroup *>(parent())); - return static_cast<QQStyleKitPropertyGroup *>(parent()); - } - - const QQStyleKitControlProperties *asControlProperties() const; - - inline bool isDefined(QQSK::Property property) const - { - return QQStyleKitPropertyResolver::readStyleProperty(this, property).isValid(); - } +protected: + QQStyleKitPropertyGroupSpace m_groupSpace; + QQSK::PropertyPathFlags m_pathFlags = QQSK::PropertyPathFlag::NoFlags; private: bool shouldEmitLocally(); bool shouldEmitGlobally(); - -private: - QQSK::PropertyGroup m_group; }; // ************* QQStyleKitImageProperties **************** @@ -128,7 +115,7 @@ class QQStyleKitImageProperties : public QQStyleKitPropertyGroup QML_NAMED_ELEMENT(StyleKitImageProperties) public: - QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitImageProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -159,7 +146,7 @@ class QQStyleKitBorderProperties : public QQStyleKitPropertyGroup QML_NAMED_ELEMENT(StyleKitBorderProperties) public: - QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitBorderProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -192,7 +179,7 @@ class QQStyleKitShadowProperties : public QQStyleKitPropertyGroup QML_NAMED_ELEMENT(StyleKitShadowProperties) public: - QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitShadowProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -267,7 +254,7 @@ class QQStyleKitDelegateProperties : public QQStyleKitPropertyGroup QML_NAMED_ELEMENT(StyleKitDelegateProperties) public: - QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitDelegateProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -392,7 +379,7 @@ class QQStyleKitHandleProperties : public QQStyleKitDelegateProperties QML_NAMED_ELEMENT(StyleKitHandleProperties) public: - QQStyleKitHandleProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitHandleProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); QQStyleKitDelegateProperties *first() const; QQStyleKitDelegateProperties *second() const; @@ -418,7 +405,7 @@ class QQStyleKitIndicatorProperties : public QQStyleKitDelegateProperties QML_NAMED_ELEMENT(StyleKitIndicatorProperties) public: - QQStyleKitIndicatorProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitIndicatorProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -447,7 +434,7 @@ class QQStyleKitIndicatorWithSubTypes : public QQStyleKitDelegateProperties QML_NAMED_ELEMENT(StyleKitIndicatorPropertiesWithSubTypes) public: - QQStyleKitIndicatorWithSubTypes(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitIndicatorWithSubTypes(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; @@ -485,7 +472,7 @@ class QQStyleKitTextProperties : public QQStyleKitPropertyGroup QML_NAMED_ELEMENT(StyleKitTextProperties) public: - QQStyleKitTextProperties(QQSK::PropertyGroup group, QQStyleKitPropertyGroup *parent = nullptr); + QQStyleKitTextProperties(QQSK::PropertyGroup group, QQStyleKitControlProperties *parent = nullptr); template <typename... CHANGED_SIGNALS> void emitGlobally(CHANGED_SIGNALS... changedSignals) const; diff --git a/src/labs/stylekit/qqstylekitcontrolstate.cpp b/src/labs/stylekit/qqstylekitcontrolstate.cpp index f31ec969b4..41d81fdccf 100644 --- a/src/labs/stylekit/qqstylekitcontrolstate.cpp +++ b/src/labs/stylekit/qqstylekitcontrolstate.cpp @@ -37,7 +37,7 @@ QQStyleKitControlState::controlAndState() * states determines the state of the control that the properties * inside this QQStyleKitControlState should apply for. */ QQStyleKitControl *control = nullptr; - QQSK::State nestedState = QQSK::StateFlag::NoState; + QQSK::State nestedState = QQSK::StateFlag::Unspecified; const QQStyleKitControlState *obj = this; if (metaObject()->inherits(&QQStyleKitControl::staticMetaObject)) @@ -77,7 +77,7 @@ QQStyleKitControlState::controlAndState() nestedState.setFlag(QQSK::StateFlag::Highlighted, false); } - if (nestedState == QQSK::StateFlag::NoState) + if (nestedState == QQSK::StateFlag::Unspecified) nestedState = QQSK::StateFlag::Normal; Q_ASSERT(control); diff --git a/src/labs/stylekit/qqstylekitdebug_p.h b/src/labs/stylekit/qqstylekitdebug_p.h index 4d30da4251..d428e88fab 100644 --- a/src/labs/stylekit/qqstylekitdebug_p.h +++ b/src/labs/stylekit/qqstylekitdebug_p.h @@ -18,8 +18,8 @@ #include <QtQuick/qquickitem.h> +#include "qqstylekitglobal_p.h" #include "qqstylekitcontrolproperties_p.h" -#include "qqstylekitstorage_p.h" QT_BEGIN_NAMESPACE diff --git a/src/labs/stylekit/qqstylekitglobal.cpp b/src/labs/stylekit/qqstylekitglobal.cpp index 481afa3cc6..81b7cbb99c 100644 --- a/src/labs/stylekit/qqstylekitglobal.cpp +++ b/src/labs/stylekit/qqstylekitglobal.cpp @@ -5,6 +5,70 @@ QT_BEGIN_NAMESPACE +PropertyPathId::PropertyPathId( + const QQSK::Property property, + const PropertyPathId_t groupStart, + QQSK::PropertyGroup subtype) + : m_property(property) +{ + /* Each style property in StyleKit needs a unique PropertyStorageId that can be used as + * a key in the map that stores its value. To compute such an ID, we must consider the + * property’s full nested path, since properties like 'background.color' and + * 'background.border.color' refer to different values. + * + * Because a property may have multiple values depending on the control’s state and + * subtype, we distinguish between a property’s path ID and its storage ID. The path + * ID represents the portion of the property path that does not vary during lookups. + * For example, in the full path: + * + * "button.pressed.indicator.up.background.color" + * + * the portion that is invariant is: + * + * "indicator.background.color" + * + * The other parts of the path—such as the control type ('button'), the state ('pressed'), + * and the subtype ('up')—are resolved dynamically by the propagation engine. During lookup, + * the engine substitutes these components in decreasing order of specificity. For instance: + * + * - If the property is not found on 'button', it falls back to 'abstractButton'. + * - If it is not found in the 'pressed' state, it falls back to 'normal'. + * - If it is not found in the 'up' subtype, it falls back to 'indicator'. + * + * These varying components are prepended in sequence by the propagation engine to form + * the final PropertyStorageId, which uniquely identifies the stored value in the map. + * + * Note that a property path may also include groups known as Options. These are not part + * of the Path ID or the Storage ID; they are simply flags used by QQStyleKitPropertyResolver + * to control how a property should be read. + * + * In general, the structure of a property path is: + * + * control.options.states.subtype.nested_group_path.property + * + * However, for API convenience, subtypes are written inside the delegate they belong to. + * For example, although the storage path is "spinBox.up.indicator.background.color", the + * style syntax is "spinBox.indicator.up.background.color". */ + const PropertyPathId_t subtypeIndex = PropertyPathId_t(subtype) + - PropertyPathId_t(QQSK::PropertyGroup::DelegateSubtype0); + const PropertyPathId_t subtypeStart = subtypeIndex * subtypeStorageSpaceSize; + m_groupStart = subtypeStart + groupStart; +} + +PropertyStorageId PropertyPathId::storageId(QQSK::State state) const +{ + /* To compute the fully qualified property ID used as a key in a storage map + * (QMap) that holds its value, we need to prefix the property’s state, since + * the same property can have different values in different states. + * Because StateFlag::Normal == 1, we subtract 1 so that the address space for + * properties in the Normal state starts at 0. */ + Q_ASSERT(state != QQSK::StateFlag::Unspecified); + const PropertyPathId_t stateIndex = PropertyPathId_t(state) - 1; + const PropertyPathId_t propertyIndex = PropertyPathId_t(m_property); + const PropertyPathId_t stateStart = stateIndex * stateStorageSpaceSize; + return stateStart + m_groupStart + propertyIndex; +} + QT_END_NAMESPACE #include "moc_qqstylekitglobal_p.cpp" diff --git a/src/labs/stylekit/qqstylekitglobal_p.h b/src/labs/stylekit/qqstylekitglobal_p.h index 165a8c403f..6aa0422dc0 100644 --- a/src/labs/stylekit/qqstylekitglobal_p.h +++ b/src/labs/stylekit/qqstylekitglobal_p.h @@ -20,8 +20,6 @@ QT_BEGIN_NAMESPACE -using QQStyleKitExtendedControlType = uint; - class QQSK: public QObject { Q_OBJECT @@ -45,23 +43,43 @@ public: Q_FLAG(Delegate) enum class PropertyGroup { - NoGroup, Control, Background, + Foreground, Border, - DelegateSubType1, - DelegateSubType2, Handle, - Foreground, Image, Indicator, Shadow, - globalFlag, Text, - COUNT + PATH_ID_GROUP_COUNT, + + /* Sub types, like states, are a part of a propertys storage ID, not its Path ID. + * They appear in the group path, but are handled differently. */ + DelegateSubtype0, + DelegateSubtype1, + DelegateSubtype2, + + /* Read options are not a part of either the Path ID nor the Storage ID. They + * just offer a convenient API for providing read options when reading a property. + * The Global flag is used to signal that a property should be read directly from + * the global style, circumventing the local StyleKitReader cache. */ + GlobalFlag, + + Unspecified }; Q_ENUM(PropertyGroup) + enum class PropertyPathFlag : quint8 { + NoFlags = 0x0, + DelegateSubtype0 = 0x1, + DelegateSubtype1 = 0x2, + DelegateSubtype2 = 0x4, + Global = 0x8 + }; + Q_DECLARE_FLAGS(PropertyPathFlags, PropertyPathFlag) + Q_FLAG(PropertyPathFlag) + enum class Property { NoProperty, BottomLeftRadius, @@ -110,7 +128,7 @@ public: Q_ENUM(Property) enum class StateFlag { - NoState = 0x000, + Unspecified = 0x000, Normal = 0x001, Pressed = 0x002, Hovered = 0x004, @@ -130,13 +148,6 @@ public: }; Q_ENUM(Subclass) - enum class PathFlag { - NoFlag = 0x00, - StyleDirect = 0x01 - }; - Q_DECLARE_FLAGS(PathFlags, PathFlag) - Q_FLAG(PathFlag) - public: template <typename T, typename Owner, typename... Args> static inline T *lazyCreate(T *const &ptr, const Owner *self, Args&&... args) @@ -152,7 +163,49 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::Delegates) -Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::PathFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(QQSK::PropertyPathFlags) + +using PropertyPathId_t = quint32; +using PropertyStorageId = quint32; +using QQStyleKitExtendedControlType = quint32; +using QQStyleKitPropertyStorage = QMap<PropertyStorageId, QVariant>; + +constexpr PropertyPathId_t maxPropertyStorageSpaceSize = std::numeric_limits<PropertyPathId_t>::max(); +constexpr PropertyPathId_t maxStateCombinationCount = PropertyPathId_t(QQSK::StateFlag::MAX_STATE); +constexpr PropertyPathId_t stateStorageSpaceSize = maxPropertyStorageSpaceSize / maxStateCombinationCount; +constexpr PropertyPathId_t subtypeCount = PropertyPathId_t(QQSK::PropertyPathFlag::DelegateSubtype2) - PropertyPathId_t(QQSK::PropertyPathFlag::DelegateSubtype0) + 1; +constexpr PropertyPathId_t nestedGroupsStartSize = maxPropertyStorageSpaceSize / (maxStateCombinationCount * subtypeCount); +constexpr PropertyPathId_t subtypeStorageSpaceSize = maxPropertyStorageSpaceSize / (subtypeCount * maxStateCombinationCount); + +struct QQStyleKitPropertyGroupSpace { + PropertyPathId_t size = 0; + PropertyPathId_t start = 0; +}; + +class PropertyPathId { + Q_GADGET + +public: + enum class Flag { + ExcludeSubtype, + IncludeSubtype + }; + Q_ENUM(Flag) + + PropertyPathId( + const QQSK::Property property = QQSK::Property::NoProperty, + const PropertyPathId_t groupStart = PropertyPathId_t(0), + QQSK::PropertyGroup subtype = QQSK::PropertyGroup::DelegateSubtype0); + + PropertyPathId subTypePrepended(QQSK::PropertyGroup subtype) const; + + QQSK::Property property() const { return m_property; } + PropertyStorageId storageId(QQSK::State state) const; + +private: + QQSK::Property m_property; + PropertyPathId_t m_groupStart; +}; QT_END_NAMESPACE diff --git a/src/labs/stylekit/qqstylekitpropertyresolver.cpp b/src/labs/stylekit/qqstylekitpropertyresolver.cpp index b995c5496a..b823ba7e97 100644 --- a/src/labs/stylekit/qqstylekitpropertyresolver.cpp +++ b/src/labs/stylekit/qqstylekitpropertyresolver.cpp @@ -16,85 +16,9 @@ QT_BEGIN_NAMESPACE bool QQStyleKitPropertyResolver::s_styleWarningsIssued = false; bool QQStyleKitPropertyResolver::s_isReadingProperty = false; -QQSK::State QQStyleKitPropertyResolver::s_cachedState = QQSK::StateFlag::NoState; +QQSK::State QQStyleKitPropertyResolver::s_cachedState = QQSK::StateFlag::Unspecified; QVarLengthArray<QQSK::StateFlag, 10> QQStyleKitPropertyResolver::s_cachedStateList; -PropertyPathId QQStyleKitPropertyResolver::pathId( - const QQStyleKitPropertyGroup *group, const QQSK::Property property, PathId flag) -{ - /* Follow the parent chain of the property up to the QQStyleKitControlProperties - * group it's inside. This group path, together with the enum value of the property, - * will form its unique PropertyPathId. - * E.g the property 'color' will get a different path ID when it's a part of - * 'background.color' compared to 'background.border.color'. - * This path ID will later be used together with different state combinations to - * form different PropertyStorageId's. A storage ID is used as the key into QMaps - * that stores property values for each state in each QQStyleKitControl. */ - if (property == QQSK::Property::NoProperty) - return PropertyPathId(); - - const int propertyCount = int(QQSK::Property::COUNT); - const int groupCount = int(QQSK::PropertyGroup::COUNT); - - /* Deliberatly use extra wide types for calculations, in order - * to do rough overflow checks in the end. */ - quint64 id = qint64(property); - quint64 idSpaceForPreviousLevel = propertyCount; - - const QQStyleKitPropertyGroup *groupParent = group; - - if (flag == PathId::ExcludeSubType && groupParent->isDelegateSubType()) - groupParent = static_cast<QQStyleKitPropertyGroup *>(groupParent->parent()); - - if (groupParent->isPathFlag()) { - /* property 'global' is not a real group, it's just a hint to the property - * resolver that it should read style properties directly from the style, igoring - * any ongoing transition inside the reader. So just skip it. */ - groupParent = static_cast<QQStyleKitPropertyGroup *>(groupParent->parent()); - } - - while (!groupParent->isControlProperties()) { - // Add 1 to the group number since group 0 (with start ID == 0) is - // reserved for properties that are not nested in a group (e.g control.implicitWidth). - const int groupNumber = int(groupParent->group()) + 1; - const quint64 idSpaceForCurrentGroup = groupNumber * idSpaceForPreviousLevel; - - id += idSpaceForCurrentGroup; - - /* Every time we move up one group level, all the possible property paths - * in the previous level can theoretically occur inside each group on this - * level. So we need to multiply this space with group count. */ - idSpaceForPreviousLevel *= groupCount; - - groupParent = static_cast<QQStyleKitPropertyGroup *>(groupParent->parent()); - if (flag == PathId::ExcludeSubType && groupParent->isDelegateSubType()) { - groupParent = static_cast<QQStyleKitPropertyGroup *>(groupParent->parent()); - Q_ASSERT(groupParent); - } - Q_ASSERT(groupParent); - if (groupParent->isPathFlag()) { - groupParent = static_cast<QQStyleKitPropertyGroup *>(groupParent->parent()); - Q_ASSERT(groupParent); - } - } - - const PropertyPathId pathId(property, id, idSpaceForPreviousLevel); - -#ifdef QT_DEBUG - // Check that the id calculation didn't overflow - Q_ASSERT_X(pathId.pathId() == id, - __FUNCTION__, QQStyleKitDebug::propertyPath(group, property).toUtf8().constData()); - - /* Also check in advance that the path ID can be used in combination with - * any possible state combination later on to form a storage ID. */ - const QQSK::StateFlag maxNestedState = QQSK::StateFlag::MAX_STATE; - Q_ASSERT_X(id < pathId.storageId(maxNestedState), - __FUNCTION__, QQStyleKitDebug::propertyPath(group, property).toUtf8().constData()); -#endif - - return pathId; -} - const QList<QQStyleKitExtendedControlType> QQStyleKitPropertyResolver::baseTypesForType( QQStyleKitExtendedControlType exactType) { @@ -139,6 +63,7 @@ const QList<QQStyleKitExtendedControlType> QQStyleKitPropertyResolver::baseTypes void QQStyleKitPropertyResolver::cacheReaderState(QQSK::State state) { + Q_ASSERT(state != QQSK::StateFlag::Unspecified); if (state == s_cachedState) return; @@ -174,10 +99,10 @@ void QQStyleKitPropertyResolver::addTypeVariationsToReader( static PropertyPathIds ids; if (ids.property.property() == QQSK::Property::NoProperty) { /* ids is made static, since the 'variations' path will be the same for all - * StyleKitControls. Also, since sub types are only possible for delegates, - * and 'variations' is a control property, we can exclude sub types. */ - ids.property = pathId(styleReader, QQSK::Property::Variations, PathId::ExcludeSubType); - ids.alternative = pathId(styleReader, QQSK::Property::NoProperty, PathId::ExcludeSubType); + * StyleKitControls. Also, since subtypes are only possible for delegates, + * and 'variations' is a control property, we can exclude subtypes. */ + ids.property = styleReader->propertyPathId(QQSK::Property::Variations, PropertyPathId::Flag::ExcludeSubtype); + ids.alternative = styleReader->propertyPathId(QQSK::Property::NoProperty, PropertyPathId::Flag::ExcludeSubtype); ids.subTypeProperty = PropertyPathId(); ids.subTypeAlternative = PropertyPathId(); } @@ -242,7 +167,7 @@ void QQStyleKitPropertyResolver::addInstanceVariationsToReader( continue; /* Invariant: we found a variation in a Style or a Theme with a name that matches * a name in the attached variation list. Check if the found variation contains the - * type, or the sub types, of the style reader. If not, it doesn't affect it and can + * type, or the subtypes, of the style reader. If not, it doesn't affect it and can * therefore be skipped. */ if (variationInStyleOrTheme->getControl(styleReaderType)) { styleReader->m_effectiveInAppVariations.append(variationInStyleOrTheme); @@ -384,7 +309,7 @@ QVariant QQStyleKitPropertyResolver::readPropertyInControlForStates( } // Check the current combination - QQSK::State storageState = QQSK::StateFlag::NoState; + QQSK::State storageState = QQSK::StateFlag::Unspecified; for (int j = 0; j <= recursionLevel; ++j) storageState.setFlag(s_cachedStateList[stateListIndices[j]]); const QVariant value = readPropertyInStorageForState(main, alternative, control, storageState); @@ -401,12 +326,12 @@ QVariant QQStyleKitPropertyResolver::readPropertyInControl( /* Find the most specific state combination (based on the state of the reader) that * has a value set for the property in the contol. In case several state combinations * could be found, the order of the states in the stateList decides the priority. - * If we're reading a property in a sub type, try all state combinations in the sub - * type first, before trying all the state combinations in the super type. */ + * If we're reading a property in a subtype, try all state combinations in the subtype + * first, before trying all the state combinations in the super type. */ QVarLengthArray<int, 10> stateListIndices(s_cachedStateList.length()); if (ids.subTypeProperty.property() != QQSK::Property::NoProperty) { - if (s_cachedState != QQSK::StateFlag::NoState) { + if (s_cachedState != QQSK::StateFlag::Normal) { QVariant value = readPropertyInControlForStates( ids.subTypeProperty, ids.subTypeAlternative, control, stateListIndices, 0, 0); if (value.isValid()) @@ -421,7 +346,7 @@ QVariant QQStyleKitPropertyResolver::readPropertyInControl( } } - if (s_cachedState != QQSK::StateFlag::NoState) { + if (s_cachedState != QQSK::StateFlag::Normal) { const QVariant value = readPropertyInControlForStates( ids.property, ids.alternative, control, stateListIndices, 0, 0); if (value.isValid()) @@ -553,7 +478,8 @@ QVariant QQStyleKitPropertyResolver::readStyleProperty( const QQSK::Property property, const QQSK::Property alternative) { - auto [controlProperties, subType, pathFlags] = group->inspectGroupPath(); + const QQStyleKitControlProperties *controlProperties = group->controlProperties(); + const QQSK::PropertyPathFlags pathFlags = group->pathFlags(); const QQSK::Subclass subclass = controlProperties->subclass(); if (subclass == QQSK::Subclass::QQStyleKitState) { @@ -566,7 +492,7 @@ QVariant QQStyleKitPropertyResolver::readStyleProperty( * static (as in non-propagating) bindings between the properties in a Style, * we fall back to simply return the value specified in the accessed control. */ const auto [control, nestedState] = controlProperties->asQQStyleKitState()->controlAndState(); - const PropertyPathId propertyPathId = pathId(group, property, PathId::IncludeSubType); + const PropertyPathId propertyPathId = group->propertyPathId(property, PropertyPathId::Flag::IncludeSubtype); const PropertyStorageId key = propertyPathId.storageId(nestedState); return control->readStyleProperty(key); } @@ -600,24 +526,26 @@ QVariant QQStyleKitPropertyResolver::readStyleProperty( QScopedValueRollback rollback(s_isReadingProperty, true); PropertyPathIds ids; - ids.property = pathId(group, property, PathId::ExcludeSubType); - ids.alternative = pathId(group, alternative, PathId::ExcludeSubType); - - if (subType != QQSK::PropertyGroup::NoGroup) { - ids.subTypeProperty = pathId(group, property, PathId::IncludeSubType); - ids.subTypeAlternative = pathId(group, alternative, PathId::IncludeSubType); + ids.property = group->propertyPathId(property, PropertyPathId::Flag::ExcludeSubtype); + ids.alternative = group->propertyPathId(alternative, PropertyPathId::Flag::ExcludeSubtype); + const bool insideSubType = pathFlags & + (QQSK::PropertyPathFlag::DelegateSubtype1 | QQSK::PropertyPathFlag::DelegateSubtype2); + + if (insideSubType) { + ids.subTypeProperty = group->propertyPathId(property, PropertyPathId::Flag::IncludeSubtype); + ids.subTypeAlternative = group->propertyPathId(alternative, PropertyPathId::Flag::IncludeSubtype); } else { ids.subTypeProperty = PropertyPathId(); ids.subTypeAlternative = PropertyPathId(); } - if (!pathFlags.testFlag(QQSK::PathFlag::StyleDirect)) { + if (!pathFlags.testFlag(QQSK::PropertyPathFlag::Global)) { /* A style reader can have a storage that contains local property overrides (that is, * interpolated values from an ongoing transition). When searching for a property, we * therefore need to check this storage first. The exception is if the property was read * inside the 'global' group, which means that we should read the values directly * from the style. */ - if (subType != QQSK::PropertyGroup::NoGroup) { + if (insideSubType) { const QVariant value = readPropertyInStorageForState( ids.subTypeProperty, ids.subTypeAlternative, styleReader, QQSK::StateFlag::Normal); if (value.isValid()) @@ -647,13 +575,12 @@ bool QQStyleKitPropertyResolver::writeStyleProperty( // While readStyleProperty() takes propagation into account, writeStyleProperty() doesn't. // Instead it writes \a value directly to the storage that the group belongs to. Q_ASSERT(group); - auto [controlProperties, subType, pathFlags] = group->inspectGroupPath(); + const QQStyleKitControlProperties *controlProperties = group->controlProperties(); + const QQSK::PropertyPathFlags pathFlags = group->pathFlags(); const QQSK::Subclass subclass = controlProperties->subclass(); - const PropertyPathId propertyPathId = pathId(group, property, PathId::IncludeSubType); - // The subType is only used when reading a property using propagation - Q_UNUSED(subType); + const PropertyPathId propertyPathId = group->propertyPathId(property, PropertyPathId::Flag::IncludeSubtype); - if (pathFlags.testFlag(QQSK::PathFlag::StyleDirect)) { + if (pathFlags.testFlag(QQSK::PropertyPathFlag::Global)) { qmlWarning(controlProperties) << "Properties inside 'global' are read-only!"; return false; } @@ -694,12 +621,12 @@ bool QQStyleKitPropertyResolver::hasLocalStyleProperty( const QQSK::Property property) { Q_ASSERT(group); - auto [controlProperties, subType, pathFlags] = group->inspectGroupPath(); + const QQStyleKitControlProperties *controlProperties = group->controlProperties(); + const QQSK::PropertyPathFlags pathFlags = group->pathFlags(); + const PropertyPathId propertyPathId = group->propertyPathId(property, PropertyPathId::Flag::IncludeSubtype); const QQSK::Subclass subclass = controlProperties->subclass(); - const PropertyPathId propertyPathId = pathId(group, property, PathId::IncludeSubType); - Q_UNUSED(subType); - if (pathFlags.testFlag(QQSK::PathFlag::StyleDirect)) + if (pathFlags.testFlag(QQSK::PropertyPathFlag::Global)) return false; if (subclass == QQSK::Subclass::QQStyleKitReader) { diff --git a/src/labs/stylekit/qqstylekitpropertyresolver_p.h b/src/labs/stylekit/qqstylekitpropertyresolver_p.h index ad37b53877..b46c0c1403 100644 --- a/src/labs/stylekit/qqstylekitpropertyresolver_p.h +++ b/src/labs/stylekit/qqstylekitpropertyresolver_p.h @@ -19,7 +19,6 @@ #include <QtQml/QtQml> #include "qqstylekitglobal_p.h" -#include "qqstylekitstorage_p.h" QT_BEGIN_NAMESPACE @@ -34,7 +33,7 @@ class QQStyleKitPropertyResolver Q_GADGET public: - enum class PathId { + enum class PathId { // REMOVE THIS AS WELL ExcludeSubType, IncludeSubType }; @@ -98,10 +97,6 @@ private: QQStyleKitReader *styleReader, QQStyleKitStyle *style); - static PropertyPathId pathId( - const QQStyleKitPropertyGroup *group, - const QQSK::Property property, PathId flag); - static const QList<QQStyleKitExtendedControlType> baseTypesForType( QQStyleKitExtendedControlType exactType); diff --git a/src/labs/stylekit/qqstylekitreader.cpp b/src/labs/stylekit/qqstylekitreader.cpp index 690e9f96dd..2b871f2848 100644 --- a/src/labs/stylekit/qqstylekitreader.cpp +++ b/src/labs/stylekit/qqstylekitreader.cpp @@ -41,7 +41,7 @@ QQStyleKitReader::QQStyleKitReader(QObject *parent) : QQStyleKitControlProperties(QQSK::PropertyGroup::Control, parent) , m_dontEmitChangedSignals(false) , m_effectiveVariationsDirty(true) - , m_global(QQStyleKitControlProperties(QQSK::PropertyGroup::globalFlag, this)) + , m_global(QQStyleKitControlProperties(QQSK::PropertyGroup::GlobalFlag, this)) { s_allReaders.append(this); } @@ -334,7 +334,7 @@ QQSK::State QQStyleKitReader::controlState() const QQSK::StateFlag::Hovered); } - if (effectiveState == QQSK::StateFlag::NoState) + if (effectiveState == QQSK::StateFlag::Unspecified) effectiveState.setFlag(QQSK::StateFlag::Normal); return effectiveState; diff --git a/src/labs/stylekit/qqstylekitreader_p.h b/src/labs/stylekit/qqstylekitreader_p.h index be9f195bd2..10b688e814 100644 --- a/src/labs/stylekit/qqstylekitreader_p.h +++ b/src/labs/stylekit/qqstylekitreader_p.h @@ -22,7 +22,6 @@ #include "qqstylekitglobal_p.h" #include "qqstylekitcontrolproperties_p.h" #include "qqstylekitfont_p.h" -#include "qqstylekitstorage_p.h" QT_BEGIN_NAMESPACE @@ -176,7 +175,7 @@ private: QFont m_font; mutable QQStyleKitPropertyStorage m_storage; AlternateState m_alternateState = AlternateState::Alternate1; - QQSK::State m_state = QQSK::StateFlag::NoState; + QQSK::State m_state = QQSK::StateFlag::Unspecified; QQuickStateGroup *m_stateGroup = nullptr; QQSK::Delegates m_trackedDelegates = QQSK::Delegate::NoDelegate; diff --git a/src/labs/stylekit/qqstylekitstorage.cpp b/src/labs/stylekit/qqstylekitstorage.cpp deleted file mode 100644 index 6a62910573..0000000000 --- a/src/labs/stylekit/qqstylekitstorage.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// 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 - -#include "qqstylekitstorage_p.h" - -QT_BEGIN_NAMESPACE - -PropertyPathId::PropertyPathId( - const QQSK::Property property, PropertyPathId_t id, uint numberOfPropertiesInGroup) - : m_property(property), m_id(id), m_numberOfPropertiesInGroup(numberOfPropertiesInGroup) -{ -} - -PropertyStorageId PropertyPathId::storageId(QQSK::State state) const -{ - return m_id + (m_numberOfPropertiesInGroup * state); -} - -QT_END_NAMESPACE - -#include "moc_qqstylekitstorage_p.cpp" diff --git a/src/labs/stylekit/qqstylekitstorage_p.h b/src/labs/stylekit/qqstylekitstorage_p.h deleted file mode 100644 index 9b49f2446c..0000000000 --- a/src/labs/stylekit/qqstylekitstorage_p.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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 QQSTYLEKITSTORAGE_P_H -#define QQSTYLEKITSTORAGE_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 <QtCore/QtCore> - -#include "qqstylekitglobal_p.h" - -QT_BEGIN_NAMESPACE - -using PropertyPathId_t = uint; -using PropertyStorageId = uint; -using QQStyleKitPropertyStorage = QMap<PropertyStorageId, QVariant>; - -class PropertyPathId { - Q_GADGET - -public: - PropertyPathId( - const QQSK::Property property = QQSK::Property::NoProperty, - PropertyPathId_t id = 0, uint numberOfPropertiesInGroup = 0); - - QQSK::Property property() const { return m_property; } - PropertyPathId_t pathId() const { return m_id; } - PropertyStorageId storageId(QQSK::State state) const; - -private: - QQSK::Property m_property; - PropertyPathId_t m_id; - uint m_numberOfPropertiesInGroup; -}; - -QT_END_NAMESPACE - -#endif // QQSTYLEKITSTORAGE_P_H |
