-
Notifications
You must be signed in to change notification settings - Fork 28
/
debughelper.h
72 lines (60 loc) · 1.92 KB
/
debughelper.h
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
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include <QColor>
#include <QObject>
#include <QtQml/qqml.h>
class QSettings;
class DebugQuickItem : public QObject
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
QML_NAMED_ELEMENT(DebugItem)
QML_ATTACHED(DebugQuickItem)
public:
explicit DebugQuickItem(QObject * parent = nullptr);
static DebugQuickItem *qmlAttachedProperties(QObject *object);
QColor color() const;
void setColor(const QColor &newColor);
signals:
void colorChanged();
private:
QColor m_color;
};
class DebugHelper : public QObject
{
Q_OBJECT
Q_PROPERTY(bool qtDebugEnabled READ qtDebugEnabled CONSTANT)
Q_PROPERTY(bool useRegularWindow MEMBER m_useRegularWindow NOTIFY onUseRegularWindowChanged)
Q_PROPERTY(bool avoidLaunchApp MEMBER m_avoidLaunchApp NOTIFY onAvoidLaunchAppChanged)
Q_PROPERTY(bool avoidHideWindow MEMBER m_avoidHideWindow NOTIFY onAvoidHideWindowChanged)
Q_PROPERTY(bool itemBoundingEnabled MEMBER m_itemBoundingEnabled NOTIFY onItemBoundingEnabledChanged)
QML_NAMED_ELEMENT(DebugHelper)
QML_SINGLETON
public:
static DebugHelper &instance()
{
static DebugHelper _instance;
return _instance;
}
static DebugHelper *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
Q_UNUSED(qmlEngine)
Q_UNUSED(jsEngine)
return &instance();
}
~DebugHelper();
bool qtDebugEnabled() const;
signals:
void onUseRegularWindowChanged(bool);
void onAvoidLaunchAppChanged(bool);
void onAvoidHideWindowChanged(bool);
void onItemBoundingEnabledChanged(bool);
private:
explicit DebugHelper(QObject * parent = nullptr);
QSettings * m_debugSettings;
bool m_useRegularWindow;
bool m_avoidLaunchApp;
bool m_avoidHideWindow;
bool m_itemBoundingEnabled;
};