diff options
author | Laurent Montel <laurent.montel@kdab.com> | 2018-10-03 09:51:48 +0200 |
---|---|---|
committer | Laurent Montel <laurent.montel@kdab.com> | 2018-10-08 12:33:10 +0000 |
commit | 167f08e2ce0dd5b10e9436987509bc5392871c5b (patch) | |
tree | e6783edb79ef1d4150ca12915bedd2277e757c9e /src/plugins/projectexplorer/jsonwizard | |
parent | 5900766ecb6aa25f363660c5ad2ef15777db5053 (diff) |
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>
Diffstat (limited to 'src/plugins/projectexplorer/jsonwizard')
-rw-r--r-- | src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 1ef81e7d45..a75bb6ee3b 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -314,6 +314,24 @@ JsonWizardFactory *JsonWizardFactory::createWizardFactory(const QVariantMap &dat 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() { static Utils::FileNameList m_searchPaths = Utils::FileNameList() @@ -321,6 +339,9 @@ Utils::FileNameList &JsonWizardFactory::searchPaths() QLatin1String(WIZARD_PATH)) << Utils::FileName::fromString(Core::ICore::resourcePath() + QLatin1Char('/') + QLatin1String(WIZARD_PATH)); + for (const QString &environmentTemplateDirName : environmentTemplatesPaths()) + m_searchPaths << Utils::FileName::fromString(environmentTemplateDirName); + return m_searchPaths; } |