QmlDesigner: Skip asset importer dialog when dropping an external asset

Fixes: QDS-9350
Change-Id: I7bef35350108580ef293160840a9e4174d1f6642
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2023-03-03 14:46:13 +02:00
parent 26b2b01ab4
commit 399cc372db
2 changed files with 7 additions and 6 deletions

View File

@@ -288,15 +288,16 @@ void AssetsLibraryWidget::handleExtFilesDrop(const QList<QUrl> &simpleFilePaths,
auto toLocalFile = [](const QUrl &url) { return url.toLocalFile(); };
QStringList simpleFilePathStrings = Utils::transform<QStringList>(simpleFilePaths, toLocalFile);
QStringList complexFilePathStrings = Utils::transform<QStringList>(complexFilePaths,
toLocalFile);
QStringList complexFilePathStrings = Utils::transform<QStringList>(complexFilePaths, toLocalFile);
if (!simpleFilePathStrings.isEmpty()) {
if (targetDirPath.isEmpty()) {
addResources(simpleFilePathStrings);
} else {
bool isDropOnRoot = m_assetsModel->rootPath() == targetDirPath;
AddFilesResult result = ModelNodeOperations::addFilesToProject(simpleFilePathStrings,
targetDirPath);
targetDirPath,
isDropOnRoot);
if (result.status() == AddFilesResult::Failed) {
Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"),
tr("Could not add %1 to project.")
@@ -432,7 +433,7 @@ static QHash<QByteArray, QStringList> allImageFormats()
return imageFormats;
}
void AssetsLibraryWidget::addResources(const QStringList &files)
void AssetsLibraryWidget::addResources(const QStringList &files, bool showDialog)
{
clearSearchFilter();
@@ -506,7 +507,7 @@ void AssetsLibraryWidget::addResources(const QStringList &files)
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_RESOURCE_IMPORTED + category);
if (operation) {
AddFilesResult result = operation(fileNames,
document->fileName().parentDir().toString(), true);
document->fileName().parentDir().toString(), showDialog);
if (result.status() == AddFilesResult::Failed) {
Core::AsynchronousMessageBox::warning(tr("Failed to Add Files"),
tr("Could not add %1 to project.")

View File

@@ -112,7 +112,7 @@ protected:
private:
void reloadQmlSource();
void addResources(const QStringList &files);
void addResources(const QStringList &files, bool showDialog = true);
void updateSearch();
void setIsDragging(bool val);