Make palette global in Qml
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();
+};
|