33
33
#include < QPalette>
34
34
#include < QProcess>
35
35
#include < QSettings>
36
+ #include < QStyleHints>
36
37
#include < QTranslator>
37
38
38
39
inline CommandWithArguments::second_type parseArgumentJson (const QString& argumentStr)
@@ -74,19 +75,17 @@ Application::Application(int& argc, char** argv, const QString& name) :
74
75
#endif
75
76
}
76
77
77
- #ifndef Q_OS_MAC
78
78
bool Application::isDarkTheme ()
79
79
{
80
- #ifdef Q_OS_WIN
81
- QSettings settings (
82
- " HKEY_CURRENT_USER\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Themes\\ Personalize" ,
83
- QSettings::NativeFormat);
84
- return settings.value (" AppsUseLightTheme" , 1 ).toInt () == 0 ;
80
+ #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
81
+ return styleHints ()->colorScheme () == Qt::ColorScheme::Dark;
85
82
#else
86
- // There is currently no straightforward way to detect dark mode in Linux, but this works for supported OS-s.
83
+ // There is currently no straightforward way to detect dark mode in Linux, but this works for
84
+ // supported OS-s.
87
85
static const bool isDarkTheme = [] {
88
86
QProcess p;
89
- p.start (QStringLiteral (" gsettings" ), {" get" , " org.gnome.desktop.interface" , " color-scheme" });
87
+ p.start (QStringLiteral (" gsettings" ),
88
+ {" get" , " org.gnome.desktop.interface" , " color-scheme" });
90
89
if (p.waitForFinished ()) {
91
90
return p.readAllStandardOutput ().contains (" dark" );
92
91
}
@@ -97,7 +96,6 @@ bool Application::isDarkTheme()
97
96
return isDarkTheme;
98
97
#endif
99
98
}
100
- #endif
101
99
102
100
void Application::loadTranslations (const QString& lang)
103
101
{
0 commit comments