From bb63bf92f0bacccd9c72a10dd07009a26cace258 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 19 Sep 2025 20:39:31 +1000 Subject: [PATCH] Qt: Remove multiple sources of truth for dark theme --- src/duckstation-qt/qtthemes.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/duckstation-qt/qtthemes.cpp b/src/duckstation-qt/qtthemes.cpp index 00777bc55..b51c564a1 100644 --- a/src/duckstation-qt/qtthemes.cpp +++ b/src/duckstation-qt/qtthemes.cpp @@ -24,7 +24,6 @@ struct State QString unthemed_style_name; QPalette unthemed_palette; bool unthemed_style_name_set = false; - bool is_variable_color_style = false; }; } // namespace @@ -53,7 +52,6 @@ void QtHost::UpdateApplicationTheme() void QtHost::SetStyleFromSettings() { const TinyString theme = Host::GetBaseTinyStringSettingValue("UI", "Theme", QtHost::GetDefaultThemeName()); - s_state.is_variable_color_style = false; if (theme == "qdarkstyle") { @@ -68,11 +66,10 @@ void QtHost::SetStyleFromSettings() } else if (theme == "fusion") { - s_state.is_variable_color_style = true; qApp->setStyle(QStyleFactory::create("Fusion")); qApp->setPalette(s_state.unthemed_palette); qApp->setStyleSheet(QString()); - qApp->styleHints()->setColorScheme(Qt::ColorScheme::Unknown); + qApp->styleHints()->unsetColorScheme(); } else if (theme == "darkfusion") { @@ -479,35 +476,27 @@ QToolTip { #endif else { - s_state.is_variable_color_style = true; qApp->setStyle(s_state.unthemed_style_name); qApp->setPalette(s_state.unthemed_palette); qApp->setStyleSheet(QString()); - qApp->styleHints()->setColorScheme(Qt::ColorScheme::Unknown); + qApp->styleHints()->unsetColorScheme(); } } bool QtHost::IsDarkApplicationTheme() { - if (s_state.is_variable_color_style) - { - return (qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark); - } - else - { - const QPalette palette = qApp->palette(); - return (palette.windowText().color().value() > palette.window().color().value()); - } + return (qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark); } void QtHost::SetIconThemeFromStyle() { - const bool dark = IsDarkApplicationTheme(); - QIcon::setThemeName(dark ? QStringLiteral("white") : QStringLiteral("black")); + QIcon::setThemeName(IsDarkApplicationTheme() ? QStringLiteral("white") : QStringLiteral("black")); } const char* Host::GetDefaultFullscreenUITheme() { + using namespace QtHost; + const TinyString theme = Host::GetBaseTinyStringSettingValue("UI", "Theme", QtHost::GetDefaultThemeName()); if (theme == "cobaltsky") @@ -524,8 +513,6 @@ const char* Host::GetDefaultFullscreenUITheme() return "DarkRuby"; else if (theme == "AMOLED") return "AMOLED"; - else if (theme == "windowsvista") - return "Light"; - else // if (theme == "fusion" || theme == "darkfusion" || theme == "darkfusionblue" || theme == "darkruby") - return "Dark"; + else + return IsDarkApplicationTheme() ? "Dark" : "Light"; }