DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickbusyindicator_p.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DQUICKBUSYINDICATOR_P_H
6#define DQUICKBUSYINDICATOR_P_H
7
8#include <dtkdeclarative_global.h>
9
10#include <QtGui/qcolor.h>
11#include <QtQuick/qquickitem.h>
12#include <QtQuick/private/qsgadaptationlayer_p.h>
13
14DQUICK_BEGIN_NAMESPACE
15
16class DQuickBusyIndicator;
17class DQuickBusyIndicatorNode : public QObject, public QSGTransformNode
18{
19 Q_OBJECT
20
21public:
23
24 void setSpinning(bool spinning);
25 void sync(QQuickItem *item);
26
27public Q_SLOTS:
28 void maybeRotate();
29 void maybeUpdate();
30 void setFillColor(const QColor &color);
31
32private:
33 int updateIndicatorColors(const QColor &fill);
34
35private:
36 bool m_spinning;
37 float m_rotation;
38 QPointF m_center;
39 QQuickWindow *m_window;
40 QList<QList<QColor>> m_indicatorColors;
41};
42
43class DQuickBusyIndicator : public QQuickItem
44{
45 Q_OBJECT
46 Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
47 Q_PROPERTY(bool running READ isRunning WRITE setRunning)
48
49public:
50 explicit DQuickBusyIndicator(QQuickItem *parent = nullptr);
51
52 QColor fillColor() const;
53 bool isRunning() const;
54
55public Q_SLOTS:
56 void setFillColor(const QColor &color);
57 void setRunning(bool running);
58
59protected:
60 void itemChange(ItemChange change, const ItemChangeData &data) override;
61 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
62
63Q_SIGNALS:
64 void fillColorChanged();
65
66private:
67 QColor m_fillColor;
68 bool m_isRunning;
69 bool m_fillColorIsChanged;
70};
71
72DQUICK_END_NAMESPACE
73
74QML_DECLARE_TYPE(DTK_QUICK_NAMESPACE::DQuickBusyIndicator)
75
76#endif // DQUICKBUSYINDICATOR_P_H
Definition dquickbusyindicator_p.h:18
Definition dquickbusyindicator_p.h:44