diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-11-06 05:48:52 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-11-06 05:48:52 +0100 |
commit | 37cc59c04d0573a42d67242135495c0a0729f965 (patch) | |
tree | 35cd453c9d35022dd31f5c2769740b5b80d4ba9c /application | |
parent | bc753859b5ab5d1402940024c0478548165b57f8 (diff) | |
download | MultiMC-37cc59c04d0573a42d67242135495c0a0729f965.tar MultiMC-37cc59c04d0573a42d67242135495c0a0729f965.tar.gz MultiMC-37cc59c04d0573a42d67242135495c0a0729f965.tar.lz MultiMC-37cc59c04d0573a42d67242135495c0a0729f965.tar.xz MultiMC-37cc59c04d0573a42d67242135495c0a0729f965.zip |
GH-378 add a resource search path to custom themes
This allows adding images and other bits and pieces to themes.
Diffstat (limited to 'application')
-rw-r--r-- | application/MultiMC.cpp | 1 | ||||
-rw-r--r-- | application/themes/CustomTheme.cpp | 9 | ||||
-rw-r--r-- | application/themes/CustomTheme.h | 1 | ||||
-rw-r--r-- | application/themes/ITheme.h | 4 |
4 files changed, 14 insertions, 1 deletions
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 9ccd0895..40a11a26 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -1027,6 +1027,7 @@ void MultiMC::setApplicationTheme(const QString& name) auto & theme = (*themeIter).second; setStyle(QStyleFactory::create(theme->qtTheme())); setPalette(theme->colorScheme()); + QDir::setSearchPaths("theme", theme->searchPaths()); setStyleSheet(theme->appStyleSheet()); } else diff --git a/application/themes/CustomTheme.cpp b/application/themes/CustomTheme.cpp index a3141573..70d55211 100644 --- a/application/themes/CustomTheme.cpp +++ b/application/themes/CustomTheme.cpp @@ -128,10 +128,11 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QString folder) { m_id = folder; QString path = FS::PathCombine("themes", m_id); + QString pathResources = FS::PathCombine("themes", m_id, "resources"); qDebug() << "Loading theme" << m_id; - if(!FS::ensureFolderPathExists(path)) + if(!FS::ensureFolderPathExists(path) || !FS::ensureFolderPathExists(pathResources)) { qWarning() << "couldn't create folder for theme!"; m_palette = baseTheme->colorScheme(); @@ -191,6 +192,12 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QString folder) } } +QStringList CustomTheme::searchPaths() +{ + return { FS::PathCombine("themes", m_id, "resources") }; +} + + QString CustomTheme::id() { return m_id; diff --git a/application/themes/CustomTheme.h b/application/themes/CustomTheme.h index 94cd10a5..e5d3625c 100644 --- a/application/themes/CustomTheme.h +++ b/application/themes/CustomTheme.h @@ -15,6 +15,7 @@ public: double fadeAmount() override; QColor fadeColor() override; QString qtTheme() override; + QStringList searchPaths() override; private: /* data */ QPalette m_palette; diff --git a/application/themes/ITheme.h b/application/themes/ITheme.h index 9c071e0a..8070efb1 100644 --- a/application/themes/ITheme.h +++ b/application/themes/ITheme.h @@ -13,6 +13,10 @@ public: virtual QPalette colorScheme() = 0; virtual QColor fadeColor() = 0; virtual double fadeAmount() = 0; + virtual QStringList searchPaths() + { + return {}; + } static QPalette fadeInactive(QPalette in, qreal bias, QColor color); }; |