From 37cc59c04d0573a42d67242135495c0a0729f965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 6 Nov 2016 05:48:52 +0100 Subject: GH-378 add a resource search path to custom themes This allows adding images and other bits and pieces to themes. --- application/MultiMC.cpp | 1 + application/themes/CustomTheme.cpp | 9 ++++++++- application/themes/CustomTheme.h | 1 + application/themes/ITheme.h | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) (limited to 'application') 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); }; -- cgit v1.2.3