Kirigami2

headerfooterlayout.h
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 HEADERFOOTERLAYOUT_H
9
10#include <QQuickItem>
11#include <qtmetamacros.h>
12
13/**
14 * replicates a little part of what Page does,
15 * It's a container with 3 properties, header, contentItem and footer
16 * which will be laid out oone on top of each other. It works better than a
17 * ColumnLayout when the elements are to be defined by properties by the
18 * user, which would require ugly reparenting dances and container items to
19 * maintain the layout well behaving.
20 */
22{
24 QML_ELEMENT
25 /**
26 * @brief This property holds the page header item.
27 *
28 * The header item is positioned to the top,
29 * and resized to the width of the page. The default value is null.
30 */
31 Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
32
33 /**
34 * @brief This property holds the visual content Item.
35 *
36 * It will be resized both in width and height with the layout resizing.
37 * Its height will be resized to still have room for the heder and footer
38 */
39 Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL)
40
41 /**
42 * @brief This property holds the page footer item.
43 *
44 * The footer item is positioned to the bottom,
45 * and resized to the width of the page. The default value is null.
46 */
47 Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
48
49public:
51 ~HeaderFooterLayout() override;
52
53 void setHeader(QQuickItem *item);
55
56 void setContentItem(QQuickItem *item);
58
59 void setFooter(QQuickItem *item);
61
62 /**
63 * @brief HeaderFooterLayout normally positions its header, footer and
64 * contentItem once per frame (at polish event). This method forces the it
65 * to recalculate the layout immediately.
66 */
68
70 void headerChanged();
71 void contentItemChanged();
72 void footerChanged();
73
74protected:
75 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
76 void componentComplete() override;
77 void updatePolish() override;
78
79private:
80 void markAsDirty();
81 void performLayout();
82 void updateImplicitSize();
83 void disconnectItem(QQuickItem *item);
84
85 QPointer<QQuickItem> m_header;
86 QPointer<QQuickItem> m_contentItem;
87 QPointer<QQuickItem> m_footer;
88
89 bool m_isDirty : 1;
90 bool m_performingLayout : 1;
91};
92
93#endif
replicates a little part of what Page does, It's a container with 3 properties, header,...
QQuickItem * footer
This property holds the page footer item.
QML_ELEMENTQQuickItem * header
This property holds the page header item.
Q_INVOKABLE void forceLayout()
HeaderFooterLayout normally positions its header, footer and contentItem once per frame (at polish ev...
QQuickItem * contentItem
This property holds the visual content Item.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.