Merge pull request #2749 from TheKodeToad/theme-bugfixes
Fix system theme detection
This commit is contained in:
commit
44f589817f
@ -40,11 +40,11 @@
|
|||||||
#include "HintOverrideProxyStyle.h"
|
#include "HintOverrideProxyStyle.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
|
||||||
SystemTheme::SystemTheme(QString& styleName, bool isSystemTheme)
|
SystemTheme::SystemTheme(const QString& styleName, const QPalette& palette, bool isDefaultTheme)
|
||||||
{
|
{
|
||||||
themeName = isSystemTheme ? "system" : styleName;
|
themeName = isDefaultTheme ? "system" : styleName;
|
||||||
widgetTheme = styleName;
|
widgetTheme = styleName;
|
||||||
colorPalette = QApplication::palette();
|
colorPalette = palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTheme::apply(bool initial)
|
void SystemTheme::apply(bool initial)
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
class SystemTheme : public ITheme {
|
class SystemTheme : public ITheme {
|
||||||
public:
|
public:
|
||||||
SystemTheme(QString& themeName, bool isSystemTheme = false);
|
SystemTheme(const QString& styleName, const QPalette& palette, bool isDefaultTheme);
|
||||||
virtual ~SystemTheme() {}
|
virtual ~SystemTheme() {}
|
||||||
void apply(bool initial) override;
|
void apply(bool initial) override;
|
||||||
|
|
||||||
|
@ -36,6 +36,13 @@
|
|||||||
|
|
||||||
ThemeManager::ThemeManager()
|
ThemeManager::ThemeManager()
|
||||||
{
|
{
|
||||||
|
themeDebugLog() << "Determining System Widget Theme...";
|
||||||
|
const auto& style = QApplication::style();
|
||||||
|
m_defaultStyle = style->objectName();
|
||||||
|
themeDebugLog() << "System theme seems to be:" << m_defaultStyle;
|
||||||
|
|
||||||
|
m_defaultPalette = QApplication::palette();
|
||||||
|
|
||||||
initializeThemes();
|
initializeThemes();
|
||||||
initializeCatPacks();
|
initializeCatPacks();
|
||||||
}
|
}
|
||||||
@ -121,13 +128,8 @@ void ThemeManager::initializeIcons()
|
|||||||
|
|
||||||
void ThemeManager::initializeWidgets()
|
void ThemeManager::initializeWidgets()
|
||||||
{
|
{
|
||||||
themeDebugLog() << "Determining System Widget Theme...";
|
|
||||||
const auto& style = QApplication::style();
|
|
||||||
m_currentlySelectedSystemTheme = style->objectName();
|
|
||||||
themeDebugLog() << "System theme seems to be:" << m_currentlySelectedSystemTheme;
|
|
||||||
|
|
||||||
themeDebugLog() << "<> Initializing Widget Themes";
|
themeDebugLog() << "<> Initializing Widget Themes";
|
||||||
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>(m_currentlySelectedSystemTheme, true));
|
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>(m_defaultStyle, m_defaultPalette, 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>());
|
||||||
@ -140,7 +142,7 @@ void ThemeManager::initializeWidgets()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
themeDebugLog() << "Loading System Theme:" << addTheme(std::make_unique<SystemTheme>(st));
|
themeDebugLog() << "Loading System Theme:" << addTheme(std::make_unique<SystemTheme>(st, m_defaultPalette, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need some way to differentiate same name themes in different subdirectories
|
// TODO: need some way to differentiate same name themes in different subdirectories
|
||||||
@ -260,7 +262,7 @@ void ThemeManager::applyCurrentlySelectedTheme(bool initial)
|
|||||||
themeDebugLog() << "<> Icon theme set.";
|
themeDebugLog() << "<> Icon theme set.";
|
||||||
auto applicationTheme = settings->get("ApplicationTheme").toString();
|
auto applicationTheme = settings->get("ApplicationTheme").toString();
|
||||||
if (applicationTheme == "") {
|
if (applicationTheme == "") {
|
||||||
applicationTheme = m_currentlySelectedSystemTheme;
|
applicationTheme = m_defaultStyle;
|
||||||
}
|
}
|
||||||
setApplicationTheme(applicationTheme, initial);
|
setApplicationTheme(applicationTheme, initial);
|
||||||
themeDebugLog() << "<> Application theme set.";
|
themeDebugLog() << "<> Application theme set.";
|
||||||
|
@ -66,7 +66,8 @@ class ThemeManager {
|
|||||||
QDir m_applicationThemeFolder{ "themes" };
|
QDir m_applicationThemeFolder{ "themes" };
|
||||||
QDir m_catPacksFolder{ "catpacks" };
|
QDir m_catPacksFolder{ "catpacks" };
|
||||||
std::map<QString, std::unique_ptr<CatPack>> m_catPacks;
|
std::map<QString, std::unique_ptr<CatPack>> m_catPacks;
|
||||||
QString m_currentlySelectedSystemTheme;
|
QString m_defaultStyle;
|
||||||
|
QPalette m_defaultPalette;
|
||||||
LogColors m_logColors;
|
LogColors m_logColors;
|
||||||
|
|
||||||
void initializeThemes();
|
void initializeThemes();
|
||||||
|
Loading…
Reference in New Issue
Block a user