QmlMaterial 0.1.0
Loading...
Searching...
No Matches
layout.hpp
1#pragma once
2
3#include <QMetaObject>
4#include <QObject>
5#include <QPointer>
6#include <QQuickItem>
7#include <QQmlEngine>
8
9#include "qml_material/export.hpp"
10
11namespace qml_material
12{
13
19class QML_MATERIAL_API LayoutAttached final : public QObject {
20 Q_OBJECT
21 Q_PROPERTY(bool fillWidth READ fillWidth WRITE setFillWidth NOTIFY fillWidthChanged FINAL)
22 Q_PROPERTY(bool fillHeight READ fillHeight WRITE setFillHeight NOTIFY fillHeightChanged FINAL)
23 Q_PROPERTY(QQuickItem* visibilitySource READ visibilitySource WRITE setVisibilitySource RESET
24 resetVisibilitySource NOTIFY visibilitySourceChanged FINAL)
25
26public:
27 explicit LayoutAttached(QObject* parent = nullptr);
28
29 bool fillWidth() const;
30 void setFillWidth(bool fill);
31
32 bool fillHeight() const;
33 void setFillHeight(bool fill);
34
35 QQuickItem* visibilitySource() const;
36 void setVisibilitySource(QQuickItem* source);
37 void resetVisibilitySource();
38
39 // A configured null source excludes the item; an unset source preserves legacy behavior.
40 bool isVisibilitySourceSet() const;
41
42 Q_SIGNAL void fillWidthChanged();
43 Q_SIGNAL void fillHeightChanged();
44 Q_SIGNAL void visibilitySourceChanged();
45
46private:
47 QPointer<QQuickItem> m_visibility_source;
48 QMetaObject::Connection m_visibility_source_destroyed;
49 bool m_fill_width = false;
50 bool m_fill_height = false;
51 bool m_visibility_source_set = false;
52};
53
59class QML_MATERIAL_API Layout : public QObject {
60 Q_OBJECT
61 QML_NAMED_ELEMENT(Layout)
62 QML_UNCREATABLE("Layout is only available via attached properties.")
63 QML_ATTACHED(LayoutAttached)
64
65public:
66 explicit Layout(QObject* parent = nullptr);
67
68 static LayoutAttached* qmlAttachedProperties(QObject* object);
69};
70
71} // namespace qml_material
Definition layout.hpp:19
Definition layout.hpp:59