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
|
// set default theme after going into theme wizard
|
||||||
if (!validIcons)
|
if (!validIcons)
|
||||||
settings()->set("IconTheme", QString("pe_colored"));
|
settings()->set("IconTheme", QString("pe_colored"));
|
||||||
// if (!validWidgets)
|
if (!validWidgets)
|
||||||
// settings()->set("ApplicationTheme", QString("system"));
|
settings()->set("ApplicationTheme", QString("system"));
|
||||||
|
|
||||||
m_themeManager->applyCurrentlySelectedTheme(true);
|
m_themeManager->applyCurrentlySelectedTheme(true);
|
||||||
|
|
||||||
|
@ -40,31 +40,9 @@
|
|||||||
#include "HintOverrideProxyStyle.h"
|
#include "HintOverrideProxyStyle.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
|
||||||
SystemTheme::SystemTheme()
|
SystemTheme::SystemTheme(QString& styleName, bool isSystemTheme)
|
||||||
{
|
{
|
||||||
themeName = QObject::tr("System");
|
themeName = isSystemTheme ? "system" : styleName;
|
||||||
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;
|
|
||||||
widgetTheme = styleName;
|
widgetTheme = styleName;
|
||||||
colorPalette = QApplication::palette();
|
colorPalette = QApplication::palette();
|
||||||
}
|
}
|
||||||
@ -94,6 +72,8 @@ QString SystemTheme::name()
|
|||||||
return QObject::tr("Windows 9x");
|
return QObject::tr("Windows 9x");
|
||||||
} else if (themeName.toLower() == "windows11") {
|
} else if (themeName.toLower() == "windows11") {
|
||||||
return QObject::tr("Windows 11");
|
return QObject::tr("Windows 11");
|
||||||
|
} else if (themeName.toLower() == "system") {
|
||||||
|
return QObject::tr("System");
|
||||||
} else {
|
} else {
|
||||||
return themeName;
|
return themeName;
|
||||||
}
|
}
|
||||||
@ -110,7 +90,7 @@ QString SystemTheme::tooltip()
|
|||||||
} else if (themeName.toLower() == "fusion") {
|
} else if (themeName.toLower() == "fusion") {
|
||||||
return QObject::tr("The default Qt widget style");
|
return QObject::tr("The default Qt widget style");
|
||||||
} else if (themeName.toLower() == "system") {
|
} else if (themeName.toLower() == "system") {
|
||||||
return QObject::tr("Your current system theme") + " (" + widgetTheme + ")";
|
return QObject::tr("Your current system theme");
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@
|
|||||||
|
|
||||||
class SystemTheme : public ITheme {
|
class SystemTheme : public ITheme {
|
||||||
public:
|
public:
|
||||||
SystemTheme();
|
SystemTheme(QString& themeName, bool isSystemTheme = false);
|
||||||
explicit SystemTheme(QString& themeName);
|
|
||||||
virtual ~SystemTheme() {}
|
virtual ~SystemTheme() {}
|
||||||
void apply(bool initial) override;
|
void apply(bool initial) override;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void ThemeManager::initializeWidgets()
|
|||||||
themeDebugLog() << "System theme seems to be:" << currentlySelectedSystemTheme;
|
themeDebugLog() << "System theme seems to be:" << currentlySelectedSystemTheme;
|
||||||
|
|
||||||
themeDebugLog() << "<> Initializing Widget Themes";
|
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>());
|
auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
|
||||||
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
|
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
|
||||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
|
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
|
||||||
|
Loading…
Reference in New Issue
Block a user