mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add replace_action() to keyboard manager
This commit is contained in:
parent
604d4ca916
commit
b61638fa28
@ -198,6 +198,10 @@ class InterfaceAction(QObject):
|
||||
:param shortcut_name: The test displayed to the user when customizing
|
||||
the keyboard shortcuts for this action. By default it is set to the
|
||||
value of ``text``.
|
||||
|
||||
:return: The created Qation, This action has one extra attribute
|
||||
calibre_shortcut_unique_name which if not None refers to the unique
|
||||
name under which this action is registered with the keyboard manager.
|
||||
'''
|
||||
if shortcut_name is None:
|
||||
shortcut_name = unicode(text)
|
||||
@ -216,10 +220,12 @@ class InterfaceAction(QObject):
|
||||
ac.setStatusTip(description)
|
||||
ac.setWhatsThis(description)
|
||||
|
||||
ac.calibre_shortcut_unique_name = None
|
||||
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
|
||||
|
@ -117,6 +117,13 @@ class Manager(QObject): # {{{
|
||||
#import pprint
|
||||
#pprint.pprint(self.keys_map)
|
||||
|
||||
def replace_action(self, unique_name, new_action):
|
||||
sc = self.shortcuts[unique_name]
|
||||
ac = sc['action']
|
||||
if ac is not None:
|
||||
new_action.setShortcuts(ac.shortcuts())
|
||||
ac.setShortcuts([])
|
||||
|
||||
# }}}
|
||||
|
||||
# Model {{{
|
||||
|
Loading…
x
Reference in New Issue
Block a user