From 3470004cc46ec40ee4b03522d376bebbda39ce7c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Sep 2011 12:38:03 -0600 Subject: [PATCH] ... --- src/calibre/gui2/keyboard.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py index b40845d61a..806f1d2f17 100644 --- a/src/calibre/gui2/keyboard.py +++ b/src/calibre/gui2/keyboard.py @@ -10,6 +10,7 @@ __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, @@ -125,11 +126,18 @@ class Manager(QObject): # {{{ #pprint.pprint(self.keys_map) 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. + ''' sc = self.shortcuts[unique_name] ac = sc['action'] - if ac is not None: + if ac is not None and not sip.isdeleted(ac): new_action.setShortcuts(ac.shortcuts()) ac.setShortcuts([]) + return True + return False # }}}