Qt can ignore OS settings, so, we must check palette settings instead.

This commit is contained in:
Roman Telezhynskyi 2023-08-09 15:53:00 +03:00
parent 14ec95ee9f
commit aea4fe3cee

View File

@ -280,20 +280,11 @@ auto VTheme::IsInDarkTheme() -> bool
{ {
if (NativeDarkThemeAvailable()) if (NativeDarkThemeAvailable())
{ {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
QStyleHints *hints = QGuiApplication::styleHints();
return hints->colorScheme() == Qt::ColorScheme::Dark;
#else
#if defined(Q_OS_MACX) #if defined(Q_OS_MACX)
return NSMacIsInDarkTheme(); return NSMacIsInDarkTheme();
#elif defined(Q_OS_WIN) #else
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
QSettings::NativeFormat);
return settings.value("AppsUseLightTheme", 1).toInt() == 0;
#elif defined(Q_OS_LINUX)
return ShouldApplyDarkTheme(); return ShouldApplyDarkTheme();
#endif #endif
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
} }
return false; return false;