mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 23:03:26 +02:00
Show shortcuts in top level context menu
This commit is contained in:
parent
3247c8b6ae
commit
b6c95290cb
2 changed files with 15 additions and 4 deletions
|
|
@ -163,8 +163,10 @@ def create_action(self, spec=None, attr='qaction', shortcut_name=None):
|
|||
else:
|
||||
action = QAction(text, self.gui)
|
||||
if attr == 'qaction':
|
||||
mt = (action.text() if self.action_menu_clone_qaction is True else
|
||||
unicode_type(self.action_menu_clone_qaction))
|
||||
if hasattr(self.action_menu_clone_qaction, 'rstrip'):
|
||||
mt = unicode_type(self.action_menu_clone_qaction)
|
||||
else:
|
||||
mt = action.text()
|
||||
self.menuless_qaction = ma = QAction(action.icon(), mt, self.gui)
|
||||
ma.triggered.connect(action.trigger)
|
||||
for a in ((action, ma) if attr == 'qaction' else (action,)):
|
||||
|
|
@ -198,6 +200,7 @@ def create_action(self, spec=None, attr='qaction', shortcut_name=None):
|
|||
shortcut_action.setShortcuts([QKeySequence(key,
|
||||
QKeySequence.PortableText) for key in keys])
|
||||
else:
|
||||
self.shortcut_action_for_context_menu = shortcut_action
|
||||
if isosx:
|
||||
# In Qt 5 keyboard shortcuts dont work unless the
|
||||
# action is explicitly added to the main window
|
||||
|
|
|
|||
|
|
@ -410,7 +410,11 @@ def populate_menu(m, items, iactions):
|
|||
if what is None:
|
||||
m.addSeparator()
|
||||
elif what in iactions:
|
||||
m.addAction(CloneAction(iactions[what].qaction, m))
|
||||
ia = iactions[what]
|
||||
ac = ia.qaction
|
||||
if not ac.menu() and hasattr(ia, 'shortcut_action_for_context_menu'):
|
||||
ac = ia.shortcut_action_for_context_menu
|
||||
m.addAction(CloneAction(ac, m))
|
||||
|
||||
class MenuBar(QObject):
|
||||
|
||||
|
|
@ -499,7 +503,11 @@ def populate_menu(m, items, iactions):
|
|||
if what is None:
|
||||
m.addSeparator()
|
||||
elif what in iactions:
|
||||
m.addAction(iactions[what].qaction)
|
||||
ia = iactions[what]
|
||||
ac = ia.qaction
|
||||
if not ac.menu() and hasattr(ia, 'shortcut_action_for_context_menu'):
|
||||
ac = ia.shortcut_action_for_context_menu
|
||||
m.addAction(ac)
|
||||
|
||||
from calibre.gui2.dbus_export.widgets import factory
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue