mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Apply changes to reader preferences when the preferences panel is closed
This commit is contained in:
parent
fdb50deca9
commit
1cc40a335e
@ -113,6 +113,9 @@ class Boss:
|
|||||||
def reload_book(self):
|
def reload_book(self):
|
||||||
self.read_ui.reload_book()
|
self.read_ui.reload_book()
|
||||||
|
|
||||||
|
def redisplay_book(self):
|
||||||
|
self.read_ui.redisplay_book()
|
||||||
|
|
||||||
def return_to_book_list(self, book_id):
|
def return_to_book_list(self, book_id):
|
||||||
# Note that book_id could refer to a deleted book, that is, a book no
|
# Note that book_id could refer to a deleted book, that is, a book no
|
||||||
# longer in local storage
|
# longer in local storage
|
||||||
|
@ -192,7 +192,9 @@ class MainOverlay:
|
|||||||
self.timer = setInterval(self.update_time, 1000)
|
self.timer = setInterval(self.update_time, 1000)
|
||||||
|
|
||||||
def update_time(self):
|
def update_time(self):
|
||||||
document.getElementById(self.timer_id).textContent = self.date_formatter.format(Date())
|
tm = document.getElementById(self.timer_id)
|
||||||
|
if tm:
|
||||||
|
tm.textContent = self.date_formatter.format(Date())
|
||||||
|
|
||||||
def on_hide(self):
|
def on_hide(self):
|
||||||
if self.timer is not None:
|
if self.timer is not None:
|
||||||
@ -233,13 +235,20 @@ class PrefsOverlay: # {{{
|
|||||||
|
|
||||||
def __init__(self, overlay):
|
def __init__(self, overlay):
|
||||||
self.overlay = overlay
|
self.overlay = overlay
|
||||||
|
self.changes_occurred = False
|
||||||
|
|
||||||
def on_container_click(self, evt):
|
def on_container_click(self, evt):
|
||||||
pass # Dont allow panel to be closed by a click
|
pass # Dont allow panel to be closed by a click
|
||||||
|
|
||||||
def show(self, container):
|
def show(self, container):
|
||||||
|
self.changes_occurred = False
|
||||||
container.style.backgroundColor = get_color('window-background')
|
container.style.backgroundColor = get_color('window-background')
|
||||||
create_prefs_panel(container, self.overlay.hide_current_panel)
|
create_prefs_panel(container, self.overlay.hide_current_panel, def():self.changes_occurred=True;)
|
||||||
|
|
||||||
|
def on_hide(self):
|
||||||
|
if self.changes_occurred:
|
||||||
|
self.changes_occurred = False
|
||||||
|
get_boss().redisplay_book()
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -317,5 +326,5 @@ class Overlay:
|
|||||||
self.show_current_panel()
|
self.show_current_panel()
|
||||||
|
|
||||||
def show_prefs(self):
|
def show_prefs(self):
|
||||||
self.panels.push(PrefsOverlay(self))
|
self.panels = [PrefsOverlay(self)]
|
||||||
self.show_current_panel()
|
self.show_current_panel()
|
||||||
|
@ -11,10 +11,10 @@ from read_book.prefs.colors import create_colors_panel, commit_colors
|
|||||||
|
|
||||||
class Prefs:
|
class Prefs:
|
||||||
|
|
||||||
def __init__(self, container, close_func):
|
def __init__(self, container, close_func, on_change):
|
||||||
self.close_func = close_func
|
self.close_func = close_func
|
||||||
self.changes_occurred = False
|
self.on_change = on_change
|
||||||
title = E.h2(_('Configure book reader'))
|
title = E.h2()
|
||||||
self.title_id = ensure_id(title)
|
self.title_id = ensure_id(title)
|
||||||
container.appendChild(E.div(
|
container.appendChild(E.div(
|
||||||
style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor',
|
style='display: flex; justify-content: space-between; padding: 1ex 1em; border-bottom: solid 1px currentColor',
|
||||||
@ -27,7 +27,7 @@ class Prefs:
|
|||||||
self.display_top(container.lastChild)
|
self.display_top(container.lastChild)
|
||||||
|
|
||||||
def onchange(self):
|
def onchange(self):
|
||||||
self.changes_occurred = True
|
self.on_change()
|
||||||
|
|
||||||
def onclose(self):
|
def onclose(self):
|
||||||
if self.stack.length > 1:
|
if self.stack.length > 1:
|
||||||
@ -53,6 +53,7 @@ class Prefs:
|
|||||||
self.display_panel(which)
|
self.display_panel(which)
|
||||||
|
|
||||||
def display_top(self, container):
|
def display_top(self, container):
|
||||||
|
document.getElementById(self.title_id).textContent = _('Configure book reader')
|
||||||
c = E.div()
|
c = E.div()
|
||||||
container.appendChild(c)
|
container.appendChild(c)
|
||||||
build_list(c, [
|
build_list(c, [
|
||||||
@ -71,5 +72,5 @@ class Prefs:
|
|||||||
document.getElementById(self.title_id).textContent = _('Page Layout')
|
document.getElementById(self.title_id).textContent = _('Page Layout')
|
||||||
|
|
||||||
|
|
||||||
def create_prefs_panel(container, close_func):
|
def create_prefs_panel(container, close_func, on_change):
|
||||||
Prefs(container, close_func)
|
Prefs(container, close_func, on_change)
|
||||||
|
@ -107,6 +107,9 @@ class ReadUI:
|
|||||||
metadata = self.metadata or self.interface_data.metadata[book_id]
|
metadata = self.metadata or self.interface_data.metadata[book_id]
|
||||||
self.load_book(book_id, self.base_url_data.fmt, metadata, True)
|
self.load_book(book_id, self.base_url_data.fmt, metadata, True)
|
||||||
|
|
||||||
|
def redisplay_book(self):
|
||||||
|
self.view.redisplay_book()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url_data(self):
|
def url_data(self):
|
||||||
ans = {'book_id':self.base_url_data.book_id, 'fmt': self.base_url_data.fmt}
|
ans = {'book_id':self.base_url_data.book_id, 'fmt': self.base_url_data.fmt}
|
||||||
|
@ -233,6 +233,9 @@ class View:
|
|||||||
pos.type, pos.cfi = 'cfi', '/' + rest
|
pos.type, pos.cfi = 'cfi', '/' + rest
|
||||||
self.show_name(name, initial_position=pos)
|
self.show_name(name, initial_position=pos)
|
||||||
|
|
||||||
|
def redisplay_book(self):
|
||||||
|
self.display_book(self.book)
|
||||||
|
|
||||||
def show_name(self, name, initial_position=None):
|
def show_name(self, name, initial_position=None):
|
||||||
if self.currently_showing.loading:
|
if self.currently_showing.loading:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user