aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs/stylekit/qqstylekitpropertyresolver_p.h
blob: ad37b53877a0b30988e3c21139414d249421755d (plain)
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
// 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 QQSTYLEKITPROPERTYRESOLVER_P_H
#define QQSTYLEKITPROPERTYRESOLVER_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 "qqstylekitglobal_p.h"
#include "qqstylekitstorage_p.h"

QT_BEGIN_NAMESPACE

class QQStyleKitControl;
class QQStyleKitControls;
class QQStyleKitStyle;
class QQStyleKitReader;
class QQStyleKitPropertyGroup;

class QQStyleKitPropertyResolver
{
    Q_GADGET

public:
    enum class PathId {
        ExcludeSubType,
        IncludeSubType
    };
    Q_ENUM(PathId)

    struct PropertyPathIds {
        PropertyPathId property;
        PropertyPathId alternative;
        PropertyPathId subTypeProperty;
        PropertyPathId subTypeAlternative;
    };

    static QVariant readStyleProperty(
        const QQStyleKitPropertyGroup *group,
        const QQSK::Property property,
        const QQSK::Property alternative = QQSK::Property::NoProperty);

    static bool writeStyleProperty(
        const QQStyleKitPropertyGroup *group,
        const QQSK::Property property,
        const QVariant &value);

    static bool hasLocalStyleProperty(
        const QQStyleKitPropertyGroup *group,
        const QQSK::Property property);

private:
    static bool s_styleWarningsIssued;
    static bool s_isReadingProperty;
    static QQSK::State s_cachedState;
    static QVarLengthArray<QQSK::StateFlag, 10> s_cachedStateList;

private:
    template <class T>
    static QVariant readPropertyInStorageForState(
        const PropertyPathId main, const PropertyPathId alternative,
        const T *storageProvider, QQSK::State state);

    template <class INDICES_CONTAINER>
    static QVariant readPropertyInControlForStates(
        const PropertyPathId main, const PropertyPathId alternative,
        const QQStyleKitControl *control, INDICES_CONTAINER &stateListIndices,
        int startIndex, int recursionLevel);

    static QVariant readPropertyInControl(
        const PropertyPathIds &ids, const QQStyleKitControl *control);

    static QVariant readPropertyInRelevantControls(
        const QQStyleKitControls *controls, const PropertyPathIds &ids,
        const QQStyleKitExtendedControlType exactType,
        const QList<QQStyleKitExtendedControlType> baseTypes);

    static QVariant readPropertyInStyle(
        const PropertyPathIds &ids,
        const QQStyleKitExtendedControlType exactType,
        const QList<QQStyleKitExtendedControlType> baseTypes,
        const QQStyleKitStyle *style);

    static QVariant readProperty(
        const PropertyPathIds &ids,
        QQStyleKitReader *styleReader,
        QQStyleKitStyle *style);

    static PropertyPathId pathId(
        const QQStyleKitPropertyGroup *group,
        const QQSK::Property property, PathId flag);

    static const QList<QQStyleKitExtendedControlType> baseTypesForType(
        QQStyleKitExtendedControlType exactType);

    static void cacheReaderState(QQSK::State state);
    static void addInstanceVariationsToReader(
        QQStyleKitReader *styleReader,
        const QStringList &inAppVariationNames,
        const QVarLengthArray<const QQStyleKitControls *, 6> &stylesAndThemes);
    static void addTypeVariationsToReader(
        QQStyleKitReader *styleReader,
        const QQStyleKitExtendedControlType parentType,
        const QQStyleKitStyle *style);
    static void rebuildVariationsForReader(
        QQStyleKitReader *styleReader,
        const QQStyleKitStyle *style);
};

QT_END_NAMESPACE

#endif // QQSTYLEKITPROPERTYRESOLVER_P_H