fix system theme

Signed-off-by: Tayou <git@tayou.org>
This commit is contained in:
Tayou
2024-07-01 23:05:54 +02:00
parent d70be5121c
commit dbcfefca1b
4 changed files with 9 additions and 30 deletions

View File

@ -40,31 +40,9 @@
#include "HintOverrideProxyStyle.h"
#include "ThemeManager.h"
SystemTheme::SystemTheme()
SystemTheme::SystemTheme(QString& styleName, bool isSystemTheme)
{
themeName = QObject::tr("System");
themeDebugLog() << "Determining System Theme...";
const auto& style = QApplication::style();
colorPalette = QApplication::palette();
QString lowerThemeName = style->objectName();
themeDebugLog() << "System theme seems to be:" << lowerThemeName;
QStringList styles = QStyleFactory::keys();
for (auto& st : styles) {
themeDebugLog() << "Considering theme from theme factory:" << st.toLower();
if (st.toLower() == lowerThemeName) {
widgetTheme = st;
themeDebugLog() << "System theme has been determined to be:" << widgetTheme;
return;
}
}
// fall back to fusion if we can't find the current theme.
widgetTheme = "Fusion";
themeDebugLog() << "System theme not found, defaulted to Fusion";
}
SystemTheme::SystemTheme(QString& styleName)
{
themeName = styleName;
themeName = isSystemTheme ? "system" : styleName;
widgetTheme = styleName;
colorPalette = QApplication::palette();
}
@ -94,6 +72,8 @@ QString SystemTheme::name()
return QObject::tr("Windows 9x");
} else if (themeName.toLower() == "windows11") {
return QObject::tr("Windows 11");
} else if (themeName.toLower() == "system") {
return QObject::tr("System");
} else {
return themeName;
}
@ -110,7 +90,7 @@ QString SystemTheme::tooltip()
} else if (themeName.toLower() == "fusion") {
return QObject::tr("The default Qt widget style");
} else if (themeName.toLower() == "system") {
return QObject::tr("Your current system theme") + " (" + widgetTheme + ")";
return QObject::tr("Your current system theme");
} else {
return "";
}