fix(SystemTheme): use default palette on all system themes

Signed-off-by: Seth Flynn <getchoo@tuta.io>
This commit is contained in:
Seth Flynn
2025-04-06 06:40:43 -04:00
parent c1b460fa05
commit e5861129ad
4 changed files with 22 additions and 10 deletions

View File

@ -40,20 +40,29 @@
#include "HintOverrideProxyStyle.h"
#include "ThemeManager.h"
SystemTheme::SystemTheme(const QString& styleName, bool isDefaultTheme)
// See https://github.com/MultiMC/Launcher/issues/1790
// or https://github.com/PrismLauncher/PrismLauncher/issues/490
static const QStringList S_NATIVE_STYLES{ "windows11", "windowsvista", "macos", "system", "windows" };
SystemTheme::SystemTheme(const QString& styleName, const QPalette& defaultPalette, bool isDefaultTheme)
{
m_themeName = isDefaultTheme ? "system" : styleName;
m_widgetTheme = styleName;
auto style = QStyleFactory::create(styleName);
m_colorPalette = style->standardPalette();
delete style;
// NOTE: SystemTheme is reconstructed on page refresh. We can't accurately determine the system palette here
// See also S_NATIVE_STYLES comment
if (S_NATIVE_STYLES.contains(m_themeName)) {
m_colorPalette = defaultPalette;
} else {
auto style = QStyleFactory::create(styleName);
m_colorPalette = style->standardPalette();
delete style;
}
}
void SystemTheme::apply(bool initial)
{
// See https://github.com/MultiMC/Launcher/issues/1790
// or https://github.com/PrismLauncher/PrismLauncher/issues/490
if (initial && m_themeName == "system") {
// See S_NATIVE_STYLES comment
if (initial && S_NATIVE_STYLES.contains(m_themeName)) {
QApplication::setStyle(new HintOverrideProxyStyle(QStyleFactory::create(qtTheme())));
return;
}