DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dquickiconimage_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 DQUICKICONIMAGE_H
6#define DQUICKICONIMAGE_H
7
8#include <dtkdeclarative_global.h>
9
10#include <QIcon>
11#ifndef emit
12#define emit Q_EMIT
13#include <private/qquickimage_p.h>
14#undef emit
15#else
16#include <private/qquickimage_p.h>
17#endif
18
19DQUICK_BEGIN_NAMESPACE
20
21class DQuickIconImagePrivate;
22class DQuickIconImage : public QQuickImage
23{
24 Q_OBJECT
25 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
26 Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged FINAL)
27 Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged FINAL)
28 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
29 Q_PROPERTY(QUrl fallbackSource READ fallbackSource WRITE setFallbackSource NOTIFY fallbackSourceChanged FINAL)
30
31#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
32 QML_NAMED_ELEMENT(QtIcon)
33#endif
34public:
35 enum class Mode {
36 Invalid = QIcon::Normal - 1,
37 Normal = QIcon::Normal,
38 Disabled = QIcon::Disabled,
39 Active = QIcon::Active,
40 Selected = QIcon::Selected
41 };
42 enum class State {
43 On = QIcon::On,
44 Off = QIcon::Off
45 };
46
47 Q_ENUM(Mode)
48 Q_ENUM(State)
49
50 explicit DQuickIconImage(QQuickItem *parent = nullptr);
52
53 void componentComplete() override;
54
55 QString name() const;
56 State state() const;
57 Mode mode() const;
58 QColor color() const;
59
60 const QUrl &fallbackSource() const;
61
62public Q_SLOTS:
63 void setName(const QString &name);
64 void setState(State state);
65 void setMode(Mode mode);
66 void setColor(const QColor &color);
67 void setFallbackSource(const QUrl &newSource);
68
69Q_SIGNALS:
70 void nameChanged();
71 void stateChanged();
72 void modeChanged();
73 void colorChanged();
74 void fallbackSourceChanged();
75
76protected:
77 DQuickIconImage(DQuickIconImagePrivate &dd, QQuickItem *parent);
78 void itemChange(ItemChange change, const ItemChangeData &value) override;
79 void pixmapChange() override;
80
81private:
82 Q_DISABLE_COPY(DQuickIconImage)
83 Q_DECLARE_PRIVATE(DQuickIconImage)
84 Q_PRIVATE_SLOT(d_func(), void maybeUpdateUrl())
85 friend class DQuickDciIconImagePrivate;
86};
87
88DQUICK_END_NAMESPACE
89
90#endif // DQUICKICONIMAGE_H
Definition dquickdciiconimage_p_p.h:32
Definition dquickiconimage_p_p.h:20
Definition dquickiconimage_p.h:23