Qt: Add Classic Windows as theme option

But it'll bug out when switching between windows11/windowsvista.

Restart to fix.
This commit is contained in:
JordanTheToaster 2024-04-30 13:05:26 +01:00 committed by Connor McLaughlin
parent b67b555617
commit ce734f8a0d
2 changed files with 17 additions and 6 deletions

View File

@ -11,6 +11,9 @@
const char* InterfaceSettingsWidget::THEME_NAMES[] = { const char* InterfaceSettingsWidget::THEME_NAMES[] = {
QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Native"), QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Native"),
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated. //: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
#ifdef _WIN32
QT_TRANSLATE_NOOP("MainWindow", "Classic Windows"),
#endif
QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Fusion [Light/Dark]"), QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Fusion [Light/Dark]"),
//: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated. //: Ignore what Crowdin says in this string about "[Light]/[Dark]" being untouchable here, these are not variables in this case and must be translated.
QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Dark Fusion (Gray) [Dark]"), QT_TRANSLATE_NOOP("InterfaceSettingsWidget", "Dark Fusion (Gray) [Dark]"),
@ -42,6 +45,9 @@ const char* InterfaceSettingsWidget::THEME_NAMES[] = {
const char* InterfaceSettingsWidget::THEME_VALUES[] = { const char* InterfaceSettingsWidget::THEME_VALUES[] = {
"", "",
#ifdef _WIN32
"windowsvista",
#endif
"fusion", "fusion",
"darkfusion", "darkfusion",
"darkfusionblue", "darkfusionblue",

View File

@ -47,14 +47,22 @@ void QtHost::SetStyleFromSettings()
{ {
const std::string theme(Host::GetBaseStringSettingValue("UI", "Theme", GetDefaultThemeName())); const std::string theme(Host::GetBaseStringSettingValue("UI", "Theme", GetDefaultThemeName()));
// setPalette() shouldn't be necessary, as the documentation claims that setStyle() resets the palette, but it
// is here, to work around a bug in 6.4.x and 6.5.x where the palette doesn't restore after changing themes.
qApp->setPalette(QPalette());
if (theme == "fusion") if (theme == "fusion")
{ {
// setPalette() shouldn't be necessary, as the documentation claims that setStyle() resets the palette, but it
// is here, to work around a bug in 6.4.x and 6.5.x where the palette doesn't restore after changing themes.
qApp->setPalette(QPalette());
qApp->setStyle(QStyleFactory::create("Fusion")); qApp->setStyle(QStyleFactory::create("Fusion"));
qApp->setStyleSheet(QString()); qApp->setStyleSheet(QString());
} }
#ifdef _WIN32
else if (theme == "windowsvista")
{
qApp->setStyle(QStyleFactory::create("windowsvista"));
qApp->setStyleSheet(QString());
}
#endif
else if (theme == "darkfusion") else if (theme == "darkfusion")
{ {
// adapted from https://gist.github.com/QuantumCD/6245215 // adapted from https://gist.github.com/QuantumCD/6245215
@ -481,9 +489,6 @@ void QtHost::SetStyleFromSettings()
} }
else else
{ {
// setPalette() shouldn't be necessary, as the documentation claims that setStyle() resets the palette, but it
// is here, to work around a bug in 6.4.x and 6.5.x where the palette doesn't restore after changing themes.
qApp->setPalette(QPalette());
qApp->setStyle(s_unthemed_style_name); qApp->setStyle(s_unthemed_style_name);
qApp->setStyleSheet(QString()); qApp->setStyleSheet(QString());
} }