DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickdciiconimage_p.h
1// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DQUICKDCIICONIMAGE_P_H
6#define DQUICKDCIICONIMAGE_P_H
7
8#include "dquickiconimage_p.h"
9#include "dqmlglobalobject_p.h"
10
11#include <dtkdeclarative_global.h>
12#include <DObject>
13#include <DDciIcon>
14#include <DDciIconPalette>
15
16DQUICK_BEGIN_NAMESPACE
17DGUI_USE_NAMESPACE
18
19class DQuickDciIconImageItem;
20class DQuickIconAttached;
21class DQuickDciIconImagePrivate;
22class DQuickDciIconImage : public QQuickItem, DCORE_NAMESPACE::DObject
23{
24 Q_OBJECT
25 D_DECLARE_PRIVATE(DQuickDciIconImage)
26 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
27 Q_PROPERTY(DTK_QUICK_NAMESPACE::DQMLGlobalObject::ControlState mode READ mode WRITE setMode NOTIFY modeChanged FINAL)
28 Q_PROPERTY(DTK_GUI_NAMESPACE::DGuiApplicationHelper::ColorType theme READ theme WRITE setTheme NOTIFY themeChanged FINAL)
29 Q_PROPERTY(DTK_GUI_NAMESPACE::DDciIconPalette palette READ palette WRITE setPalette NOTIFY paletteChanged)
30 Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)
31 Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged)
32 Q_PROPERTY(bool fallbackToQIcon READ fallbackToQIcon WRITE setFallbackToQIcon NOTIFY fallbackToQIconChanged)
33 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
34 Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged FINAL)
35#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
36 QML_NAMED_ELEMENT(DciIcon)
37 QML_ATTACHED(DQuickIconAttached)
38#endif
39
40public:
41 explicit DQuickDciIconImage(QQuickItem *parent = nullptr);
42 ~DQuickDciIconImage() override;
43
44 QString name() const;
45 void setName(const QString &name);
46
47 DQMLGlobalObject::ControlState mode() const;
48 void setMode(DQMLGlobalObject::ControlState mode);
49 Q_INVOKABLE void play(DQMLGlobalObject::ControlState mode);
50
51 DGuiApplicationHelper::ColorType theme() const;
52 void setTheme(DGuiApplicationHelper::ColorType theme);
53
54 DDciIconPalette palette() const;
55 void setPalette(const DDciIconPalette &palette);
56
57 QSize sourceSize() const;
58 void setSourceSize(const QSize &size);
59
60 void setMirror(bool mirror);
61 bool mirror() const;
62
63 bool fallbackToQIcon() const;
64 void setFallbackToQIcon(bool newFallbackToQIcon);
65
66 bool asynchronous() const;
67 void setAsynchronous(bool async);
68
69 bool cache() const;
70 void setCache(bool cache);
71
72 DQuickIconImage *imageItem() const;
73
74 static bool isNull(const QString &iconName);
75 static DQuickIconAttached *qmlAttachedProperties(QObject *object);
76
77Q_SIGNALS:
78 void nameChanged();
79 void modeChanged();
80 void themeChanged();
81 void paletteChanged();
82 void sourceSizeChanged();
83 void mirrorChanged();
84 void fallbackToQIconChanged();
85 void asynchronousChanged();
86 void cacheChanged();
87
88protected:
89 void classBegin() override;
90 void componentComplete() override;
91};
92
94class DQuickIconAttached : public QObject, DCORE_NAMESPACE::DObject
95{
96 Q_OBJECT
97 D_DECLARE_PRIVATE(DQuickIconAttached)
98 Q_PROPERTY(DTK_QUICK_NAMESPACE::DQMLGlobalObject::ControlState mode READ mode WRITE setMode NOTIFY modeChanged)
99 Q_PROPERTY(DTK_GUI_NAMESPACE::DGuiApplicationHelper::ColorType theme READ theme WRITE setTheme NOTIFY themeChanged)
100 Q_PROPERTY(DTK_GUI_NAMESPACE::DDciIconPalette palette READ palette WRITE setPalette NOTIFY paletteChanged)
101 Q_PROPERTY(bool fallbackToQIcon READ fallbackToQIcon WRITE setFallbackToQIcon NOTIFY fallbackToQIconChanged)
102
103public:
104 explicit DQuickIconAttached(QQuickItem *parent);
106
107 DQMLGlobalObject::ControlState mode() const;
108 void setMode(DQMLGlobalObject::ControlState mode);
109
110 DGuiApplicationHelper::ColorType theme() const;
111 void setTheme(DGuiApplicationHelper::ColorType theme);
112
113 DDciIconPalette palette() const;
114 void setPalette(const DDciIconPalette &palette);
115
116 bool fallbackToQIcon() const;
117 void setFallbackToQIcon(bool newFallbackToQIcon);
118
119Q_SIGNALS:
120 void modeChanged();
121 void themeChanged();
122 void paletteChanged();
123 void fallbackToQIconChanged();
124};
125
126DQUICK_END_NAMESPACE
127QML_DECLARE_TYPEINFO(DTK_QUICK_NAMESPACE::DQuickDciIconImage, QML_HAS_ATTACHED_PROPERTIES)
128#endif // DQUICKDCIICONIMAGE_P_H
Definition dquickdciiconimage_p.h:23
Definition dquickdciiconimage.cpp:385
Definition dquickdciiconimage_p.h:95
Definition dquickiconimage_p.h:23