mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix changes to keyboard shortcuts not being applied until viewer is restarted. Fixes #1851045 [Change the shortcut for word lookup does not work](https://bugs.launchpad.net/calibre/+bug/1851045)
This commit is contained in:
parent
0b05e33224
commit
21de8718d7
@ -425,7 +425,10 @@ class PrefsOverlay: # {{{
|
||||
def show(self, container):
|
||||
self.changes_occurred = False
|
||||
container.style.backgroundColor = get_color('window-background')
|
||||
self.prefs = create_prefs_panel(container, self.overlay.hide_current_panel, def():self.changes_occurred=True;)
|
||||
self.prefs = create_prefs_panel(container, self.overlay.hide_current_panel, self.on_change)
|
||||
|
||||
def on_change(self):
|
||||
self.changes_occurred = True
|
||||
|
||||
def handle_escape(self):
|
||||
self.prefs.onclose()
|
||||
|
@ -145,7 +145,7 @@ def customize_shortcut(sc_name):
|
||||
|
||||
|
||||
|
||||
def create_keyboard_panel(container, close_func, onchange):
|
||||
def create_keyboard_panel(container, apply_func, cancel_func, onchange):
|
||||
create_keyboard_panel.onchange = onchange
|
||||
container.appendChild(E.div(id=unique_id('keyboard-settings'), style='margin: 1rem'))
|
||||
container = container.lastChild
|
||||
@ -168,7 +168,7 @@ def create_keyboard_panel(container, close_func, onchange):
|
||||
create_item_list(container.lastChild, items)
|
||||
|
||||
container.appendChild(E.div(
|
||||
style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults.bind(None, close_func))
|
||||
style='margin-top: 1rem', create_button(_('Restore defaults'), action=restore_defaults.bind(None, apply_func))
|
||||
))
|
||||
|
||||
|
||||
|
@ -55,9 +55,12 @@ class Prefs:
|
||||
else:
|
||||
self.close_func()
|
||||
|
||||
def create_panel(self, container, which, create_func):
|
||||
def create_panel(self, container, which, create_func, needs_onchange):
|
||||
document.getElementById(self.title_id).textContent = self.title_map[which] or which
|
||||
create_func(container, self.onclose, self.cancel)
|
||||
if needs_onchange:
|
||||
create_func(container, self.onclose, self.cancel, self.onchange)
|
||||
else:
|
||||
create_func(container, self.onclose, self.cancel)
|
||||
|
||||
@property
|
||||
def container(self):
|
||||
@ -131,7 +134,7 @@ class Prefs:
|
||||
commit_head_foot(self.onchange, self.container)
|
||||
|
||||
def display_keyboard(self, container):
|
||||
self.create_panel(container, 'keyboard', create_keyboard_panel)
|
||||
self.create_panel(container, 'keyboard', create_keyboard_panel, True)
|
||||
|
||||
def close_keyboard(self):
|
||||
commit_keyboard(self.onchange, self.container)
|
||||
|
Loading…
x
Reference in New Issue
Block a user