mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update shortcut in tooltips of layout buttons
This commit is contained in:
parent
8ccdd923b9
commit
0dc431952d
@ -338,6 +338,7 @@ class GridViewButton(LayoutButton): # {{{
|
||||
gui.keyboard.register_shortcut('grid view toggle' + self.label, unicode(self.action_toggle.text()),
|
||||
default_keys=(sc,), action=self.action_toggle)
|
||||
self.action_toggle.triggered.connect(self.toggle)
|
||||
self.action_toggle.changed.connect(self.update_shortcut)
|
||||
self.toggled.connect(self.update_state)
|
||||
|
||||
def update_state(self, checked):
|
||||
@ -367,6 +368,7 @@ class SearchBarButton(LayoutButton): # {{{
|
||||
gui.keyboard.register_shortcut('search bar toggle' + self.label, unicode(self.action_toggle.text()),
|
||||
default_keys=(sc,), action=self.action_toggle)
|
||||
self.action_toggle.triggered.connect(self.toggle)
|
||||
self.action_toggle.changed.connect(self.update_shortcut)
|
||||
self.toggled.connect(self.update_state)
|
||||
|
||||
def update_state(self, checked):
|
||||
|
@ -965,9 +965,15 @@ class LayoutButton(QToolButton):
|
||||
if splitter is not None:
|
||||
splitter.state_changed.connect(self.update_state)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self.shortcut = ''
|
||||
if shortcut:
|
||||
self.shortcut = shortcut
|
||||
self.shortcut = shortcut or ''
|
||||
|
||||
def update_shortcut(self, action_toggle=None):
|
||||
action_toggle = action_toggle or getattr(self, 'action_toggle', None)
|
||||
if action_toggle:
|
||||
sc = action_toggle.shortcut()
|
||||
if sc:
|
||||
sc = sc.toString(sc.NativeText)
|
||||
self.shortcut = sc or ''
|
||||
|
||||
def set_state_to_show(self, *args):
|
||||
self.setChecked(False)
|
||||
@ -1036,6 +1042,7 @@ class Splitter(QSplitter):
|
||||
if shortcut is not None:
|
||||
self.action_toggle = QAction(QIcon(icon), _('Toggle') + ' ' + label,
|
||||
self)
|
||||
self.action_toggle.changed.connect(self.update_shortcut)
|
||||
self.action_toggle.triggered.connect(self.toggle_triggered)
|
||||
if parent is not None:
|
||||
parent.addAction(self.action_toggle)
|
||||
@ -1048,6 +1055,9 @@ class Splitter(QSplitter):
|
||||
else:
|
||||
self.action_toggle.setShortcut(shortcut)
|
||||
|
||||
def update_shortcut(self):
|
||||
self.button.update_shortcut(self.action_toggle)
|
||||
|
||||
def toggle_triggered(self, *args):
|
||||
self.toggle_side_pane()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user