fix system theme
Signed-off-by: Tayou <git@tayou.org>
This commit is contained in:
parent
d70be5121c
commit
dbcfefca1b
@ -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);
|
||||
|
||||
|
@ -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 "";
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>());
|
||||
|
Loading…
Reference in New Issue
Block a user