aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs/stylekit/qqstylekitdebug_p.h
blob: 4d30da4251536d0d47995e3c347e90f636713ae4 (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
// 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 QQSTYLEKITDEBUG_P_H
#define QQSTYLEKITDEBUG_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 <QtQuick/qquickitem.h>

#include "qqstylekitcontrolproperties_p.h"
#include "qqstylekitstorage_p.h"

QT_BEGIN_NAMESPACE

class QQStyleKitDebug: public QObject
{
    Q_OBJECT
    Q_PROPERTY(QQuickItem *control READ control WRITE setControl NOTIFY controlChanged FINAL)
    Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged FINAL)
    QML_NAMED_ELEMENT(StyleKitDebug)

public:
    QQuickItem *control() const;
    void setControl(QQuickItem *item);

    QString filter() const;
    void setFilter(const QString &filter);

    Q_INVOKABLE static bool insideControl(const QObject *child);

signals:
    void controlChanged();
    void filterChanged();

private:
    static const QQStyleKitPropertyGroup *groupBeingRead;
    static QPointer<QQuickItem> m_item;
    static QString m_filter;
    static int m_outputCount;

private:
    static inline bool enabled() { return m_item != nullptr; }
    static void notifyPropertyNotResolved(const PropertyPathId property);
    static void notifyPropertyRead(
        const PropertyPathId property,
        const QQStyleKitControlProperties *resolvedControl,
        const QQSK::State state,
        const QVariant &value);
    static void notifyPropertyWrite(
        const QQStyleKitPropertyGroup *group,
        const QQSK::Property property,
        const QQStyleKitControlProperties *storage,
        const QQSK::State state,
        const PropertyStorageId key,
        const QVariant &value);
    static void trace(
        const PropertyPathId property,
        const QQStyleKitControlProperties *resolvedControl,
        const QQSK::State state,
        const PropertyStorageId key);

    template <typename EnumType>
    static QString enumToString(EnumType enumValue);
    static QString objectName(const QObject *obj);
    static QString stateToString(const QQSK::State state);
    static QString styleReaderToString(const QQStyleKitReader *reader);
    static QString controlToString(const QQStyleKitControlProperties *control);
    static QString objectPath(const QQStyleKitControlProperties *properties, QObject *from);
    static QString propertyPath(const QQStyleKitPropertyGroup *group, const PropertyPathId property);

    friend class QQStyleKitPropertyResolver;
};

QT_END_NAMESPACE

#endif // QQSTYLEKITDEBUG_P_H