KGuiAddons

kwindowinsetscontroller.cpp
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#include "kwindowinsetscontroller.h"
6
7#include <QCoreApplication>
8
9#ifdef Q_OS_ANDROID
10#include <QJniObject>
11#endif
12
13class KWindowInsetsControllerPrivate
14{
15public:
16 QColor m_statusBarColor;
17 QColor m_navigationBarColor;
18};
19
20KWindowInsetsController::KWindowInsetsController(QObject *parent)
21 : QObject(parent)
22#ifdef Q_OS_ANDROID
23 , d(new KWindowInsetsControllerPrivate)
24#endif
25{
26}
27
28KWindowInsetsController::~KWindowInsetsController() = default;
29
30QColor KWindowInsetsController::statusBarBackgroundColor() const // NOLINT readability-convert-member-functions-to-static
31{
32#ifdef Q_OS_ANDROID
33 return d->m_statusBarColor;
34#else
35 return {};
36#endif
37}
38
39void KWindowInsetsController::setStatusBarBackgroundColor(const QColor &color) // NOLINT readability-convert-member-functions-to-static
40{
41#ifdef Q_OS_ANDROID
42 d->m_statusBarColor = color;
43
45 QJniObject::callStaticMethod<void>("org.kde.guiaddons.KWindowInsetsController",
46 "setStatusBarBackground",
47 "(Landroid/app/Activity;I)V",
49 color.rgba());
50 });
51#else
52 Q_UNUSED(color)
53#endif
54}
55
56QColor KWindowInsetsController::navigationBarBackgroundColor() const // NOLINT readability-convert-member-functions-to-static
57{
58#ifdef Q_OS_ANDROID
59 return d->m_navigationBarColor;
60#else
61 return {};
62#endif
63}
64
65void KWindowInsetsController::setNavigationBarBackgroundColor(const QColor &color) // NOLINT readability-convert-member-functions-to-static
66{
67#ifdef Q_OS_ANDROID
68 d->m_navigationBarColor = color;
69
71 QJniObject::callStaticMethod<void>("org.kde.guiaddons.KWindowInsetsController",
72 "setNavigationBarBackground",
73 "(Landroid/app/Activity;I)V",
75 color.rgba());
76 });
77#else
78 Q_UNUSED(color)
79#endif
80}
81
82#include "moc_kwindowinsetscontroller.cpp"
QColor statusBarBackgroundColor
Background color of the status bar.
QColor navigationBarBackgroundColor
Background color of the navigation bar.
QRgb rgba() const const
auto callStaticMethod(const char *className, const char *methodName, Args &&... args)
QFuture< QVariant > runOnAndroidMainThread(const std::function< QVariant()> &runnable, const QDeadlineTimer timeout)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:51:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.