Viewer: Fix shortcut changes not being applied after pressing OK if shortcut list is closed by pressing Esc. Fixes #1846765 [ebook viewer preferences not saved](https://bugs.launchpad.net/calibre/+bug/1846765)

This commit is contained in:
Kovid Goyal 2019-10-04 22:39:09 +05:30
parent 67aca61d0c
commit 95c71e3cd0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -83,6 +83,7 @@ def close_customize_shortcut(apply_changes):
item.dataset.userData = JSON.stringify(q)
break
get_container().dataset.changed = 'true'
commit_keyboard(create_keyboard_panel.onchange)
def add_key_widget():
@ -143,7 +144,8 @@ def customize_shortcut(sc_name):
def create_keyboard_panel(container, close_func):
def create_keyboard_panel(container, close_func, onchange):
create_keyboard_panel.onchange = onchange
container.appendChild(E.div(id=unique_id('keyboard-settings'), style='margin: 1rem'))
container = container.lastChild
container.dataset.changed = 'false'
@ -189,5 +191,6 @@ def commit_keyboard(onchange):
if shortcuts_differ(q.shortcuts, SHORTCUTS[q.name].shortcuts):
vals[q.name] = q.shortcuts
sd.set('keyboard_shortcuts', vals)
create_keyboard_panel.onchange = None
if get_container().dataset.changed is 'true':
onchange()

View File

@ -124,7 +124,7 @@ class Prefs:
def display_keyboard(self, container):
document.getElementById(self.title_id).textContent = _('Keyboard shortcuts')
create_keyboard_panel(container, self.onclose)
create_keyboard_panel(container, self.onclose, self.onchange)
def close_keyboard(self):
commit_keyboard(self.onchange, self.container)