This commit is contained in:
Kovid Goyal 2011-09-03 14:13:48 -06:00
parent 3470004cc4
commit 384e8ff320
2 changed files with 6 additions and 12 deletions

View File

@ -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

View File

@ -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
# }}}