Creator Examples: providing custom examples-manifest.xml

The user can prevent the default loading of examples and
provide a custom example manifest file through the
environment variable QTC_EXAMPLE_FILE

Change-Id: Id458d321e2c8815312e338e458a5283ac64b5c95
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christiaan Janssen
2012-11-21 14:28:08 +01:00
committed by hjk
parent 9fa21d26c1
commit 3e0aae6872

View File

@@ -40,6 +40,7 @@
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/environment.h>
#include <algorithm> #include <algorithm>
using QtSupport::QtVersionManager; using QtSupport::QtVersionManager;
@@ -309,6 +310,16 @@ QStringList ExamplesListModel::exampleSources(QString *examplesFallback, QString
QStringList sources; QStringList sources;
QString resourceDir = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/"); QString resourceDir = Core::ICore::resourcePath() + QLatin1String("/welcomescreen/");
// overriding examples with a custom XML file
QString exampleFileEnvKey = QLatin1String("QTC_EXAMPLE_FILE");
if (Utils::Environment::systemEnvironment().hasKey(exampleFileEnvKey)) {
QString filePath = Utils::Environment::systemEnvironment().value(exampleFileEnvKey);
if (filePath.endsWith(QLatin1String(".xml")) && QFileInfo(filePath).exists()) {
sources.append(filePath);
return sources;
}
}
// Qt Creator shipped tutorials // Qt Creator shipped tutorials
sources << (resourceDir + QLatin1String("/qtcreator_tutorials.xml")); sources << (resourceDir + QLatin1String("/qtcreator_tutorials.xml"));