mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-09-29 15:31:08 -04:00
Preferences: Show the keyboard shortcut for each category in preferences in the tooltip. Fixes #2122257 [[Enhancement] show preferences shortcuts](https://bugs.launchpad.net/calibre/+bug/2122257)
This commit is contained in:
parent
f92bfac622
commit
40f5df12cf
@ -42,6 +42,7 @@ class PreferencesAction(InterfaceAction):
|
||||
self.preferences_menu = pm
|
||||
for x in (self.gui.preferences_action, self.qaction):
|
||||
x.triggered.connect(self.do_config)
|
||||
self.action_map = {}
|
||||
|
||||
def initialization_complete(self):
|
||||
# Add the individual preferences to the menu.
|
||||
@ -60,7 +61,7 @@ class PreferencesAction(InterfaceAction):
|
||||
current_cat = p.category_order
|
||||
cm = pm.addMenu(p.gui_category.replace('&', '&&'))
|
||||
cm.setIcon(config_icon)
|
||||
self.create_menu_action(cm, p.name, p.gui_name.replace('&', '&&'),
|
||||
self.action_map[p.name] = self.create_menu_action(cm, p.name, p.gui_name.replace('&', '&&'),
|
||||
icon=QIcon.ic(p.icon), shortcut=None, shortcut_name=p.gui_name,
|
||||
triggered=partial(self.do_config, initial_plugin=(p.category, p.name),
|
||||
close_after_initial=True))
|
||||
|
@ -18,6 +18,7 @@ from qt.core import (
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
QIcon,
|
||||
QKeySequence,
|
||||
QLabel,
|
||||
QPainter,
|
||||
QPointF,
|
||||
@ -150,10 +151,16 @@ class Category(QWidget): # {{{
|
||||
self.bar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
|
||||
self._layout.addWidget(self.bar)
|
||||
self.actions = []
|
||||
from calibre.gui2.ui import get_gui
|
||||
iac = get_gui().iactions['Preferences']
|
||||
for p in plugins:
|
||||
sc = iac.action_map.get(p.name).shortcut().toString(QKeySequence.SequenceFormat.NativeText)
|
||||
target = partial(self.triggered, p)
|
||||
ac = self.bar.addAction(QIcon.ic(p.icon), p.gui_name.replace('&', '&&'), target)
|
||||
ac.setToolTip(textwrap.fill(p.description))
|
||||
tt = '<p>' + p.description
|
||||
if sc:
|
||||
tt += '<br>' + _('Shortcut: <i>{}').format(sc)
|
||||
ac.setToolTip(tt)
|
||||
ac.setWhatsThis(textwrap.fill(p.description))
|
||||
ac.setStatusTip(p.description)
|
||||
self.actions.append(ac)
|
||||
|
Loading…
x
Reference in New Issue
Block a user