From b771bdf4c1873c3dbf5b6c7bd49f6ed620205be9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 16 Sep 2021 16:17:40 +0200 Subject: [PATCH] ProjectExplorer: Add a cancel option to the rename dialog ... in the project tree. Also properly handle the situation where the dialog is closed by other means than one of the buttons. Task-number: QTCREATORBUG-26268 Change-Id: Ic0b613be2413f96355c1b33bb4753bd1170e0671 Reviewed-by: hjk --- src/plugins/projectexplorer/projectmodels.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index a628d6df75b..6d14768ff36 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -315,8 +315,11 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol const QMessageBox::StandardButton reply = QMessageBox::question( Core::ICore::dialogParent(), tr("Rename More Files?"), tr("Would you like to rename these files as well?\n %1") - .arg(fileNames.join("\n "))); - if (reply == QMessageBox::Yes) { + .arg(fileNames.join("\n ")), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, + QMessageBox::Yes); + switch (reply) { + case QMessageBox::Yes: for (Node * const n : candidateNodes) { QString targetFilePath = orgFileInfo.absolutePath() + '/' + newFilePath.completeBaseName(); @@ -326,6 +329,11 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol toRename.emplace_back(std::make_tuple(n, n->filePath(), FilePath::fromString(targetFilePath))); } + break; + case QMessageBox::Cancel: + return false; + default: + break; } } }