GH-378 add a resource search path to custom themes
This allows adding images and other bits and pieces to themes.
This commit is contained in:
parent
bc753859b5
commit
37cc59c04d
@ -1027,6 +1027,7 @@ void MultiMC::setApplicationTheme(const QString& name)
|
|||||||
auto & theme = (*themeIter).second;
|
auto & theme = (*themeIter).second;
|
||||||
setStyle(QStyleFactory::create(theme->qtTheme()));
|
setStyle(QStyleFactory::create(theme->qtTheme()));
|
||||||
setPalette(theme->colorScheme());
|
setPalette(theme->colorScheme());
|
||||||
|
QDir::setSearchPaths("theme", theme->searchPaths());
|
||||||
setStyleSheet(theme->appStyleSheet());
|
setStyleSheet(theme->appStyleSheet());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -128,10 +128,11 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QString folder)
|
|||||||
{
|
{
|
||||||
m_id = folder;
|
m_id = folder;
|
||||||
QString path = FS::PathCombine("themes", m_id);
|
QString path = FS::PathCombine("themes", m_id);
|
||||||
|
QString pathResources = FS::PathCombine("themes", m_id, "resources");
|
||||||
|
|
||||||
qDebug() << "Loading theme" << m_id;
|
qDebug() << "Loading theme" << m_id;
|
||||||
|
|
||||||
if(!FS::ensureFolderPathExists(path))
|
if(!FS::ensureFolderPathExists(path) || !FS::ensureFolderPathExists(pathResources))
|
||||||
{
|
{
|
||||||
qWarning() << "couldn't create folder for theme!";
|
qWarning() << "couldn't create folder for theme!";
|
||||||
m_palette = baseTheme->colorScheme();
|
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()
|
QString CustomTheme::id()
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
double fadeAmount() override;
|
double fadeAmount() override;
|
||||||
QColor fadeColor() override;
|
QColor fadeColor() override;
|
||||||
QString qtTheme() override;
|
QString qtTheme() override;
|
||||||
|
QStringList searchPaths() override;
|
||||||
|
|
||||||
private: /* data */
|
private: /* data */
|
||||||
QPalette m_palette;
|
QPalette m_palette;
|
||||||
|
@ -13,6 +13,10 @@ public:
|
|||||||
virtual QPalette colorScheme() = 0;
|
virtual QPalette colorScheme() = 0;
|
||||||
virtual QColor fadeColor() = 0;
|
virtual QColor fadeColor() = 0;
|
||||||
virtual double fadeAmount() = 0;
|
virtual double fadeAmount() = 0;
|
||||||
|
virtual QStringList searchPaths()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
static QPalette fadeInactive(QPalette in, qreal bias, QColor color);
|
static QPalette fadeInactive(QPalette in, qreal bias, QColor color);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user