QmlDesigner: Handle absolute and web urls when exporting a bundle

Properly handle absolute paths: added to the root of the exported
bundle. Skip web urls for now (they are not working for textures anyway)

Change-Id: I4bb9e8bfbe28bd2a11b36ca1e1dae876dc9bce22
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-09-09 15:59:35 +03:00
parent db5acbb381
commit 02ed7f77f7

View File

@@ -660,9 +660,24 @@ QSet<AssetPath> BundleHelper::getComponentDependencies(const Utils::FilePath &fi
if (std::string_view{pValue.typeName()} == "QUrl") {
QString pValueStr = pValue.toString();
if (!pValueStr.isEmpty() && !pValueStr.startsWith("#")) {
Utils::FilePath pValuePath = Utils::FilePath::fromString(pValueStr);
Utils::FilePath assetPathBase;
QString assetPathRelative;
if (!pValuePath.toUrl().isLocalFile() || pValuePath.startsWith("www.")) {
qWarning() << "BundleHelper::getComponentDependencies(): Web urls are not"
" supported. Skipping " << pValuePath;
continue;
} else if (pValuePath.isAbsolutePath()) {
assetPathRelative = pValuePath.fileName();
assetPathBase = pValuePath.parentDir();
} else {
Utils::FilePath assetPath = filePath.parentDir().resolvePath(pValueStr);
Utils::FilePath assetPathRelative = assetPath.relativePathFrom(mainCompDir);
depList.insert({mainCompDir, assetPathRelative.toFSPathString()});
assetPathRelative = assetPath.relativePathFrom(mainCompDir).toFSPathString();
assetPathBase = mainCompDir;
}
depList.insert({assetPathBase, assetPathRelative});
}
}
}