QmlMaterial 0.1.0
Loading...
Searching...
No Matches
snake_bar_state.hpp
1#pragma once
2#include "qml_material/style/common_state.hpp"
3Q_MOC_INCLUDE("qml_material/control/control.hpp")
4Q_MOC_INCLUDE("qml_material/control/button_control.hpp")
5namespace qml_material
6{
7class Control;
8class ButtonControl;
9class QML_MATERIAL_API SnakeBarState : public CommonState {
10 Q_OBJECT
11 QML_NAMED_ELEMENT(StateSnakeBar)
12 Q_PROPERTY(qml_material::IndicationValues actionIndication READ actionIndication NOTIFY
13 actionIndicationChanged FINAL)
14 Q_PROPERTY(qml_material::IndicationValues iconIndication READ iconIndication NOTIFY
15 iconIndicationChanged FINAL)
16 Q_PROPERTY(qml_material::Control* item READ item WRITE setItem NOTIFY itemChanged FINAL)
17 Q_PROPERTY(qml_material::ButtonControl* actionItem READ actionItem WRITE setActionItem NOTIFY
18 actionItemChanged)
19 Q_PROPERTY(qml_material::ButtonControl* iconItem READ iconItem WRITE setIconItem NOTIFY
20 iconItemChanged)
21 Q_PROPERTY(QColor iconColor READ iconColor WRITE setIconColor RESET resetIconColor NOTIFY
22 iconColorChanged BINDABLE bindableIconColor)
23 Q_PROPERTY(QColor iconStateLayerColor READ iconStateLayerColor WRITE setIconStateLayerColor
24 RESET resetIconStateLayerColor NOTIFY iconStateLayerColorChanged BINDABLE
25 bindableIconStateLayerColor)
26 Q_PROPERTY(qreal iconStateLayerOpacity READ iconStateLayerOpacity WRITE setIconStateLayerOpacity
27 RESET resetIconStateLayerOpacity NOTIFY iconStateLayerOpacityChanged BINDABLE
28 bindableIconStateLayerOpacity)
29public:
30 explicit SnakeBarState(QObject* parent = nullptr);
31 ~SnakeBarState() override;
32 IndicationValues actionIndication() const { return m_actionIndication.values(); }
33 IndicationValues iconIndication() const { return m_iconIndication.values(); }
34 Q_SIGNAL void actionIndicationChanged();
35 Q_SIGNAL void iconIndicationChanged();
36 Control* item() const;
37 void setItem(Control*);
38 Q_SIGNAL void itemChanged();
39 ButtonControl* actionItem() const;
40 void setActionItem(ButtonControl*);
41 Q_SIGNAL void actionItemChanged();
42 ButtonControl* iconItem() const;
43 void setIconItem(ButtonControl*);
44 Q_SIGNAL void iconItemChanged();
45 QColor iconColor() const;
46 void setIconColor(const QColor&);
47 QBindable<QColor> bindableIconColor();
48 void resetIconColor();
49 Q_SIGNAL void iconColorChanged();
50 QColor iconStateLayerColor() const;
51 void setIconStateLayerColor(const QColor&);
52 QBindable<QColor> bindableIconStateLayerColor();
53 void resetIconStateLayerColor();
54 Q_SIGNAL void iconStateLayerColorChanged();
55 qreal iconStateLayerOpacity() const;
56 void setIconStateLayerOpacity(qreal);
57 QBindable<qreal> bindableIconStateLayerOpacity();
58 void resetIconStateLayerOpacity();
59 Q_SIGNAL void iconStateLayerOpacityChanged();
60
61private:
62 enum class Appearance
63 {
64 Base
65 };
66 StateBindingSet<Appearance> m_bindings { Appearance::Base };
67 QProperty<ButtonControl*> m_actionItem { nullptr };
68 QProperty<ButtonControl*> m_iconItem { nullptr };
69 QMetaObject::Connection m_actionDestroyed;
70 QMetaObject::Connection m_iconDestroyed;
71 QMetaObject::Connection m_actionSourceChanged, m_iconSourceChanged;
72 Q_OBJECT_BINDABLE_PROPERTY(SnakeBarState, QColor, m_iconColor, &SnakeBarState::iconColorChanged)
73 Q_OBJECT_BINDABLE_PROPERTY(SnakeBarState, QColor, m_iconStateLayerColor,
74 &SnakeBarState::iconStateLayerColorChanged)
75 Q_OBJECT_BINDABLE_PROPERTY(SnakeBarState, qreal, m_iconStateLayerOpacity,
76 &SnakeBarState::iconStateLayerOpacityChanged)
77 PropertyKey<QColor> m_iconColorKey;
78 PropertyKey<QColor> m_iconLayerColorKey;
79 PropertyKey<qreal> m_iconLayerOpacityKey;
80 IndicationPolicy m_actionIndication;
81 IndicationPolicy m_iconIndication;
82 StateBindingSet<Appearance>::Lifetime m_lifetime { m_bindings.lifetime() };
83};
84} // namespace qml_material