summaryrefslogtreecommitdiffstats
path: root/application/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-10-21 09:07:26 +0200
committerPetr Mrázek <peterix@gmail.com>2016-10-21 09:07:26 +0200
commit872cfe036d9472739939ad401dbe9511193d62ca (patch)
tree2d8356848c4955b09d66d6fc96924cc4da85ccb9 /application/MultiMC.cpp
parentf07496ac6d42986266f3bff5093fa0009521ecd5 (diff)
downloadMultiMC-872cfe036d9472739939ad401dbe9511193d62ca.tar
MultiMC-872cfe036d9472739939ad401dbe9511193d62ca.tar.gz
MultiMC-872cfe036d9472739939ad401dbe9511193d62ca.tar.lz
MultiMC-872cfe036d9472739939ad401dbe9511193d62ca.tar.xz
MultiMC-872cfe036d9472739939ad401dbe9511193d62ca.zip
GH-903 simple theme switching and dark theme
Diffstat (limited to 'application/MultiMC.cpp')
-rw-r--r--application/MultiMC.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index f53d05e1..093d03b4 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -9,6 +9,10 @@
#include "pages/global/AccountListPage.h"
#include "pages/global/PasteEEPage.h"
+#include "themes/ITheme.h"
+#include "themes/SystemTheme.h"
+#include "themes/DarkTheme.h"
+
#include <iostream>
#include <QDir>
#include <QFileInfo>
@@ -241,6 +245,9 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar
// load icons
initIcons();
+ // load themes
+ initThemes();
+
// and instances
auto InstDirSetting = m_settings->getSetting("InstanceDir");
// instance path: check for problems with '!' in instance path and warn the user in the log
@@ -442,7 +449,10 @@ void MultiMC::initGlobalSettings(bool test_mode)
// Updates
m_settings->registerSetting("UpdateChannel", BuildConfig.VERSION_CHANNEL);
m_settings->registerSetting("AutoUpdate", true);
+
+ // Theming
m_settings->registerSetting("IconTheme", QString("multimc"));
+ m_settings->registerSetting("ApplicationTheme", QString("system"));
// Notifications
m_settings->registerSetting("ShownNotifications", QString());
@@ -943,6 +953,45 @@ FAILED:
QMessageBox::critical(nullptr, tr("Update failed!"), msg);
}
+std::vector<ITheme *> MultiMC::getValidApplicationThemes()
+{
+ std::vector<ITheme *> ret;
+ auto iter = m_themes.cbegin();
+ while (iter != m_themes.cend())
+ {
+ ret.push_back((*iter).second.get());
+ iter++;
+ }
+ return ret;
+}
+
+void MultiMC::initThemes()
+{
+ auto insertTheme = [this](ITheme * theme)
+ {
+ m_themes.insert(std::make_pair(theme->id(), std::unique_ptr<ITheme>(theme)));
+ };
+ insertTheme(new SystemTheme());
+ insertTheme(new DarkTheme());
+}
+
+void MultiMC::setApplicationTheme(const QString& name)
+{
+ auto systemPalette = qApp->palette();
+ auto themeIter = m_themes.find(name);
+ if(themeIter != m_themes.end())
+ {
+ auto & theme = (*themeIter).second;
+ setPalette(theme->colorScheme());
+ setStyleSheet(theme->appStyleSheet());
+ //setStyle(QStyleFactory::create("Fusion"));
+ }
+ else
+ {
+ qWarning() << "Tried to set invalid theme:" << name;
+ }
+}
+
void MultiMC::setIconTheme(const QString& name)
{
XdgIcon::setThemeName(name);