Diff: Fix that dialog for "Revert Chunk" closes right away

On macOS.

Change-Id: Ifbe402c44779e4062a5dfb5d7c09da7ac845acce
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Eike Ziller
2024-02-23 12:17:37 +01:00
parent 3d8592edd1
commit fdabbfcbcf
2 changed files with 18 additions and 9 deletions

View File

@@ -267,9 +267,12 @@ void DiffEditorWidgetController::addPatchAction(QMenu *menu, int fileIndex, int
const QString actionName = patchAction == PatchAction::Apply ? Tr::tr("Apply Chunk...") const QString actionName = patchAction == PatchAction::Apply ? Tr::tr("Apply Chunk...")
: Tr::tr("Revert Chunk..."); : Tr::tr("Revert Chunk...");
QAction *action = menu->addAction(actionName); QAction *action = menu->addAction(actionName);
connect(action, &QAction::triggered, this, [this, fileIndex, chunkIndex, patchAction] { connect(
patch(patchAction, fileIndex, chunkIndex); action,
}); &QAction::triggered,
this,
[this, fileIndex, chunkIndex, patchAction] { patch(patchAction, fileIndex, chunkIndex); },
Qt::QueuedConnection);
const bool enabled = chunkExists(fileIndex, chunkIndex) const bool enabled = chunkExists(fileIndex, chunkIndex)
&& (patchAction == PatchAction::Revert || fileNamesAreDifferent(fileIndex)); && (patchAction == PatchAction::Revert || fileNamesAreDifferent(fileIndex));
action->setEnabled(enabled); action->setEnabled(enabled);

View File

@@ -995,14 +995,20 @@ void VcsBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e)
// the user has "Open With" and choose the right diff editor so that // the user has "Open With" and choose the right diff editor so that
// fileNameFromDiffSpecification() works. // fileNameFromDiffSpecification() works.
QAction *applyAction = menu->addAction(Tr::tr("Apply Chunk...")); QAction *applyAction = menu->addAction(Tr::tr("Apply Chunk..."));
connect(applyAction, &QAction::triggered, this, [this, chunk] { connect(
slotApplyDiffChunk(chunk, PatchAction::Apply); applyAction,
}); &QAction::triggered,
this,
[this, chunk] { slotApplyDiffChunk(chunk, PatchAction::Apply); },
Qt::QueuedConnection);
// Revert a chunk from a VCS diff, which might be linked to reloading the diff. // Revert a chunk from a VCS diff, which might be linked to reloading the diff.
QAction *revertAction = menu->addAction(Tr::tr("Revert Chunk...")); QAction *revertAction = menu->addAction(Tr::tr("Revert Chunk..."));
connect(revertAction, &QAction::triggered, this, [this, chunk] { connect(
slotApplyDiffChunk(chunk, PatchAction::Revert); revertAction,
}); &QAction::triggered,
this,
[this, chunk] { slotApplyDiffChunk(chunk, PatchAction::Revert); },
Qt::QueuedConnection);
// Custom diff actions // Custom diff actions
addDiffActions(menu, chunk); addDiffActions(menu, chunk);
break; break;