QmlMaterial 0.1.0
Loading...
Searching...
No Matches
switch_state.hpp
1#pragma once
2#include "qml_material/style/button_interaction_state.hpp"
3Q_MOC_INCLUDE("qml_material/control/switch.hpp")
4namespace qml_material
5{
6class Switch;
7class QML_MATERIAL_API SwitchState : public ButtonInteractionState {
8 Q_OBJECT
9 QML_NAMED_ELEMENT(StateSwitch)
10 Q_PROPERTY(qml_material::Switch* item READ item WRITE setItem NOTIFY itemChanged FINAL)
11 Q_PROPERTY(QColor handleColor READ handleColor WRITE setHandleColor RESET resetHandleColor
12 NOTIFY handleColorChanged BINDABLE bindableHandleColor)
13 Q_PROPERTY(int handleSize READ handleSize WRITE setHandleSize RESET resetHandleSize NOTIFY
14 handleSizeChanged BINDABLE bindableHandleSize)
15 Q_PROPERTY(bool hasIcon READ hasIcon NOTIFY hasIconChanged)
16public:
17 explicit SwitchState(QObject* parent = nullptr);
18 Switch* item() const;
19 void setItem(Switch*);
20 QColor handleColor() const;
21 void setHandleColor(const QColor&);
22 void resetHandleColor();
23 QBindable<QColor> bindableHandleColor();
24 int handleSize() const;
25 void setHandleSize(int);
26 void resetHandleSize();
27 QBindable<int> bindableHandleSize();
28 bool hasIcon() const;
29 Q_SIGNAL void handleColorChanged();
30 Q_SIGNAL void handleSizeChanged();
31 Q_SIGNAL void hasIconChanged();
32
33private:
34 PropertyKey<QColor> m_handleColorKey;
35 PropertyKey<int> m_handleSizeKey;
36 Q_OBJECT_BINDABLE_PROPERTY(SwitchState, QColor, m_handleColor, &SwitchState::handleColorChanged)
37 Q_OBJECT_BINDABLE_PROPERTY(SwitchState, int, m_handleSize, &SwitchState::handleSizeChanged)
38 Q_OBJECT_BINDABLE_PROPERTY(SwitchState, bool, m_hasIcon, &SwitchState::hasIconChanged)
39 BindingLifetime m_bindingLifetime { bindingSet().lifetime() };
40};
41} // namespace qml_material