diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml index 66760b1a24d..a90dfa50f19 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/Assets.qml @@ -59,9 +59,6 @@ Item { var complexSuffixes = rootView.supportedAssetSuffixes(true); for (const u of drag.urls) { var url = u.toString(); - if (url.startsWith("file:///")) // remove file scheme (happens on Windows) - url = url.substr(8) - var ext = '*.' + url.slice(url.lastIndexOf('.') + 1).toLowerCase() if (simpleSuffixes.includes(ext)) root.dropSimpleExtFiles.push(url) diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp index 162fadcf78c..7f7831dfbde 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp @@ -213,26 +213,32 @@ void AssetsLibraryWidget::handleAddAsset() addResources({}); } -void AssetsLibraryWidget::handleExtFilesDrop(const QStringList &simpleFilesPaths, - const QStringList &complexFilesPaths, +void AssetsLibraryWidget::handleExtFilesDrop(const QList &simpleFilePaths, + const QList &complexFilePaths, const QString &targetDirPath) { - if (!simpleFilesPaths.isEmpty()) { + auto toLocalFile = [](const QUrl &url) { return url.toLocalFile(); }; + + QStringList simpleFilePathStrings = Utils::transform(simpleFilePaths, toLocalFile); + QStringList complexFilePathStrings = Utils::transform(complexFilePaths, + toLocalFile); + + if (!simpleFilePathStrings.isEmpty()) { if (targetDirPath.isEmpty()) { - addResources(simpleFilesPaths); + addResources(simpleFilePathStrings); } else { - AddFilesResult result = ModelNodeOperations::addFilesToProject(simpleFilesPaths, + AddFilesResult result = ModelNodeOperations::addFilesToProject(simpleFilePathStrings, targetDirPath); if (result == AddFilesResult::Failed) { Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"), tr("Could not add %1 to project.") - .arg(simpleFilesPaths.join(' '))); + .arg(simpleFilePathStrings.join(' '))); } } } - if (!complexFilesPaths.empty()) - addResources(complexFilesPaths); + if (!complexFilePathStrings.empty()) + addResources(complexFilePathStrings); } QSet AssetsLibraryWidget::supportedAssetSuffixes(bool complex) diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h index 3128b823b3c..125755409e9 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h @@ -79,8 +79,8 @@ public: Q_INVOKABLE void startDragAsset(const QStringList &assetPaths, const QPointF &mousePos); Q_INVOKABLE void handleAddAsset(); Q_INVOKABLE void handleSearchfilterChanged(const QString &filterText); - Q_INVOKABLE void handleExtFilesDrop(const QStringList &simpleFilesPaths, - const QStringList &complexFilesPaths, + Q_INVOKABLE void handleExtFilesDrop(const QList &simpleFilePaths, + const QList &complexFilePaths, const QString &targetDirPath = {}); Q_INVOKABLE QSet supportedAssetSuffixes(bool complex);