diff --git a/src/controller/application.cpp b/src/controller/application.cpp index ade4fac3..460d7a26 100644 --- a/src/controller/application.cpp +++ b/src/controller/application.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include inline CommandWithArguments::second_type parseArgumentJson(const QString& argumentStr) @@ -74,19 +75,17 @@ Application::Application(int& argc, char** argv, const QString& name) : #endif } -#ifndef Q_OS_MAC bool Application::isDarkTheme() { -#ifdef Q_OS_WIN - QSettings settings( - "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", - QSettings::NativeFormat); - return settings.value("AppsUseLightTheme", 1).toInt() == 0; +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + return styleHints()->colorScheme() == Qt::ColorScheme::Dark; #else - // There is currently no straightforward way to detect dark mode in Linux, but this works for supported OS-s. + // There is currently no straightforward way to detect dark mode in Linux, but this works for + // supported OS-s. static const bool isDarkTheme = [] { QProcess p; - p.start(QStringLiteral("gsettings"), {"get", "org.gnome.desktop.interface", "color-scheme"}); + p.start(QStringLiteral("gsettings"), + {"get", "org.gnome.desktop.interface", "color-scheme"}); if (p.waitForFinished()) { return p.readAllStandardOutput().contains("dark"); } @@ -97,7 +96,6 @@ bool Application::isDarkTheme() return isDarkTheme; #endif } -#endif void Application::loadTranslations(const QString& lang) { diff --git a/src/controller/application.mm b/src/controller/application.mm index 4f66d1a3..6cf6c376 100644 --- a/src/controller/application.mm +++ b/src/controller/application.mm @@ -27,13 +27,6 @@ #import #import -bool Application::isDarkTheme() -{ - auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames: - @[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]]; - return [appearance isEqualToString:NSAppearanceNameDarkAqua]; -} - void Application::showAbout() { NSLog(@"web-eid-app: starting app");