summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-08-20 14:48:02 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-09-07 11:40:53 +0000
commitb68d943c920bc76506eccdc4b2b08ce93d2f2585 (patch)
treef78c5d6fc54c28a17a4fdfe07512476c6da5165d
parentb6eb350a31343767b610bed59da3db6b5f616dd2 (diff)
downloadqt-creator-b68d943c920bc76506eccdc4b2b08ce93d2f2585.tar.gz
QbsProjectManager: Support QML designer import paths
Task-number: QTCREATORBUG-20810 Change-Id: I1f096124f94d2c9f4ad51373bb39a212a108799f Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--doc/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc3
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp16
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/doc/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc b/doc/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
index 9e2c68204f..c8f04145fe 100644
--- a/doc/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
+++ b/doc/src/qtquick/creator-only/qtquick-modules-with-plugins.qdoc
@@ -175,7 +175,8 @@
If you want to use a different module in the Design mode than in your actual
application for example to mockup C++ items, then you can use \c{QML_DESIGNER_IMPORT_PATH}
- in the \c{.pro} file.
+ in the \c{.pro} file (for qmake projects), or declare and set the property
+ qmlDesignerImportPaths in your product (for Qbs projects).
Modules in the import paths defined in \c{QML_DESIGNER_IMPORT_PATH} will be
used only in the Design mode.
For an example, see \l {Qt Quick Controls 2 - Contact List}.
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index c1645ea28e..fccb0f398a 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -188,6 +188,22 @@ ProjectImporter *QbsProject::projectImporter() const
return m_importer;
}
+QVariant QbsProject::additionalData(Id id, const Target *target) const
+{
+ if (id == "QmlDesignerImportPath") {
+ const qbs::Project qbsProject = m_qbsProjects.value(const_cast<Target *>(target));
+ const qbs::ProjectData projectData = qbsProject.isValid()
+ ? qbsProject.projectData() : qbs::ProjectData();
+ QStringList designerImportPaths;
+ foreach (const qbs::ProductData &product, projectData.allProducts()) {
+ designerImportPaths << product.properties()
+ .value("qmlDesignerImportPaths").toStringList();
+ }
+ return designerImportPaths;
+ }
+ return Project::additionalData(id, target);
+}
+
QStringList QbsProject::filesGeneratedFrom(const QString &sourceFile) const
{
QStringList generated;
diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h
index 5d8c057a9c..d6e2326398 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.h
+++ b/src/plugins/qbsprojectmanager/qbsproject.h
@@ -135,6 +135,7 @@ private:
void projectLoaded() override;
ProjectExplorer::ProjectImporter *projectImporter() const override;
+ QVariant additionalData(Core::Id id, const ProjectExplorer::Target *target) const final;
static bool ensureWriteableQbsFile(const QString &file);