mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-03 11:38:49 -06:00
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:
@ -175,40 +175,40 @@ void Settings::ApplyStyle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (stylesheet_contents.isEmpty())
|
// 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()))
|
||||||
{
|
{
|
||||||
// No theme selected or found. Usually we would just fallthrough and set an empty stylesheet
|
if (stylesheet_contents.isEmpty())
|
||||||
// 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.
|
|
||||||
if (style_type == StyleType::Dark || (style_type != StyleType::Light && IsSystemDark()))
|
|
||||||
{
|
{
|
||||||
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
|
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
|
||||||
if (file.open(QFile::ReadOnly))
|
if (file.open(QFile::ReadOnly))
|
||||||
stylesheet_contents = QString::fromUtf8(file.readAll().data());
|
stylesheet_contents = QString::fromUtf8(file.readAll().data());
|
||||||
|
}
|
||||||
|
|
||||||
QPalette palette = qApp->style()->standardPalette();
|
QPalette palette = qApp->style()->standardPalette();
|
||||||
palette.setColor(QPalette::Window, QColor(32, 32, 32));
|
palette.setColor(QPalette::Window, QColor(32, 32, 32));
|
||||||
palette.setColor(QPalette::WindowText, QColor(220, 220, 220));
|
palette.setColor(QPalette::WindowText, QColor(220, 220, 220));
|
||||||
palette.setColor(QPalette::Base, QColor(32, 32, 32));
|
palette.setColor(QPalette::Base, QColor(32, 32, 32));
|
||||||
palette.setColor(QPalette::AlternateBase, QColor(48, 48, 48));
|
palette.setColor(QPalette::AlternateBase, QColor(48, 48, 48));
|
||||||
palette.setColor(QPalette::PlaceholderText, QColor(126, 126, 126));
|
palette.setColor(QPalette::PlaceholderText, QColor(126, 126, 126));
|
||||||
palette.setColor(QPalette::Text, QColor(220, 220, 220));
|
palette.setColor(QPalette::Text, QColor(220, 220, 220));
|
||||||
palette.setColor(QPalette::Button, QColor(48, 48, 48));
|
palette.setColor(QPalette::Button, QColor(48, 48, 48));
|
||||||
palette.setColor(QPalette::ButtonText, QColor(220, 220, 220));
|
palette.setColor(QPalette::ButtonText, QColor(220, 220, 220));
|
||||||
palette.setColor(QPalette::BrightText, QColor(255, 255, 255));
|
palette.setColor(QPalette::BrightText, QColor(255, 255, 255));
|
||||||
palette.setColor(QPalette::Highlight, QColor(0, 120, 215));
|
palette.setColor(QPalette::Highlight, QColor(0, 120, 215));
|
||||||
palette.setColor(QPalette::HighlightedText, QColor(255, 255, 255));
|
palette.setColor(QPalette::HighlightedText, QColor(255, 255, 255));
|
||||||
palette.setColor(QPalette::Link, QColor(100, 160, 220));
|
palette.setColor(QPalette::Link, QColor(100, 160, 220));
|
||||||
palette.setColor(QPalette::LinkVisited, QColor(100, 160, 220));
|
palette.setColor(QPalette::LinkVisited, QColor(100, 160, 220));
|
||||||
qApp->setPalette(palette);
|
qApp->setPalette(palette);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// reset any palette changes that may exist from a previously set dark mode
|
// reset any palette changes that may exist from a previously set dark mode
|
||||||
if (s_default_palette)
|
if (s_default_palette)
|
||||||
qApp->setPalette(*s_default_palette);
|
qApp->setPalette(*s_default_palette);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user