| 1 | /* |
| 2 | * SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org> |
| 3 | * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> |
| 4 | * |
| 5 | * SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | #ifndef HEADERFOOTERLAYOUT_H |
| 8 | #define |
| 9 | |
| 10 | #include <QQuickItem> |
| 11 | #include <qtmetamacros.h> |
| 12 | |
| 13 | /*! |
| 14 | * \qmltype HeaderFooterLayout |
| 15 | * \inqmlmodule org.kde.kirigami.layouts |
| 16 | * |
| 17 | * \brief Replicates a little part of what Page does. |
| 18 | * |
| 19 | * It's a container with 3 properties, header, contentItem and footer |
| 20 | * which will be laid out oone on top of each other. |
| 21 | * |
| 22 | * It works better than a ColumnLayout when the elements are to be |
| 23 | * defined by properties by the user, which would require ugly |
| 24 | * reparenting dances and container items to |
| 25 | * maintain the layout well behaving. |
| 26 | */ |
| 27 | class : public QQuickItem |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | QML_ELEMENT |
| 31 | /*! |
| 32 | * \qmlproperty Item HeaderFooterLayout::header |
| 33 | * \brief This property holds the page header item. |
| 34 | * |
| 35 | * The header item is positioned to the top, |
| 36 | * and resized to the width of the page. The default value is null. |
| 37 | */ |
| 38 | Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) |
| 39 | |
| 40 | /*! |
| 41 | * \qmlproperty Item HeaderFooterLayout::contentItem |
| 42 | * \brief This property holds the visual content Item. |
| 43 | * |
| 44 | * It will be resized both in width and height with the layout resizing. |
| 45 | * Its height will be resized to still have room for the heder and footer |
| 46 | */ |
| 47 | Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) |
| 48 | |
| 49 | /*! |
| 50 | * \qmlproperty Item HeaderFooterLayout::footer |
| 51 | * \brief This property holds the page footer item. |
| 52 | * |
| 53 | * The footer item is positioned to the bottom, |
| 54 | * and resized to the width of the page. The default value is null. |
| 55 | */ |
| 56 | Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) |
| 57 | |
| 58 | /*! |
| 59 | * \qmlproperty real HeaderFooterLayout::spacing |
| 60 | * \brief Space between contentItem and the header and footer items. |
| 61 | * |
| 62 | * The content Item of the page will be positioned at this distance in pixels |
| 63 | * from the header and footer Items. The default value is zero. |
| 64 | * |
| 65 | * @since 6.13 |
| 66 | */ |
| 67 | Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged FINAL) |
| 68 | |
| 69 | public: |
| 70 | (QQuickItem *parent = nullptr); |
| 71 | () override; |
| 72 | |
| 73 | void (QQuickItem *item); |
| 74 | QQuickItem *(); |
| 75 | |
| 76 | void (QQuickItem *item); |
| 77 | QQuickItem *(); |
| 78 | |
| 79 | void (QQuickItem *item); |
| 80 | QQuickItem *(); |
| 81 | |
| 82 | void (qreal spacing); |
| 83 | qreal () const; |
| 84 | |
| 85 | /*! |
| 86 | * \qmlmethod void HeaderFooterLayout::forceLayout() |
| 87 | * \brief HeaderFooterLayout normally positions its header, footer and |
| 88 | * contentItem once per frame (at polish event). This method forces the it |
| 89 | * to recalculate the layout immediately. |
| 90 | */ |
| 91 | Q_INVOKABLE void (); |
| 92 | |
| 93 | Q_SIGNALS: |
| 94 | void (); |
| 95 | void (); |
| 96 | void (); |
| 97 | void (); |
| 98 | |
| 99 | protected: |
| 100 | void (const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 101 | void () override; |
| 102 | void () override; |
| 103 | |
| 104 | private: |
| 105 | void (); |
| 106 | void (); |
| 107 | void (); |
| 108 | void (QQuickItem *item); |
| 109 | |
| 110 | QPointer<QQuickItem> ; |
| 111 | QPointer<QQuickItem> ; |
| 112 | QPointer<QQuickItem> ; |
| 113 | |
| 114 | qreal = 0; |
| 115 | |
| 116 | bool : 1; |
| 117 | bool : 1; |
| 118 | }; |
| 119 | |
| 120 | #endif |
| 121 | |