summary refs log tree commit diff
path: root/src
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
parentFix warning on gcc11 (diff)
downloadnheko-a7f8b23b524c5e3af72e42fde118706e94a454f3.tar.xz
Make palette global in Qml
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineViewManager.cpp5
-rw-r--r--src/ui/NhekoGlobalObject.cpp27
-rw-r--r--src/ui/NhekoGlobalObject.h25
3 files changed, 57 insertions, 0 deletions
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp

index 628f3c31..94cef1a7 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -32,6 +32,7 @@ #include "emoji/Provider.h" #include "ui/NhekoCursorShape.h" #include "ui/NhekoDropArea.h" +#include "ui/NhekoGlobalObject.h" Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) Q_DECLARE_METATYPE(std::vector<DeviceInfo>) @@ -221,6 +222,10 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par "im.nheko", 1, 0, "Clipboard", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Clipboard(); }); + qmlRegisterSingletonType<Nheko>( + "im.nheko", 1, 0, "Nheko", [](QQmlEngine *, QJSEngine *) -> QObject * { + return new Nheko(); + }); qRegisterMetaType<mtx::events::collections::TimelineEvents>(); qRegisterMetaType<std::vector<DeviceInfo>>(); 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(); +};