diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-01-18 02:45:04 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-01-18 02:48:29 +0100 |
commit | ceb5fc6d755cdcb263edc27386db38de9499048f (patch) | |
tree | fb1180717d1b10991e806acfd05c86a5080c1ec5 /application | |
parent | 201d4ac317cba2a7034cd08945b488bd46eb8ed3 (diff) | |
download | MultiMC-ceb5fc6d755cdcb263edc27386db38de9499048f.tar MultiMC-ceb5fc6d755cdcb263edc27386db38de9499048f.tar.gz MultiMC-ceb5fc6d755cdcb263edc27386db38de9499048f.tar.lz MultiMC-ceb5fc6d755cdcb263edc27386db38de9499048f.tar.xz MultiMC-ceb5fc6d755cdcb263edc27386db38de9499048f.zip |
GH-1790 do not apply system theme on launch if it is selected
This prevents some ugly colors to show up on macOS in most cases.
It still looks ugly right after you switch to the it though.
Diffstat (limited to 'application')
-rw-r--r-- | application/MultiMC.cpp | 19 | ||||
-rw-r--r-- | application/MultiMC.h | 2 | ||||
-rw-r--r-- | application/pages/global/MultiMCPage.cpp | 2 | ||||
-rw-r--r-- | application/themes/ITheme.cpp | 21 | ||||
-rw-r--r-- | application/themes/ITheme.h | 1 | ||||
-rw-r--r-- | application/themes/SystemTheme.cpp | 27 | ||||
-rw-r--r-- | application/themes/SystemTheme.h | 1 |
7 files changed, 44 insertions, 29 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 6c0c4e5e..2f752904 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -355,7 +355,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) connect(this, SIGNAL(aboutToQuit()), SLOT(onExit())); setIconTheme(settings()->get("IconTheme").toString()); - setApplicationTheme(settings()->get("ApplicationTheme").toString()); + setApplicationTheme(settings()->get("ApplicationTheme").toString(), true); initAnalytics(); @@ -868,27 +868,14 @@ void MultiMC::initThemes() insertTheme(new CustomTheme(darkTheme, "custom")); } -void MultiMC::setApplicationTheme(const QString& name) +void MultiMC::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; - setStyle(QStyleFactory::create(theme->qtTheme())); - if(theme->hasColorScheme()) - { - setPalette(theme->colorScheme()); - } - if(theme->hasStyleSheet()) - { - setStyleSheet(theme->appStyleSheet()); - } - else - { - setStyleSheet(QString()); - } - QDir::setSearchPaths("theme", theme->searchPaths()); + theme->apply(initial); } else { diff --git a/application/MultiMC.h b/application/MultiMC.h index 7600a120..98a6d780 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -87,7 +87,7 @@ public: std::vector<ITheme *> getValidApplicationThemes(); - void setApplicationTheme(const QString& name); + void setApplicationTheme(const QString& name, bool initial); // DownloadUpdateTask std::shared_ptr<UpdateChecker> updateChecker() diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp index 728f2dde..47d79d98 100644 --- a/application/pages/global/MultiMCPage.cpp +++ b/application/pages/global/MultiMCPage.cpp @@ -330,7 +330,7 @@ void MultiMCPage::applySettings() if(originalAppTheme != newAppTheme) { s->set("ApplicationTheme", newAppTheme); - MMC->setApplicationTheme(newAppTheme); + MMC->setApplicationTheme(newAppTheme, false); } // Console settings diff --git a/application/themes/ITheme.cpp b/application/themes/ITheme.cpp index aefcc381..b1cecf57 100644 --- a/application/themes/ITheme.cpp +++ b/application/themes/ITheme.cpp @@ -1,5 +1,26 @@ #include "ITheme.h" #include "rainbow.h" +#include <QStyleFactory> +#include <QDir> +#include "MultiMC.h" + +void ITheme::apply(bool) +{ + QApplication::setStyle(QStyleFactory::create(qtTheme())); + if(hasColorScheme()) + { + QApplication::setPalette(colorScheme()); + } + if(hasStyleSheet()) + { + MMC->setStyleSheet(appStyleSheet()); + } + else + { + MMC->setStyleSheet(QString()); + } + QDir::setSearchPaths("theme", searchPaths()); +} QPalette ITheme::fadeInactive(QPalette in, qreal bias, QColor color) { diff --git a/application/themes/ITheme.h b/application/themes/ITheme.h index 0360c445..b75001c2 100644 --- a/application/themes/ITheme.h +++ b/application/themes/ITheme.h @@ -8,6 +8,7 @@ class ITheme { public: virtual ~ITheme() {} + virtual void apply(bool initial); virtual QString id() = 0; virtual QString name() = 0; virtual bool hasStyleSheet() = 0; diff --git a/application/themes/SystemTheme.cpp b/application/themes/SystemTheme.cpp index 1e0146f7..069b0b1b 100644 --- a/application/themes/SystemTheme.cpp +++ b/application/themes/SystemTheme.cpp @@ -24,6 +24,16 @@ SystemTheme::SystemTheme() qWarning() << "System theme not found, defaulted to Fusion"; } +void SystemTheme::apply(bool initial) +{ + // if we are applying the system theme as the first theme, just don't touch anything. it's for the better... + if(initial) + { + return; + } + ITheme::apply(initial); +} + QString SystemTheme::id() { return "system"; @@ -50,14 +60,14 @@ QString SystemTheme::appStyleSheet() } double SystemTheme::fadeAmount() - { - return 0.5; - } +{ + return 0.5; +} QColor SystemTheme::fadeColor() - { - return QColor(128,128,128); - } +{ + return QColor(128,128,128); +} bool SystemTheme::hasStyleSheet() { @@ -66,10 +76,5 @@ bool SystemTheme::hasStyleSheet() bool SystemTheme::hasColorScheme() { - // FIXME: horrible hack to work around Qt's sketchy theming APIs -#if defined(Q_OS_LINUX) return true; -#else - return false; -#endif } diff --git a/application/themes/SystemTheme.h b/application/themes/SystemTheme.h index e8034efc..18291b68 100644 --- a/application/themes/SystemTheme.h +++ b/application/themes/SystemTheme.h @@ -7,6 +7,7 @@ class SystemTheme: public ITheme public: SystemTheme(); virtual ~SystemTheme() {} + void apply(bool initial) override; QString id() override; QString name() override; |