Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Cambra <claudio.cambra@gmail.com>2022-02-04 05:39:38 +0300
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>2022-03-18 19:43:15 +0300
commitc342c304ace72e76680d6c9b594c56d88ccefeec (patch)
tree4190e5f92ff998091fbe3c554a9c2196667a6bae /src/gui/systray.cpp
parent90f59eca217ff1715379c9f612f5e2d131039810 (diff)
Added dark mode
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Diffstat (limited to 'src/gui/systray.cpp')
-rw-r--r--src/gui/systray.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp
index a5a352dd4..4a6391d8c 100644
--- a/src/gui/systray.cpp
+++ b/src/gui/systray.cpp
@@ -31,6 +31,7 @@
#include <QQuickWindow>
#include <QScreen>
#include <QMenu>
+#include <QGuiApplication>
#ifdef USE_FDO_NOTIFICATIONS
#include <QDBusConnection>
@@ -129,6 +130,12 @@ Systray::Systray()
});
#endif
+ const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance());
+ if(ptr) {
+ _guiAppInstance.reset(ptr);
+ connect(ptr, &QGuiApplication::paletteChanged, this, &Systray::darkModeChanged);
+ }
+
connect(UserModel::instance(), &UserModel::newUserSelected,
this, &Systray::slotNewUserSelected);
connect(UserModel::instance(), &UserModel::addAccount,
@@ -224,6 +231,24 @@ bool Systray::useNormalWindow() const
return cfg.showMainDialogAsNormalWindow();
}
+bool Systray::darkMode()
+{
+#if defined(Q_OS_MACOS)
+ return osXInDarkMode();
+// Windows: Check registry for dark mode
+#elif defined(Q_OS_WIN)
+ const auto darkModeSubkey = QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
+ if (!Utility::registryKeyExists(HKEY_CURRENT_USER, darkModeSubkey)) {
+ return false;
+ }
+ const auto darkMode = Utility::registryGetKeyValue(HKEY_CURRENT_USER, darkModeSubkey, QStringLiteral("AppsUseLightTheme")).toBool();
+ return darkMode;
+// Probably Linux
+#else
+ return Theme::isDarkColor(QGuiApplication::palette().window().color());
+#endif
+}
+
Q_INVOKABLE void Systray::setOpened()
{
_isOpen = true;