forked from qt-creator/qt-creator
VCS: Remove Apply/Revert Chunk when they are not applicable
Having disabled entries in a context menu without any additional information why they are disabled is confusing Change-Id: Idb3d5a7befe57b84adb2f7cb58b2cbc1331039ec Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
7fb9f7b802
commit
f6f822f5f6
@@ -934,23 +934,22 @@ void VcsBaseEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
menu->addSeparator();
|
||||
// Apply/revert diff chunk.
|
||||
const DiffChunk chunk = diffChunk(cursorForPosition(e->pos()));
|
||||
const bool canApply = canApplyDiffChunk(chunk);
|
||||
if (!canApplyDiffChunk(chunk))
|
||||
break;
|
||||
// Apply a chunk from a diff loaded into the editor. This typically will
|
||||
// not have the 'source' property set and thus will only work if the working
|
||||
// directory matches that of the patch (see findDiffFile()). In addition,
|
||||
// the user has "Open With" and choose the right diff editor so that
|
||||
// fileNameFromDiffSpecification() works.
|
||||
QAction *applyAction = menu->addAction(tr("Apply Chunk..."));
|
||||
applyAction->setEnabled(canApply);
|
||||
applyAction->setData(qVariantFromValue(Internal::DiffChunkAction(chunk, false)));
|
||||
connect(applyAction, SIGNAL(triggered()), this, SLOT(slotApplyDiffChunk()));
|
||||
// Revert a chunk from a VCS diff, which might be linked to reloading the diff.
|
||||
QAction *revertAction = menu->addAction(tr("Revert Chunk..."));
|
||||
revertAction->setEnabled(canApply);
|
||||
revertAction->setData(qVariantFromValue(Internal::DiffChunkAction(chunk, true)));
|
||||
connect(revertAction, SIGNAL(triggered()), this, SLOT(slotApplyDiffChunk()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user