diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 5bc3e79c..8e924d98 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()); initAnalytics(); @@ -876,9 +876,19 @@ void MultiMC::setApplicationTheme(const QString& name) { auto & theme = (*themeIter).second; setStyle(QStyleFactory::create(theme->qtTheme())); - setPalette(theme->colorScheme()); + if(theme->hasColorScheme()) + { + setPalette(theme->colorScheme()); + } + if(theme->hasStyleSheet()) + { + setStyleSheet(theme->appStyleSheet()); + } + else + { + setStyleSheet(QString()); + } QDir::setSearchPaths("theme", theme->searchPaths()); - setStyleSheet(theme->appStyleSheet()); } else { diff --git a/application/themes/BrightTheme.cpp b/application/themes/BrightTheme.cpp index a7cfa010..2763c982 100644 --- a/application/themes/BrightTheme.cpp +++ b/application/themes/BrightTheme.cpp @@ -10,6 +10,11 @@ QString BrightTheme::name() return QObject::tr("Bright"); } +bool BrightTheme::hasColorScheme() +{ + return true; +} + QPalette BrightTheme::colorScheme() { QPalette brightPalette; @@ -39,6 +44,11 @@ QColor BrightTheme::fadeColor() return QColor(239,240,241); } +bool BrightTheme::hasStyleSheet() +{ + return false; +} + QString BrightTheme::appStyleSheet() { return QString(); diff --git a/application/themes/BrightTheme.h b/application/themes/BrightTheme.h index 814aa6de..31b31b2d 100644 --- a/application/themes/BrightTheme.h +++ b/application/themes/BrightTheme.h @@ -9,7 +9,9 @@ public: QString id() override; QString name() override; + bool hasStyleSheet() override; QString appStyleSheet() override; + bool hasColorScheme() override; QPalette colorScheme() override; double fadeAmount() override; QColor fadeColor() override; diff --git a/application/themes/CustomTheme.cpp b/application/themes/CustomTheme.cpp index 70d55211..a6c7bf8c 100644 --- a/application/themes/CustomTheme.cpp +++ b/application/themes/CustomTheme.cpp @@ -208,11 +208,21 @@ QString CustomTheme::name() return m_name; } +bool CustomTheme::hasColorScheme() +{ + return true; +} + QPalette CustomTheme::colorScheme() { return m_palette; } +bool CustomTheme::hasStyleSheet() +{ + return true; +} + QString CustomTheme::appStyleSheet() { return m_styleSheet; diff --git a/application/themes/CustomTheme.h b/application/themes/CustomTheme.h index e5d3625c..9023b13e 100644 --- a/application/themes/CustomTheme.h +++ b/application/themes/CustomTheme.h @@ -10,7 +10,9 @@ public: QString id() override; QString name() override; + bool hasStyleSheet() override; QString appStyleSheet() override; + bool hasColorScheme() override; QPalette colorScheme() override; double fadeAmount() override; QColor fadeColor() override; diff --git a/application/themes/DarkTheme.cpp b/application/themes/DarkTheme.cpp index 2bcb4cd7..cf4a81e1 100644 --- a/application/themes/DarkTheme.cpp +++ b/application/themes/DarkTheme.cpp @@ -10,6 +10,11 @@ QString DarkTheme::name() return QObject::tr("Dark"); } +bool DarkTheme::hasColorScheme() +{ + return true; +} + QPalette DarkTheme::colorScheme() { QPalette darkPalette; @@ -39,6 +44,11 @@ QColor DarkTheme::fadeColor() return QColor(49,54,59); } +bool DarkTheme::hasStyleSheet() +{ + return true; +} + QString DarkTheme::appStyleSheet() { return "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }"; diff --git a/application/themes/DarkTheme.h b/application/themes/DarkTheme.h index 142f7860..f3c18e22 100644 --- a/application/themes/DarkTheme.h +++ b/application/themes/DarkTheme.h @@ -9,7 +9,9 @@ public: QString id() override; QString name() override; + bool hasStyleSheet() override; QString appStyleSheet() override; + bool hasColorScheme() override; QPalette colorScheme() override; double fadeAmount() override; QColor fadeColor() override; diff --git a/application/themes/ITheme.h b/application/themes/ITheme.h index 8070efb1..0360c445 100644 --- a/application/themes/ITheme.h +++ b/application/themes/ITheme.h @@ -2,14 +2,18 @@ #include #include +class QStyle; + class ITheme { public: virtual ~ITheme() {} virtual QString id() = 0; virtual QString name() = 0; + virtual bool hasStyleSheet() = 0; virtual QString appStyleSheet() = 0; virtual QString qtTheme() = 0; + virtual bool hasColorScheme() = 0; virtual QPalette colorScheme() = 0; virtual QColor fadeColor() = 0; virtual double fadeAmount() = 0; diff --git a/application/themes/SystemTheme.cpp b/application/themes/SystemTheme.cpp index f7a68061..1e0146f7 100644 --- a/application/themes/SystemTheme.cpp +++ b/application/themes/SystemTheme.cpp @@ -21,6 +21,7 @@ SystemTheme::SystemTheme() } // fall back to fusion if we can't find the current theme. systemTheme = "Fusion"; + qWarning() << "System theme not found, defaulted to Fusion"; } QString SystemTheme::id() @@ -57,3 +58,18 @@ QColor SystemTheme::fadeColor() { return QColor(128,128,128); } + +bool SystemTheme::hasStyleSheet() +{ + return false; +} + +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 e4a84bca..e8034efc 100644 --- a/application/themes/SystemTheme.h +++ b/application/themes/SystemTheme.h @@ -11,7 +11,9 @@ public: QString id() override; QString name() override; QString qtTheme() override; + bool hasStyleSheet() override; QString appStyleSheet() override; + bool hasColorScheme() override; QPalette colorScheme() override; double fadeAmount() override; QColor fadeColor() override;