10#include <qqmlregistration.h>
11#include "qml_material/export.hpp"
15class QML_MATERIAL_API ActionIcon :
public QObject {
18 QML_UNCREATABLE(
"Owned by Action")
19 Q_PROPERTY(QString name READ name WRITE setName RESET resetName NOTIFY nameChanged FINAL)
20 Q_PROPERTY(QUrl source READ source WRITE setSource RESET resetSource NOTIFY sourceChanged FINAL)
21 Q_PROPERTY(QColor color READ color WRITE setColor RESET resetColor NOTIFY colorChanged FINAL)
22 Q_PROPERTY(
bool cache READ cache WRITE setCache RESET resetCache NOTIFY cacheChanged FINAL)
23 Q_PROPERTY(
bool fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged FINAL)
24 Q_PROPERTY(
int weight READ weight WRITE setWeight RESET resetWeight NOTIFY weightChanged FINAL)
25 Q_PROPERTY(
int renderType READ renderType WRITE setRenderType RESET resetRenderType NOTIFY
26 renderTypeChanged FINAL)
27 Q_PROPERTY(QUrl resolvedSource READ resolvedSource NOTIFY sourceChanged FINAL)
28 Q_PROPERTY(
bool empty READ isEmpty NOTIFY contentChanged BINDABLE bindableEmpty FINAL)
29 Q_PROPERTY(
bool image READ isImage NOTIFY contentChanged FINAL)
31 explicit ActionIcon(QObject* parent =
nullptr): QObject(parent) {}
32 QString name()
const {
return m_name; }
33 void setName(
const QString& value);
35 Q_SIGNAL
void nameChanged();
36 QUrl source()
const {
return m_source; }
37 void setSource(
const QUrl& value);
39 Q_SIGNAL
void sourceChanged();
40 QColor color()
const {
return m_color; }
41 void setColor(
const QColor& value);
43 Q_SIGNAL
void colorChanged();
44 bool cache()
const {
return m_cache; }
45 void setCache(
bool value);
47 Q_SIGNAL
void cacheChanged();
48 bool fill()
const {
return m_fill; }
49 void setFill(
bool value);
51 Q_SIGNAL
void fillChanged();
52 int weight()
const {
return m_weight; }
53 void setWeight(
int value);
55 Q_SIGNAL
void weightChanged();
56 int renderType()
const {
return m_renderType; }
57 void setRenderType(
int value);
58 void resetRenderType();
59 Q_SIGNAL
void renderTypeChanged();
60 QUrl resolvedSource()
const;
61 bool isEmpty()
const {
return m_empty.value(); }
62 QBindable<bool> bindableEmpty()
const {
return QBindable<bool>(&m_empty); }
63 bool isImage()
const {
return ! m_source.isEmpty(); }
64 Q_SIGNAL
void contentChanged();
65 Q_SIGNAL
void changed();
68 void setOverride(ActionIcon*);
72 const ActionIcon* contentOwner()
const;
73 std::optional<QString> m_local_name;
74 std::optional<QUrl> m_local_source;
75 std::optional<QColor> m_local_color;
76 std::optional<bool> m_local_cache;
77 std::optional<bool> m_local_fill;
78 std::optional<int> m_local_weight;
79 std::optional<int> m_local_renderType;
80 QString m_name = QString();
81 QProperty<bool> m_empty {
true };
82 QUrl m_source = QUrl();
83 QColor m_color = QColor(Qt::transparent);
86 int m_weight = QFont::Normal;
88 QUrl m_resolved_source;
89 QPointer<ActionIcon> m_override;
90 QList<QMetaObject::Connection> m_connections;
93class QML_MATERIAL_API IconSpec :
public ActionIcon {
96 Q_PROPERTY(
int width READ width WRITE setWidth RESET resetWidth NOTIFY widthChanged FINAL)
97 Q_PROPERTY(
int height READ height WRITE setHeight RESET resetHeight NOTIFY heightChanged FINAL)
99 explicit IconSpec(QObject* parent =
nullptr): ActionIcon(parent) {}
100 void setActionIcon(ActionIcon* value) { setOverride(value); }
101 int width()
const {
return m_width.value_or(0); }
102 int height()
const {
return m_height.value_or(0); }
107 Q_SIGNAL
void widthChanged();
108 Q_SIGNAL
void heightChanged();
111 std::optional<int> m_width, m_height;