1 | // SPDX-FileCopyrightText: ⓒ 2025 Volker Krause <vkrause@kde.org> |
2 | // SPDX-License-Identifier: LGPL-2.0-or-later |
3 | |
4 | #ifndef KIRIGAMI_SAFEAREA_H |
5 | #define KIRIGAMI_SAFEAREA_H |
6 | |
7 | #include <QMarginsF> |
8 | #include <QObject> |
9 | |
10 | #include <qqmlregistration.h> |
11 | |
12 | namespace Kirigami |
13 | { |
14 | |
15 | /*! |
16 | * \qmltype SafeArea |
17 | * \inqmlmodule org.kde.kirigami.polyfill |
18 | * |
19 | * \brief A drop-in replacement for Qt's SafeArea attached property |
20 | * when using Qt prior to 6.9. When using Qt 6.9 or higher this type |
21 | * is not provided anymore so the "real" one from Qt gets used instead. |
22 | * |
23 | * Note that this has no actual functionality and will always report |
24 | * zero margins. |
25 | * |
26 | * This is for internal use only and will go away once the minimum Qt version |
27 | * for Kirigami has reached 6.9! |
28 | * |
29 | * \since 6.15 |
30 | */ |
31 | class SafeAreaAttached : public QObject |
32 | { |
33 | Q_OBJECT |
34 | |
35 | Q_PROPERTY(QMarginsF margins READ margins NOTIFY marginsChanged FINAL) |
36 | |
37 | QML_NAMED_ELEMENT(SafeArea) |
38 | QML_ATTACHED(SafeAreaAttached) |
39 | QML_UNCREATABLE("" ) |
40 | |
41 | public: |
42 | explicit SafeAreaAttached(QObject *parent); |
43 | |
44 | [[nodiscard]] QMarginsF margins() const; |
45 | |
46 | [[nodiscard]] static SafeAreaAttached *qmlAttachedProperties(QObject *object); |
47 | |
48 | Q_SIGNALS: |
49 | void marginsChanged(); |
50 | }; |
51 | } |
52 | |
53 | #endif |
54 | |