forked from qt-creator/qt-creator
QtDesignStudio: Fix assets library external drop
Fix external drops onto assets library for ubuntu. The file paths were missing the leading slash ("/") which caused external drops to fail. Change-Id: I4c554df2ac4422d935ec06b835ce34de25b9e2e8 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
bbc44cfb90
commit
42857ce43f
@@ -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)
|
||||
|
@@ -213,26 +213,32 @@ void AssetsLibraryWidget::handleAddAsset()
|
||||
addResources({});
|
||||
}
|
||||
|
||||
void AssetsLibraryWidget::handleExtFilesDrop(const QStringList &simpleFilesPaths,
|
||||
const QStringList &complexFilesPaths,
|
||||
void AssetsLibraryWidget::handleExtFilesDrop(const QList<QUrl> &simpleFilePaths,
|
||||
const QList<QUrl> &complexFilePaths,
|
||||
const QString &targetDirPath)
|
||||
{
|
||||
if (!simpleFilesPaths.isEmpty()) {
|
||||
auto toLocalFile = [](const QUrl &url) { return url.toLocalFile(); };
|
||||
|
||||
QStringList simpleFilePathStrings = Utils::transform<QStringList>(simpleFilePaths, toLocalFile);
|
||||
QStringList complexFilePathStrings = Utils::transform<QStringList>(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<QString> AssetsLibraryWidget::supportedAssetSuffixes(bool complex)
|
||||
|
@@ -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<QUrl> &simpleFilePaths,
|
||||
const QList<QUrl> &complexFilePaths,
|
||||
const QString &targetDirPath = {});
|
||||
Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex);
|
||||
|
||||
|
Reference in New Issue
Block a user