forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -830,8 +830,7 @@ FilePath DocumentManager::getSaveFileName(const QString &title, const FilePath &
|
|||||||
bool repeat;
|
bool repeat;
|
||||||
do {
|
do {
|
||||||
repeat = false;
|
repeat = false;
|
||||||
filePath = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
|
filePath = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter);
|
||||||
QFileDialog::DontConfirmOverwrite);
|
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
// If the selected filter is All Files (*) we leave the name exactly as the user
|
// 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
|
// 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;
|
suffixOk = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!suffixOk && !suffixes.isEmpty())
|
if (!suffixOk && !suffixes.isEmpty()) {
|
||||||
filePath = filePath.stringAppended(suffixes.at(0));
|
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);
|
} while (repeat);
|
||||||
if (!filePath.isEmpty())
|
if (!filePath.isEmpty())
|
||||||
|
@@ -217,7 +217,7 @@ void GenerateResource::generateMenuEntry()
|
|||||||
QTC_ASSERT(currentProject, return);
|
QTC_ASSERT(currentProject, return);
|
||||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
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"),
|
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as QRC File"),
|
||||||
projectPath.pathAppended(currentProject->displayName() + ".qrc"),
|
projectPath.pathAppended(currentProject->displayName() + ".qrc"),
|
||||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
@@ -366,7 +366,7 @@ void GenerateResource::generateMenuEntry()
|
|||||||
QTC_ASSERT(currentProject, return);
|
QTC_ASSERT(currentProject, return);
|
||||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
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"),
|
QCoreApplication::translate("QmlDesigner::GenerateResource", "Save Project as Resource"),
|
||||||
projectPath.pathAppended(currentProject->displayName() + ".qmlrc"),
|
projectPath.pathAppended(currentProject->displayName() + ".qmlrc"),
|
||||||
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
|
Reference in New Issue
Block a user