DiffEditor/VCS: Save document before applying/reverting patch chunk

Fixes: QTCREATORBUG-22506
Change-Id: I646f24068c0c81890f36052537320a743fdeb498
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2022-10-16 04:59:51 +03:00
committed by Orgad Shaneh
parent 7edf743583
commit f696d1e6cf
4 changed files with 23 additions and 9 deletions

View File

@@ -38,13 +38,15 @@ void PatchTool::setPatchCommand(const FilePath &newCommand)
s->endGroup();
}
bool PatchTool::confirmPatching(QWidget *parent, PatchAction patchAction)
bool PatchTool::confirmPatching(QWidget *parent, PatchAction patchAction, bool isModified)
{
const QString title = patchAction == PatchAction::Apply ? Tr::tr("Apply Chunk")
: Tr::tr("Revert Chunk");
const QString question = patchAction == PatchAction::Apply
QString question = patchAction == PatchAction::Apply
? Tr::tr("Would you like to apply the chunk?")
: Tr::tr("Would you like to revert the chunk?");
if (isModified)
question += "\n" + Tr::tr("Note: The file will be saved before this operation.");
return QMessageBox::question(parent, title, question, QMessageBox::Yes | QMessageBox::No)
== QMessageBox::Yes;
}