QmlMaterial 0.1.0
Loading...
Searching...
No Matches
app_bar_state.hpp
1#pragma once
2#include "qml_material/style/common_state.hpp"
3#include "qml_material/token/type_scale.hpp"
4Q_MOC_INCLUDE("qml_material/control/tool_bar.hpp")
5namespace qml_material
6{
7class ToolBar;
8class QML_MATERIAL_API AppBarState : public CommonState {
9 Q_OBJECT
10 QML_NAMED_ELEMENT(StateAppBar)
11 Q_PROPERTY(qml_material::ToolBar* item READ item WRITE setItem NOTIFY itemChanged FINAL)
12 Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged BINDABLE bindableType)
13 Q_PROPERTY(bool showBackground READ showBackground WRITE setShowBackground NOTIFY
14 showBackgroundChanged BINDABLE bindableShowBackground)
15 Q_PROPERTY(qml_material::token::TypeScaleItem typescale READ typescale WRITE setTypescale RESET
16 resetTypescale NOTIFY typescaleChanged BINDABLE bindableTypescale)
17 Q_PROPERTY(
18 int containerHeight READ containerHeight WRITE setContainerHeight RESET resetContainerHeight
19 NOTIFY containerHeightChanged BINDABLE bindableContainerHeight)
20public:
21 explicit AppBarState(QObject* parent = nullptr);
22 ~AppBarState() override;
23 ToolBar* item() const;
24 void setItem(ToolBar*);
25 Q_SIGNAL void itemChanged();
26 int type() const;
27 void setType(int);
28 QBindable<int> bindableType();
29 Q_SIGNAL void typeChanged();
30 bool showBackground() const;
31 void setShowBackground(bool);
32 QBindable<bool> bindableShowBackground();
33 Q_SIGNAL void showBackgroundChanged();
34 token::TypeScaleItem typescale() const;
35 void setTypescale(const token::TypeScaleItem&);
36 QBindable<token::TypeScaleItem> bindableTypescale();
37 void resetTypescale();
38 Q_SIGNAL void typescaleChanged();
39 int containerHeight() const;
40 void setContainerHeight(int);
41 QBindable<int> bindableContainerHeight();
42 void resetContainerHeight();
43 Q_SIGNAL void containerHeightChanged();
44
45private:
46 enum class Specification
47 {
48 Base,
49 Small,
50 Medium,
51 Large
52 };
53 struct Selection {
54 Specification state = Specification::Base;
55 quint64 generation = 0;
56 bool operator==(const Selection&) const = default;
57 };
58 void selectionChanged();
59 StateBindingSet<Specification> m_bindings { Specification::Base };
60 QProperty<ToolBar*> m_item { nullptr };
61 QMetaObject::Connection m_destroyed;
62 bool m_ready = false;
63 Q_OBJECT_BINDABLE_PROPERTY(AppBarState, Selection, m_selection, &AppBarState::selectionChanged)
64 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(AppBarState, int, m_type,
65 int(Enum::AppBarType::AppBarCenterAligned),
66 &AppBarState::typeChanged)
67 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(AppBarState, bool, m_showBackground, false,
68 &AppBarState::showBackgroundChanged)
69 Q_OBJECT_BINDABLE_PROPERTY(AppBarState, token::TypeScaleItem, m_typescale,
70 &AppBarState::typescaleChanged)
71 Q_OBJECT_BINDABLE_PROPERTY(AppBarState, int, m_containerHeight,
72 &AppBarState::containerHeightChanged)
73 PropertyKey<token::TypeScaleItem> m_typescaleKey;
74 PropertyKey<int> m_heightKey;
75 StateBindingSet<Specification>::Lifetime m_lifetime { m_bindings.lifetime() };
76};
77} // namespace qml_material
TypeScaleItem.
Definition type_scale.hpp:36