QmlDesigner: Fix bundle importing in project storage builds

In PS builds we can just change imports without waiting for new import
to be included in possible imports if we know the import will be
available.

Also fix name generation of the imported bundle materials to match
non-PS implementation.

Task-number: QDS-14568
Task-number: QDS-14822
Change-Id: Ide9a7cafb8e2784c2c311695b5489eab267c0c04
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2025-02-25 16:29:33 +02:00
parent 155e9a885e
commit d07458c8f8
2 changed files with 5 additions and 1 deletions

View File

@@ -124,6 +124,9 @@ QString BundleImporter::importComponent(const QString &bundleDir,
data.fullReset = doReset;
Import import = Import::createLibraryImport(module, "1.0");
#ifdef QDS_USE_PROJECTSTORAGE
model->changeImports({import}, {});
#else
if (!model->hasImport(import)) {
if (model->possibleImports().contains(import)) {
try {
@@ -138,6 +141,7 @@ QString BundleImporter::importComponent(const QString &bundleDir,
data.importToAdd = module;
}
}
#endif
m_pendingImports.insert(type, data);
m_importTimerCount = 0;
m_importTimer.start(normalImportDelay);

View File

@@ -301,7 +301,7 @@ ModelNode createMaterial(AbstractView *view, const TypeName &typeName)
matLib.defaultNodeListProperty().reparentHere(newMatNode);
static QRegularExpression rgx("([A-Z])([a-z]*)");
QString newName = QString::fromUtf8(typeName).replace(rgx, " \\1\\2").trimmed();
QString newName = QString::fromUtf8(typeName.split('.').last()).replace(rgx, " \\1\\2").trimmed();
if (newName.endsWith(" Material"))
newName.chop(9); // remove trailing " Material"
QString newId = view->model()->generateNewId(newName, "material");