1// SPDX-FileCopyrightText: 2024 Mathis BrĂ¼chert <mbb@kaidan.im>
2// SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3// SPDX-License-Identifier: LGPL-2.0-or-later
4
5#ifndef KWINDOWINSETSCONTROLLER_H
6#define KWINDOWINSETSCONTROLLER_H
7
8#include "kguiaddons_export.h"
9
10#include <QColor>
11#include <QObject>
12
13#include <memory>
14
15class KWindowInsetsControllerPrivate;
16
17/*!
18 * \qmltype WindowInsetsController
19 * \inqmlmodule org.kde.guiaddons
20 * \nativetype KWindowInsetsController
21 *
22 * \brief Access to window insets colors.
23 *
24 * On most platforms this does nothing, on Android it allows
25 * to customize the (top) status bar and (botton) navigation bar
26 * background colors, e.g. to match the current window or application
27 * colors.
28 *
29 * Note that the foreground colors on Android are automatically
30 * chosen based on the background color.
31 *
32 * \code
33 * Component.onComplete: {
34 * WindowInsetsController.statusBarBackgroundColor = Kirigami.Theme.backgroundColor;
35 * WindowInsetsController.navigationBarBackgroundColor = Kirigami.Theme.backgroundColor;
36 * }
37 * \endcode
38 *
39 * \since 6.7
40 *
41 */
42
43/*!
44 * \qmlproperty color WindowInsetsController::statusBarBackgroundColor
45 * Background color of the status bar.
46 */
47
48/*!
49 * \qmlproperty color WindowInsetsController::navigationBarBackgroundColor
50 * Background color of the navigation bar.
51 */
52
53/*!
54 * \class KWindowInsetsController
55 * \inmodule KGuiAddons
56 * \brief Access to window insets colors.
57 *
58 * On most platforms this does nothing, on Android it allows
59 * to customize the (top) status bar and (botton) navigation bar
60 * background colors, e.g. to match the current window or application
61 * colors.
62 *
63 * Note that the foreground colors on Android are automatically
64 * chosen based on the background color.
65 *
66 * \code
67 * Component.onComplete: {
68 * WindowInsetsController.statusBarBackgroundColor = Kirigami.Theme.backgroundColor;
69 * WindowInsetsController.navigationBarBackgroundColor = Kirigami.Theme.backgroundColor;
70 * }
71 * \endcode
72 *
73 * \since 6.7
74 */
75class KGUIADDONS_EXPORT KWindowInsetsController : public QObject
76{
77 Q_OBJECT
78
79 /*!
80 * \property KWindowInsetsController::statusBarBackgroundColor
81 * Background color of the status bar.
82 */
83 Q_PROPERTY(QColor statusBarBackgroundColor READ statusBarBackgroundColor WRITE setStatusBarBackgroundColor NOTIFY statusBarBackgroundColorChanged)
84 /*!
85 * \property KWindowInsetsController::navigationBarBackgroundColor
86 * Background color of the navigation bar.
87 */
88 Q_PROPERTY(
89 QColor navigationBarBackgroundColor READ navigationBarBackgroundColor WRITE setNavigationBarBackgroundColor NOTIFY navigationBarBackgroundColorChanged)
90
91public:
92 explicit KWindowInsetsController(QObject *parent = nullptr);
93 ~KWindowInsetsController();
94
95 [[nodiscard]] QColor statusBarBackgroundColor() const;
96 void setStatusBarBackgroundColor(const QColor &color);
97
98 [[nodiscard]] QColor navigationBarBackgroundColor() const;
99 void setNavigationBarBackgroundColor(const QColor &color);
100
101Q_SIGNALS:
102 void statusBarBackgroundColorChanged();
103 void navigationBarBackgroundColorChanged();
104
105private:
106 std::unique_ptr<KWindowInsetsControllerPrivate> d;
107};
108
109#endif // KWINDOWINSETSCONTROLLER_H
110

source code of kguiaddons/src/colors/kwindowinsetscontroller.h