Merge pull request #13776 from jordan-woyak/win-dark-mode-styles

DolphinQt: Fix Windows dark theme when using external stylesheets.
This commit is contained in:
Admiral H. Curtiss
2025-08-01 21:26:17 +02:00
committed by GitHub

View File

@ -175,17 +175,18 @@ void Settings::ApplyStyle()
}
#ifdef _WIN32
if (stylesheet_contents.isEmpty())
{
// No theme selected or found. Usually we would just fallthrough and set an empty stylesheet
// which would select Qt's default theme, but unlike other OSes we don't automatically get a
// default dark theme on Windows when the user has selected dark mode in the Windows settings.
// So manually check if the user wants dark mode and, if yes, load our embedded dark theme.
// Unlike other OSes we don't automatically get a default dark theme on Windows.
// We manually load a dark palette for our included "(Dark)" style,
// and for *any* external style when the system is in "Dark" mode.
// Unfortunately it doesn't seem trivial to load a palette based on the stylesheet itself.
if (style_type == StyleType::Dark || (style_type != StyleType::Light && IsSystemDark()))
{
if (stylesheet_contents.isEmpty())
{
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
if (file.open(QFile::ReadOnly))
stylesheet_contents = QString::fromUtf8(file.readAll().data());
}
QPalette palette = qApp->style()->standardPalette();
palette.setColor(QPalette::Window, QColor(32, 32, 32));
@ -209,7 +210,6 @@ void Settings::ApplyStyle()
if (s_default_palette)
qApp->setPalette(*s_default_palette);
}
}
#endif
// Define tooltips style if not already defined