aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs/stylekit/qqstylekit_p.h
blob: bd8263f767cc91b8cf8027cb6a9d933d6477c4ea (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
// 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 QQSTYLEKIT_P_H
#define QQSTYLEKIT_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 "qqstylekitdebug_p.h"

#include <QtQml/QtQml>

QT_BEGIN_NAMESPACE

class QQStyleKitAttached;

class QQStyleKit : public QObject
{
    Q_OBJECT
    QML_NAMED_ELEMENT(StyleKit)
    QML_ATTACHED(QQStyleKitAttached)

public:
    QQStyleKit(QObject *parent = nullptr);
    static QQStyleKitAttached *qmlAttachedProperties(QObject *obj = nullptr);

private:
    Q_DISABLE_COPY(QQStyleKit)
};

class QQStyleKitAttached : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QQStyleKitStyle *style READ style WRITE setStyle NOTIFY styleChanged FINAL)
    Q_PROPERTY(QString styleUrl READ styleUrl WRITE setStyleUrl NOTIFY styleUrlChanged FINAL)
    Q_PROPERTY(bool transitionsEnabled READ transitionsEnabled WRITE setTransitionsEnabled NOTIFY transitionsEnabledChanged FINAL)
    Q_PROPERTY(QQStyleKitDebug *debug READ debug FINAL)

public:
    QQStyleKitAttached(QObject *parent);
    ~QQStyleKitAttached();

    QQStyleKitStyle *style() const;
    void setStyle(QQStyleKitStyle *style);

    QString styleUrl() const;
    void setStyleUrl(const QString &styleUrl);

    bool transitionsEnabled() const;
    void setTransitionsEnabled(bool enabled);

    QQStyleKitDebug *debug() const;

    Q_INVOKABLE bool styleLoaded() const;

signals:
    void styleChanged();
    void styleUrlChanged();
    void transitionsEnabledChanged();

private:
    bool m_ownsStyle = false;
    QString m_styleUrl;
    QPointer<QQmlEngine> m_engine;
    QPointer<QQStyleKitStyle> m_style;
    QQStyleKitDebug m_debug;

    static QPointer<QQStyleKitAttached> s_instance;
    static bool s_transitionsEnabled;

    friend class QQStyleKit;
};

QT_END_NAMESPACE

#endif // QQSTYLEKIT_P_H