diff --git a/src/calibre/gui2/actions/__init__.py b/src/calibre/gui2/actions/__init__.py index 4f2d5fe559..4f42a1d2bc 100644 --- a/src/calibre/gui2/actions/__init__.py +++ b/src/calibre/gui2/actions/__init__.py @@ -220,12 +220,11 @@ class InterfaceAction(QObject): ac.setStatusTip(description) ac.setWhatsThis(description) - ac.calibre_shortcut_unique_name = None + ac.calibre_shortcut_unique_name = unique_name if shortcut is not False: self.gui.keyboard.register_shortcut(unique_name, shortcut_name, default_keys=keys, action=ac, description=description, group=self.action_spec[0]) - ac.calibre_shortcut_unique_name = unique_name if triggered is not None: ac.triggered.connect(triggered) return ac diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py index 806f1d2f17..6413b216ce 100644 --- a/src/calibre/gui2/keyboard.py +++ b/src/calibre/gui2/keyboard.py @@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en' from collections import OrderedDict from functools import partial -import sip from PyQt4.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame, QApplication, QSize, QRectF, QWidget, QTreeView, @@ -127,17 +126,13 @@ class Manager(QObject): # {{{ def replace_action(self, unique_name, new_action): ''' - Replace the action associated with a shortcut. If this method returns - False you must call finalize() to have shortcuts set on the new action - correctly. + Replace the action associated with a shortcut. + Once you're done calling replace_action() for all shortcuts you want + replaced, call finalize() to have the shortcuts assigned to the replaced + actions. ''' sc = self.shortcuts[unique_name] - ac = sc['action'] - if ac is not None and not sip.isdeleted(ac): - new_action.setShortcuts(ac.shortcuts()) - ac.setShortcuts([]) - return True - return False + sc['action'] = new_action # }}}