fix: do not apply system theme on launch
Closes PrismLauncher/PrismLauncher#490 Regression introduced by PrismLauncher/PrismLauncher#249 Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
ed085630db
commit
a988111507
@ -830,9 +830,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
applyCurrentlySelectedTheme();
|
||||
}
|
||||
applyCurrentlySelectedTheme(true);
|
||||
|
||||
updateCapabilities();
|
||||
|
||||
@ -1107,9 +1105,9 @@ QList<ITheme*> Application::getValidApplicationThemes()
|
||||
return m_themeManager->getValidApplicationThemes();
|
||||
}
|
||||
|
||||
void Application::applyCurrentlySelectedTheme()
|
||||
void Application::applyCurrentlySelectedTheme(bool initial)
|
||||
{
|
||||
m_themeManager->applyCurrentlySelectedTheme();
|
||||
m_themeManager->applyCurrentlySelectedTheme(initial);
|
||||
}
|
||||
|
||||
void Application::setApplicationTheme(const QString& name)
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
|
||||
void setIconTheme(const QString& name);
|
||||
|
||||
void applyCurrentlySelectedTheme();
|
||||
void applyCurrentlySelectedTheme(bool initial = false);
|
||||
|
||||
QList<ITheme*> getValidApplicationThemes();
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <QDir>
|
||||
#include "Application.h"
|
||||
|
||||
void ITheme::apply()
|
||||
void ITheme::apply(bool)
|
||||
{
|
||||
APPLICATION->setStyleSheet(QString());
|
||||
QApplication::setStyle(QStyleFactory::create(qtTheme()));
|
||||
|
@ -41,7 +41,7 @@ class QStyle;
|
||||
class ITheme {
|
||||
public:
|
||||
virtual ~ITheme() {}
|
||||
virtual void apply();
|
||||
virtual void apply(bool initial);
|
||||
virtual QString id() = 0;
|
||||
virtual QString name() = 0;
|
||||
virtual bool hasStyleSheet() = 0;
|
||||
|
@ -60,9 +60,13 @@ SystemTheme::SystemTheme()
|
||||
themeDebugLog() << "System theme not found, defaulted to Fusion";
|
||||
}
|
||||
|
||||
void SystemTheme::apply()
|
||||
void SystemTheme::apply(bool initial)
|
||||
{
|
||||
ITheme::apply();
|
||||
// See https://github.com/MultiMC/Launcher/issues/1790
|
||||
// or https://github.com/PrismLauncher/PrismLauncher/issues/490
|
||||
if (initial)
|
||||
return;
|
||||
ITheme::apply(initial);
|
||||
}
|
||||
|
||||
QString SystemTheme::id()
|
||||
|
@ -40,7 +40,7 @@ class SystemTheme : public ITheme {
|
||||
public:
|
||||
SystemTheme();
|
||||
virtual ~SystemTheme() {}
|
||||
void apply() override;
|
||||
void apply(bool initial) override;
|
||||
|
||||
QString id() override;
|
||||
QString name() override;
|
||||
|
@ -116,22 +116,22 @@ void ThemeManager::setIconTheme(const QString& name)
|
||||
QIcon::setThemeName(name);
|
||||
}
|
||||
|
||||
void ThemeManager::applyCurrentlySelectedTheme()
|
||||
void ThemeManager::applyCurrentlySelectedTheme(bool initial)
|
||||
{
|
||||
setIconTheme(APPLICATION->settings()->get("IconTheme").toString());
|
||||
themeDebugLog() << "<> Icon theme set.";
|
||||
setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString());
|
||||
setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString(), initial);
|
||||
themeDebugLog() << "<> Application theme set.";
|
||||
}
|
||||
|
||||
void ThemeManager::setApplicationTheme(const QString& name)
|
||||
void ThemeManager::setApplicationTheme(const QString& name, bool initial)
|
||||
{
|
||||
auto systemPalette = qApp->palette();
|
||||
auto themeIter = m_themes.find(name);
|
||||
if (themeIter != m_themes.end()) {
|
||||
auto& theme = themeIter->second;
|
||||
themeDebugLog() << "applying theme" << theme->name();
|
||||
theme->apply();
|
||||
theme->apply(initial);
|
||||
} else {
|
||||
themeWarningLog() << "Tried to set invalid theme:" << name;
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ class ThemeManager {
|
||||
|
||||
QList<ITheme*> getValidApplicationThemes();
|
||||
void setIconTheme(const QString& name);
|
||||
void applyCurrentlySelectedTheme();
|
||||
void setApplicationTheme(const QString& name);
|
||||
void applyCurrentlySelectedTheme(bool initial = false);
|
||||
void setApplicationTheme(const QString& name, bool initial = false);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cat based on selected cat and with events (Birthday, XMas, etc.)
|
||||
|
Loading…
Reference in New Issue
Block a user