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