forked from qt-creator/qt-creator
Allow to define a environment variable for qtc templates
Now we can load qtc templates from anothers directories. In kde we start to provide some templates and we need to be able to specify it. Change-Id: I373faae7fdc3fa34ac9b3c7c57d69c1a5e4d244e Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -314,6 +314,24 @@ JsonWizardFactory *JsonWizardFactory::createWizardFactory(const QVariantMap &dat
|
|||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QStringList environmentTemplatesPaths()
|
||||||
|
{
|
||||||
|
QStringList paths;
|
||||||
|
|
||||||
|
QString envTempPath = qEnvironmentVariable("QTCREATOR_TEMPLATES_PATH");
|
||||||
|
|
||||||
|
if (!envTempPath.isEmpty()) {
|
||||||
|
for (const QString &path : envTempPath
|
||||||
|
.split(Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts)) {
|
||||||
|
QString canonicalPath = QDir(path).canonicalPath();
|
||||||
|
if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
|
||||||
|
paths.append(canonicalPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
Utils::FileNameList &JsonWizardFactory::searchPaths()
|
Utils::FileNameList &JsonWizardFactory::searchPaths()
|
||||||
{
|
{
|
||||||
static Utils::FileNameList m_searchPaths = Utils::FileNameList()
|
static Utils::FileNameList m_searchPaths = Utils::FileNameList()
|
||||||
@@ -321,6 +339,9 @@ Utils::FileNameList &JsonWizardFactory::searchPaths()
|
|||||||
QLatin1String(WIZARD_PATH))
|
QLatin1String(WIZARD_PATH))
|
||||||
<< Utils::FileName::fromString(Core::ICore::resourcePath() + QLatin1Char('/') +
|
<< Utils::FileName::fromString(Core::ICore::resourcePath() + QLatin1Char('/') +
|
||||||
QLatin1String(WIZARD_PATH));
|
QLatin1String(WIZARD_PATH));
|
||||||
|
for (const QString &environmentTemplateDirName : environmentTemplatesPaths())
|
||||||
|
m_searchPaths << Utils::FileName::fromString(environmentTemplateDirName);
|
||||||
|
|
||||||
return m_searchPaths;
|
return m_searchPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user