QmlMaterial 0.1.0
Loading...
Searching...
No Matches
page_context.hpp
1#pragma once
2
3#include <QtCore/QList>
4#include <QtCore/QMetaObject>
5#include <QtCore/QPointer>
6#include <QtQml/QQmlEngine>
7
8namespace qml_material
9{
10class PageContext : public QObject {
11 Q_OBJECT
12 QML_ELEMENT
13 Q_PROPERTY(PageContext* inherit READ inherit WRITE setInherit NOTIFY inheritChanged FINAL)
14 Q_PROPERTY(QObject* leadingAction READ leadingAction WRITE setLeadingAction RESET
15 resetLeadingAction NOTIFY leadingActionChanged FINAL)
16 Q_PROPERTY(qint32 headerType READ headerType WRITE setHeaderType RESET resetHeaderType NOTIFY
17 headerTypeChanged FINAL)
18 Q_PROPERTY(qint32 backgroundRadius READ backgroundRadius WRITE setBackgroundRadius RESET
19 resetBackgroundRadius NOTIFY backgroundRadiusChanged FINAL)
20 Q_PROPERTY(
21 double headerBackgroundOpacity READ headerBackgroundOpacity WRITE setHeaderBackgroundOpacity
22 RESET resetHeaderBackgroundOpacity NOTIFY headerBackgroundOpacityChanged FINAL)
23 Q_PROPERTY(
24 qint32 radius READ radius WRITE setRadius RESET resetRadius NOTIFY radiusChanged FINAL)
25 Q_PROPERTY(bool showHeader READ showHeader WRITE setShowHeader RESET resetShowHeader NOTIFY
26 showHeaderChanged FINAL)
27 Q_PROPERTY(bool showBackground READ showBackground WRITE setShowBackground RESET
28 resetShowBackground NOTIFY showBackgroundChanged FINAL)
29 Q_PROPERTY(qint32 leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY
30 leftMarginChanged FINAL)
31 Q_PROPERTY(qint32 rightMargin READ rightMargin WRITE setRightMargin RESET resetRightMargin
32 NOTIFY rightMarginChanged FINAL)
33 Q_PROPERTY(qint32 topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY
34 topMarginChanged FINAL)
35 Q_PROPERTY(qint32 bottomMargin READ bottomMargin WRITE setBottomMargin RESET resetBottomMargin
36 NOTIFY bottomMarginChanged FINAL)
37 // The portion of bottomMargin reserved for an overlapping bottom surface.
38 Q_PROPERTY(qint32 bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset
39 NOTIFY bottomInsetChanged FINAL)
40public:
41 PageContext(QObject* parent = nullptr);
42 ~PageContext();
43
44 auto inherit() const -> PageContext*;
45 auto leadingAction() const -> QObject*;
46 auto backgroundRadius() const -> qint32;
47 auto headerBackgroundOpacity() const -> double;
48 auto radius() const -> qint32;
49 auto headerType() const -> qint32;
50 auto showHeader() const -> bool;
51 auto showBackground() const -> bool;
52 auto leftMargin() const -> qint32;
53 auto rightMargin() const -> qint32;
54 auto topMargin() const -> qint32;
55 auto bottomMargin() const -> qint32;
56 auto bottomInset() const -> qint32;
57
58 Q_SLOT void setInherit(PageContext*);
59 Q_SLOT void setLeadingAction(QObject*);
60 Q_SLOT void setBackgroundRadius(qint32);
61 Q_SLOT void setHeaderBackgroundOpacity(double);
62 Q_SLOT void setRadius(qint32);
63 Q_SLOT void setHeaderType(qint32);
64 Q_SLOT void setShowHeader(bool);
65 Q_SLOT void setShowBackground(bool);
66 Q_SLOT void setLeftMargin(qint32);
67 Q_SLOT void setRightMargin(qint32);
68 Q_SLOT void setTopMargin(qint32);
69 Q_SLOT void setBottomMargin(qint32);
70 Q_SLOT void setBottomInset(qint32);
71
72 Q_SLOT void resetLeadingAction();
73 Q_SLOT void resetBackgroundRadius();
74 Q_SLOT void resetHeaderBackgroundOpacity();
75 Q_SLOT void resetRadius();
76 Q_SLOT void resetHeaderType();
77 Q_SLOT void resetShowHeader();
78 Q_SLOT void resetShowBackground();
79 Q_SLOT void resetLeftMargin();
80 Q_SLOT void resetRightMargin();
81 Q_SLOT void resetTopMargin();
82 Q_SLOT void resetBottomMargin();
83 Q_SLOT void resetBottomInset();
84
85 Q_SIGNAL void inheritChanged();
86 Q_SIGNAL void leadingActionChanged();
87 Q_SIGNAL void backgroundRadiusChanged();
88 Q_SIGNAL void headerBackgroundOpacityChanged();
89 Q_SIGNAL void radiusChanged();
90 Q_SIGNAL void headerTypeChanged();
91 Q_SIGNAL void showHeaderChanged();
92 Q_SIGNAL void showBackgroundChanged();
93 Q_SIGNAL void leftMarginChanged();
94 Q_SIGNAL void rightMarginChanged();
95 Q_SIGNAL void topMarginChanged();
96 Q_SIGNAL void bottomMarginChanged();
97 Q_SIGNAL void bottomInsetChanged();
98
99 Q_SIGNAL void pushItem(const QJSValue& url_or_comp, const QVariantMap& props = {});
100 Q_SIGNAL void pop();
101
102private:
103 void disconnectInherit();
104 void notifyInheritedProperties();
105
106 QPointer<PageContext> m_inherit;
107 QList<QMetaObject::Connection> m_inherit_connections;
108
109 std::optional<QObject*> m_leading_action;
110 std::optional<qint32> m_header_type;
111 std::optional<qint32> m_background_radius;
112 std::optional<double> m_header_background_opacity;
113 std::optional<qint32> m_radius;
114 std::optional<bool> m_show_header;
115 std::optional<bool> m_show_background;
116 std::optional<qint32> m_left_margin;
117 std::optional<qint32> m_right_margin;
118 std::optional<qint32> m_top_margin;
119 std::optional<qint32> m_bottom_margin;
120 std::optional<qint32> m_bottom_inset;
121};
122} // namespace qml_material