forked from qt-creator/qt-creator
QbsProjectManager: Support QML designer import paths
Task-number: QTCREATORBUG-20810 Change-Id: I1f096124f94d2c9f4ad51373bb39a212a108799f Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -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}.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user