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.setStatusTip(description)
ac.setWhatsThis(description) ac.setWhatsThis(description)
ac.calibre_shortcut_unique_name = None ac.calibre_shortcut_unique_name = unique_name
if shortcut is not False: if shortcut is not False:
self.gui.keyboard.register_shortcut(unique_name, self.gui.keyboard.register_shortcut(unique_name,
shortcut_name, default_keys=keys, shortcut_name, default_keys=keys,
action=ac, description=description, group=self.action_spec[0]) action=ac, description=description, group=self.action_spec[0])
ac.calibre_shortcut_unique_name = unique_name
if triggered is not None: if triggered is not None:
ac.triggered.connect(triggered) ac.triggered.connect(triggered)
return ac return ac

View File

@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
from collections import OrderedDict from collections import OrderedDict
from functools import partial from functools import partial
import sip
from PyQt4.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, from PyQt4.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex,
Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame, Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame,
QApplication, QSize, QRectF, QWidget, QTreeView, QApplication, QSize, QRectF, QWidget, QTreeView,
@ -127,17 +126,13 @@ class Manager(QObject): # {{{
def replace_action(self, unique_name, new_action): def replace_action(self, unique_name, new_action):
''' '''
Replace the action associated with a shortcut. If this method returns Replace the action associated with a shortcut.
False you must call finalize() to have shortcuts set on the new action Once you're done calling replace_action() for all shortcuts you want
correctly. replaced, call finalize() to have the shortcuts assigned to the replaced
actions.
''' '''
sc = self.shortcuts[unique_name] sc = self.shortcuts[unique_name]
ac = sc['action'] sc['action'] = new_action
if ac is not None and not sip.isdeleted(ac):
new_action.setShortcuts(ac.shortcuts())
ac.setShortcuts([])
return True
return False
# }}} # }}}