From a259b0db8e659baa6fbf0c8b687bc1e781587e45 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 26 Dec 2013 12:53:55 -0800 Subject: [PATCH] main: add Ctrl+u shortcut for "Revert Unstaged Edits" Closes #220 Suggested-by: @grandinj via github.com in #220 Signed-off-by: David Aguilar --- cola/widgets/main.py | 3 ++- cola/widgets/status.py | 39 ++++++++------------------------------ share/doc/git-cola/hotkeys.html | 5 +++++ share/doc/git-cola/hotkeys_de.html | 6 ++++++ 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/cola/widgets/main.py b/cola/widgets/main.py index 01571d11..cde557e5 100644 --- a/cola/widgets/main.py +++ b/cola/widgets/main.py @@ -318,11 +318,12 @@ class MainView(MainWindow): N_('Abort'), self.rebase_abort) # Relayed actions + status_tree = self.statusdockwidget.widget().tree + self.addAction(status_tree.revert_unstaged_edits_action) if not self.browser_dockable: # These shortcuts conflict with those from the # 'Browser' widget so don't register them when # the browser is a dockable tool. - status_tree = self.statusdockwidget.widget().tree self.addAction(status_tree.up) self.addAction(status_tree.down) self.addAction(status_tree.process_selection) diff --git a/cola/widgets/status.py b/cola/widgets/status.py index 85c8d21b..111393b1 100644 --- a/cola/widgets/status.py +++ b/cola/widgets/status.py @@ -86,6 +86,12 @@ class StatusTreeWidget(QtGui.QTreeWidget): N_('Stage / Unstage'), self._process_selection, cmds.Stage.SHORTCUT) + self.revert_unstaged_edits_action = qtutils.add_action(self, + N_('Revert Unstaged Edits...'), + cmds.run(cmds.RevertUnstagedEdits), + cmds.RevertUnstagedEdits.SHORTCUT) + self.revert_unstaged_edits_action.setIcon(qtutils.icon('undo.svg')) + self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), cmds.run(cmds.LaunchDifftool), @@ -471,9 +477,7 @@ class StatusTreeWidget(QtGui.QTreeWidget): if self.m.undoable(): menu.addSeparator() - menu.addAction(qtutils.icon('undo.svg'), - N_('Revert Unstaged Edits...'), - lambda: self._revert_unstaged_edits(staged=True)) + menu.addAction(self.revert_unstaged_edits_action) menu.addAction(qtutils.icon('undo.svg'), N_('Revert Uncommited Edits...'), lambda: self._revert_uncommitted_edits( @@ -547,9 +551,7 @@ class StatusTreeWidget(QtGui.QTreeWidget): if s.modified and self.m.stageable(): if self.m.undoable(): menu.addSeparator() - menu.addAction(qtutils.icon('undo.svg'), - N_('Revert Unstaged Edits...'), - self._revert_unstaged_edits) + menu.addAction(self.revert_unstaged_edits_action) menu.addAction(qtutils.icon('undo.svg'), N_('Revert Uncommited Edits...'), lambda: self._revert_uncommitted_edits( @@ -621,31 +623,6 @@ class StatusTreeWidget(QtGui.QTreeWidget): icon=qtutils.discard_icon()): cmds.do(cmds.Delete, files) - def _revert_unstaged_edits(self, staged=False): - if not self.m.undoable(): - return - if staged: - items_to_undo = self.staged() - else: - items_to_undo = self.modified() - - if items_to_undo: - if not qtutils.confirm(N_('Revert Unstaged Changes?'), - N_('This operation drops unstaged changes.\n' - 'These changes cannot be recovered.'), - N_('Revert the unstaged changes?'), - N_('Revert Unstaged Changes'), - default=True, - icon=qtutils.icon('undo.svg')): - return - args = [] - if not staged and self.m.amending(): - args.append(self.m.head) - cmds.do(cmds.Checkout, args + ['--'] + items_to_undo) - else: - msg = N_('No files selected for checkout from HEAD.') - Interaction.log(msg) - def _revert_uncommitted_edits(self, items_to_undo): if items_to_undo: if not qtutils.confirm( diff --git a/share/doc/git-cola/hotkeys.html b/share/doc/git-cola/hotkeys.html index 6b776813..30357e73 100644 --- a/share/doc/git-cola/hotkeys.html +++ b/share/doc/git-cola/hotkeys.html @@ -75,6 +75,11 @@ span.title { Stage untracked files + Ctrl + u + : + Revert unstaged edits + + Ctrl + r : Refresh diff --git a/share/doc/git-cola/hotkeys_de.html b/share/doc/git-cola/hotkeys_de.html index 14fa09d3..13bc73ca 100644 --- a/share/doc/git-cola/hotkeys_de.html +++ b/share/doc/git-cola/hotkeys_de.html @@ -75,6 +75,12 @@ span.title { Alle neuen Dateien vormerken + Ctrl + u + : + + Revert unstaged edits + + Ctrl + r : Ansicht aktualisieren -- 2.11.4.GIT