summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-05-13 08:23:56 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-05-13 08:23:56 +0200
commita7f8b23b524c5e3af72e42fde118706e94a454f3 (patch)
treec3918f64578ee97b89dba41ae169baea09a061e6 /src/ui
parentFix warning on gcc11 (diff)
downloadnheko-a7f8b23b524c5e3af72e42fde118706e94a454f3.tar.xz
Make palette global in Qml
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/NhekoGlobalObject.cpp27
-rw-r--r--src/ui/NhekoGlobalObject.h25
2 files changed, 52 insertions, 0 deletions
diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp
new file mode 100644

index 00000000..5a2b9788 --- /dev/null +++ b/src/ui/NhekoGlobalObject.cpp
@@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2021 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "NhekoGlobalObject.h" + +#include "UserSettingsPage.h" + +Nheko::Nheko() +{ + connect( + UserSettings::instance().get(), &UserSettings::themeChanged, this, &Nheko::colorsChanged); +} + +QPalette +Nheko::colors() const +{ + return QPalette(); +} + +QPalette +Nheko::inactiveColors() const +{ + QPalette p; + p.setCurrentColorGroup(QPalette::ColorGroup::Inactive); + return p; +} diff --git a/src/ui/NhekoGlobalObject.h b/src/ui/NhekoGlobalObject.h new file mode 100644
index 00000000..76186828 --- /dev/null +++ b/src/ui/NhekoGlobalObject.h
@@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2021 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include <QObject> +#include <QPalette> + +class Nheko : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QPalette colors READ colors NOTIFY colorsChanged) + Q_PROPERTY(QPalette inactiveColors READ inactiveColors NOTIFY colorsChanged) + +public: + Nheko(); + + QPalette colors() const; + QPalette inactiveColors() const; + +signals: + void colorsChanged(); +};