mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show shortcuts in top level context menu
This commit is contained in:
parent
3247c8b6ae
commit
b6c95290cb
@ -163,8 +163,10 @@ class InterfaceAction(QObject):
|
|||||||
else:
|
else:
|
||||||
action = QAction(text, self.gui)
|
action = QAction(text, self.gui)
|
||||||
if attr == 'qaction':
|
if attr == 'qaction':
|
||||||
mt = (action.text() if self.action_menu_clone_qaction is True else
|
if hasattr(self.action_menu_clone_qaction, 'rstrip'):
|
||||||
unicode_type(self.action_menu_clone_qaction))
|
mt = unicode_type(self.action_menu_clone_qaction)
|
||||||
|
else:
|
||||||
|
mt = action.text()
|
||||||
self.menuless_qaction = ma = QAction(action.icon(), mt, self.gui)
|
self.menuless_qaction = ma = QAction(action.icon(), mt, self.gui)
|
||||||
ma.triggered.connect(action.trigger)
|
ma.triggered.connect(action.trigger)
|
||||||
for a in ((action, ma) if attr == 'qaction' else (action,)):
|
for a in ((action, ma) if attr == 'qaction' else (action,)):
|
||||||
@ -198,6 +200,7 @@ class InterfaceAction(QObject):
|
|||||||
shortcut_action.setShortcuts([QKeySequence(key,
|
shortcut_action.setShortcuts([QKeySequence(key,
|
||||||
QKeySequence.PortableText) for key in keys])
|
QKeySequence.PortableText) for key in keys])
|
||||||
else:
|
else:
|
||||||
|
self.shortcut_action_for_context_menu = shortcut_action
|
||||||
if isosx:
|
if isosx:
|
||||||
# In Qt 5 keyboard shortcuts dont work unless the
|
# In Qt 5 keyboard shortcuts dont work unless the
|
||||||
# action is explicitly added to the main window
|
# action is explicitly added to the main window
|
||||||
|
@ -410,7 +410,11 @@ if isosx:
|
|||||||
if what is None:
|
if what is None:
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
elif what in iactions:
|
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):
|
class MenuBar(QObject):
|
||||||
|
|
||||||
@ -499,7 +503,11 @@ else:
|
|||||||
if what is None:
|
if what is None:
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
elif what in iactions:
|
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
|
from calibre.gui2.dbus_export.widgets import factory
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user