QmlMaterial 0.1.0
Loading...
Searching...
No Matches
page.hpp
1#pragma once
2
3#include "qml_material/control/panel.hpp"
4
5namespace qml_material
6{
7
8class QML_MATERIAL_API Page : public Panel {
9 Q_OBJECT
10 QML_NAMED_ELEMENT(PageBase)
11 Q_PROPERTY(QString title READ title WRITE setTitle RESET resetTitle NOTIFY titleChanged FINAL)
12 Q_PROPERTY(QQuickItem* header READ header WRITE setHeader NOTIFY headerChanged FINAL)
13 Q_PROPERTY(QQuickItem* footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
14 Q_PROPERTY(
15 qreal implicitHeaderWidth READ implicitHeaderWidth NOTIFY implicitHeaderWidthChanged FINAL)
16 Q_PROPERTY(qreal implicitHeaderHeight READ implicitHeaderHeight NOTIFY
17 implicitHeaderHeightChanged FINAL)
18 Q_PROPERTY(
19 qreal implicitFooterWidth READ implicitFooterWidth NOTIFY implicitFooterWidthChanged FINAL)
20 Q_PROPERTY(qreal implicitFooterHeight READ implicitFooterHeight NOTIFY
21 implicitFooterHeightChanged FINAL)
22 Q_PROPERTY(bool canBack READ canBack WRITE setCanBack NOTIFY canBackChanged FINAL)
23 Q_PROPERTY(bool scrolling READ scrolling WRITE setScrolling NOTIFY scrollingChanged FINAL)
24
25public:
26 explicit Page(QQuickItem* parent = nullptr);
27 ~Page() override;
28 QString title() const;
29 void setTitle(const QString& value);
30 void resetTitle();
31 QQuickItem* header() const;
32 QQuickItem* footer() const;
33 void setHeader(QQuickItem* item);
34 void setFooter(QQuickItem* item);
35 qreal implicitHeaderWidth() const;
36 qreal implicitHeaderHeight() const;
37 qreal implicitFooterWidth() const;
38 qreal implicitFooterHeight() const;
39 bool canBack() const;
40 void setCanBack(bool value);
41 bool scrolling() const;
42 void setScrolling(bool value);
43
44 Q_SIGNAL void titleChanged();
45 Q_SIGNAL void headerChanged();
46 Q_SIGNAL void footerChanged();
47 Q_SIGNAL void implicitHeaderWidthChanged();
48 Q_SIGNAL void implicitHeaderHeightChanged();
49 Q_SIGNAL void implicitFooterWidthChanged();
50 Q_SIGNAL void implicitFooterHeightChanged();
51 Q_SIGNAL void canBackChanged();
52 Q_SIGNAL void scrollingChanged();
53
54protected:
55 QRectF contentRect() const override;
56 void componentComplete() override;
57 void geometryChange(const QRectF& geometry, const QRectF& oldGeometry) override;
58
59private:
60 struct Slot {
61 QPointer<QQuickItem> item;
62 QSizeF implicitSize { 0, 0 };
63 QList<QMetaObject::Connection> connections;
64 };
65 void setSlot(Slot& slot, QQuickItem* item);
66 void updateSlot(Slot& slot);
67 void relayout();
68 Slot m_header;
69 Slot m_footer;
70 QString m_title;
71 bool m_can_back = false;
72 bool m_scrolling = false;
73 bool m_layout_active = false;
74 QMetaObject::Connection m_spacing_connection;
75};
76
77} // namespace qml_material