summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTapani Mattila <tapani.mattila@qt.io>2022-06-10 12:30:42 +0300
committerTapani Mattila <tapani.mattila@qt.io>2022-06-22 13:40:09 +0000
commit42ab928a27ed02b3fff7e6347d0a9c857720e58d (patch)
tree1d1c3fd7a8a160829db3035e4bf1a2810e302dcb /src
parente49e0f87cd0f64e67c29e0a65017c8df384ebb83 (diff)
downloadqt-creator-42ab928a27ed02b3fff7e6347d0a9c857720e58d.tar.gz
CorePlugin: Prevent double warnings for overwriting files
Task-number: QDS-6824 Change-Id: I935b2b1076a4e765230a7462c470d7c134063249 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp23
-rw-r--r--src/plugins/qmldesigner/generateresource.cpp4
2 files changed, 14 insertions, 13 deletions
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 12ad4c3e60..789374133c 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -830,8 +830,7 @@ FilePath DocumentManager::getSaveFileName(const QString &title, const FilePath &
bool repeat;
do {
repeat = false;
- filePath = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
- QFileDialog::DontConfirmOverwrite);
+ filePath = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter);
if (!filePath.isEmpty()) {
// If the selected filter is All Files (*) we leave the name exactly as the user
// specified. Otherwise the suffix must be one available in the selected filter. If
@@ -852,18 +851,20 @@ FilePath DocumentManager::getSaveFileName(const QString &title, const FilePath &
suffixOk = true;
break;
}
- if (!suffixOk && !suffixes.isEmpty())
+ if (!suffixOk && !suffixes.isEmpty()) {
filePath = filePath.stringAppended(suffixes.at(0));
+ if (filePath.exists()) {
+ if (QMessageBox::warning(ICore::dialogParent(), tr("Overwrite?"),
+ tr("An item named \"%1\" already exists at this location. "
+ "Do you want to overwrite it?").arg(filePath.toUserOutput()),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
+ repeat = true;
+ }
+ }
+ }
}
}
- if (filePath.exists()) {
- if (QMessageBox::warning(ICore::dialogParent(), tr("Overwrite?"),
- tr("An item named \"%1\" already exists at this location. "
- "Do you want to overwrite it?").arg(filePath.toUserOutput()),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
- repeat = true;
- }
- }
+
}
} while (repeat);
if (!filePath.isEmpty())
diff --git a/src/plugins/qmldesigner/generateresource.cpp b/src/plugins/qmldesigner/generateresource.cpp
index b85370f60f..9d6be4e1c7 100644
--- a/src/plugins/qmldesigner/generateresource.cpp
+++ b/src/plugins/qmldesigner/generateresource.cpp
@@ -217,7 +217,7 @@ void GenerateResource::generateMenuEntry()
QTC_ASSERT(currentProject, return);
const FilePath projectPath = currentProject->projectFilePath().parentDir();
- auto projectFileName = Core::DocumentManager::getSaveFileName(
+ auto projectFileName = Core::DocumentManager::getSaveFileNameWithExtension(
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as QRC File"),
projectPath.pathAppended(currentProject->displayName() + ".qrc"),
QCoreApplication::translate("QmlDesigner::GenerateResource",
@@ -366,7 +366,7 @@ void GenerateResource::generateMenuEntry()
QTC_ASSERT(currentProject, return);
const FilePath projectPath = currentProject->projectFilePath().parentDir();
- const FilePath resourceFileName = Core::DocumentManager::getSaveFileName(
+ const FilePath resourceFileName = Core::DocumentManager::getSaveFileNameWithExtension(
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as Resource"),
projectPath.pathAppended(currentProject->displayName() + ".qmlrc"),
QCoreApplication::translate("QmlDesigner::GenerateResource",