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

@ -1073,8 +1073,8 @@ bool Application::createSetupWizard()
// set default theme after going into theme wizard
if (!validIcons)
settings()->set("IconTheme", QString("pe_colored"));
// if (!validWidgets)
// settings()->set("ApplicationTheme", QString("system"));
if (!validWidgets)
settings()->set("ApplicationTheme", QString("system"));
m_themeManager->applyCurrentlySelectedTheme(true);

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 "";
}

View File

@ -38,8 +38,7 @@
class SystemTheme : public ITheme {
public:
SystemTheme();
explicit SystemTheme(QString& themeName);
SystemTheme(QString& themeName, bool isSystemTheme = false);
virtual ~SystemTheme() {}
void apply(bool initial) override;

View File

@ -127,7 +127,7 @@ void ThemeManager::initializeWidgets()
themeDebugLog() << "System theme seems to be:" << currentlySelectedSystemTheme;
themeDebugLog() << "<> Initializing Widget Themes";
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>());
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>(currentlySelectedSystemTheme, true));
auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());