forked from qt-creator/qt-creator
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:
@@ -267,9 +267,12 @@ void DiffEditorWidgetController::addPatchAction(QMenu *menu, int fileIndex, int
|
||||
const QString actionName = patchAction == PatchAction::Apply ? Tr::tr("Apply Chunk...")
|
||||
: Tr::tr("Revert Chunk...");
|
||||
QAction *action = menu->addAction(actionName);
|
||||
connect(action, &QAction::triggered, this, [this, fileIndex, chunkIndex, patchAction] {
|
||||
patch(patchAction, fileIndex, chunkIndex);
|
||||
});
|
||||
connect(
|
||||
action,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this, fileIndex, chunkIndex, patchAction] { patch(patchAction, fileIndex, chunkIndex); },
|
||||
Qt::QueuedConnection);
|
||||
const bool enabled = chunkExists(fileIndex, chunkIndex)
|
||||
&& (patchAction == PatchAction::Revert || fileNamesAreDifferent(fileIndex));
|
||||
action->setEnabled(enabled);
|
||||
|
@@ -995,14 +995,20 @@ void VcsBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
// the user has "Open With" and choose the right diff editor so that
|
||||
// fileNameFromDiffSpecification() works.
|
||||
QAction *applyAction = menu->addAction(Tr::tr("Apply Chunk..."));
|
||||
connect(applyAction, &QAction::triggered, this, [this, chunk] {
|
||||
slotApplyDiffChunk(chunk, PatchAction::Apply);
|
||||
});
|
||||
connect(
|
||||
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.
|
||||
QAction *revertAction = menu->addAction(Tr::tr("Revert Chunk..."));
|
||||
connect(revertAction, &QAction::triggered, this, [this, chunk] {
|
||||
slotApplyDiffChunk(chunk, PatchAction::Revert);
|
||||
});
|
||||
connect(
|
||||
revertAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this, chunk] { slotApplyDiffChunk(chunk, PatchAction::Revert); },
|
||||
Qt::QueuedConnection);
|
||||
// Custom diff actions
|
||||
addDiffActions(menu, chunk);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user