diff --git a/cockatrice/src/interface/theme_manager.cpp b/cockatrice/src/interface/theme_manager.cpp index 5809ce350..6a5514fb1 100644 --- a/cockatrice/src/interface/theme_manager.cpp +++ b/cockatrice/src/interface/theme_manager.cpp @@ -108,6 +108,31 @@ void ThemeManager::ensureThemeDirectoryExists() } } +bool ThemeManager::isDarkMode() +{ + auto themeName = SettingsCache::instance().getThemeName(); + // Explicit Dark Mode + if (themeName == FUSION_THEME_NAME_LIGHT || themeName.endsWith("(Light)")) { + return false; + } + // Explicit Light Mode + if (themeName == FUSION_THEME_NAME_DARK || themeName.endsWith("(Dark)")) { + return true; + } + + // Auto detection on compatible Qt versions +#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) + if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark && + (themeName == NONE_THEME_NAME || themeName == FUSION_THEME_NAME || themeName.endsWith("(System Default)"))) { + return true; + } else { + return false; + } +#endif + // Default to light mode + return false; +} + QStringMap &ThemeManager::getAvailableThemes() { QDir dir; diff --git a/cockatrice/src/interface/theme_manager.h b/cockatrice/src/interface/theme_manager.h index d942f0fef..c039c5728 100644 --- a/cockatrice/src/interface/theme_manager.h +++ b/cockatrice/src/interface/theme_manager.h @@ -50,6 +50,7 @@ private: protected: void ensureThemeDirectoryExists(); + bool isDarkMode(); QBrush loadBrush(QString fileName, QColor fallbackColor); QBrush loadExtraBrush(QString fileName, QBrush &fallbackBrush);