mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Get changing font size and colors working
This commit is contained in:
parent
9edb593773
commit
98ecf220e6
@ -33,9 +33,3 @@ def get_translations(val):
|
||||
if val:
|
||||
get_translations.ans = val
|
||||
return get_translations.ans
|
||||
|
||||
|
||||
def get_read_ui(val):
|
||||
if val:
|
||||
get_read_ui.ans = val
|
||||
return get_read_ui.ans
|
||||
|
@ -16,7 +16,7 @@ from book_list.constants import book_list_container_id, read_book_container_id,
|
||||
from book_list.library_data import fetch_init_data, update_library_data, url_books_query
|
||||
from book_list.theme import get_color, get_font_family
|
||||
from book_list.router import update_window_title, set_default_mode_handler, apply_url, set_mode_handler, on_pop_state
|
||||
from book_list.globals import get_db, set_session_data, get_read_ui
|
||||
from book_list.globals import get_db, set_session_data
|
||||
from book_list.ui import apply_url_state as book_list_mode_handler
|
||||
from read_book.ui import ReadUI
|
||||
|
||||
@ -76,7 +76,6 @@ def init_ui():
|
||||
read_ui = ReadUI()
|
||||
get_db(read_ui.db)
|
||||
set_mode_handler('read_book', read_ui.apply_url_state.bind(read_ui))
|
||||
get_read_ui(read_ui)
|
||||
apply_url()
|
||||
|
||||
|
||||
|
@ -75,4 +75,6 @@ ui_operations = {
|
||||
'redisplay_book': None,
|
||||
'reload_book': None,
|
||||
'forward_gesture': None,
|
||||
'update_color_scheme': None,
|
||||
'update_font_size': None,
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ from __python__ import hash_literals, bound_methods
|
||||
from gettext import gettext as _
|
||||
from dom import svgicon, set_css, add_extra_css, build_rule, clear, unique_id
|
||||
from elementmaker import E
|
||||
from book_list.globals import get_session_data, get_read_ui
|
||||
from read_book.globals import default_color_schemes
|
||||
from book_list.globals import get_session_data
|
||||
from read_book.globals import default_color_schemes, ui_operations
|
||||
from modals import error_dialog
|
||||
from widgets import create_button
|
||||
|
||||
@ -220,4 +220,4 @@ def commit_colors(onchange):
|
||||
if rcs.foreground is not c.dataset.fg or rcs.background is not c.dataset.bg:
|
||||
sd = get_session_data()
|
||||
sd.set('current_color_scheme', ccs)
|
||||
get_read_ui().update_color_scheme()
|
||||
ui_operations.update_color_scheme()
|
||||
|
@ -1,13 +1,15 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from __python__ import hash_literals, bound_methods
|
||||
from __python__ import bound_methods, hash_literals
|
||||
|
||||
from dom import unique_id, set_css, add_extra_css, rule, element
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
from widgets import create_button
|
||||
from book_list.globals import get_session_data, get_read_ui
|
||||
|
||||
from book_list.globals import get_session_data
|
||||
from book_list.theme import get_color
|
||||
from dom import add_extra_css, element, rule, set_css, unique_id
|
||||
from read_book.globals import ui_operations
|
||||
from widgets import create_button
|
||||
|
||||
CONTAINER = unique_id('font-size-prefs')
|
||||
QUICK = unique_id('quick')
|
||||
@ -23,7 +25,7 @@ def change_font_size(sz):
|
||||
sd = get_session_data()
|
||||
if sd.get('base_font_size') is not sz:
|
||||
sd.set('base_font_size', sz)
|
||||
get_read_ui().update_font_size()
|
||||
ui_operations.update_font_size()
|
||||
|
||||
def set_quick_size(ev):
|
||||
li = ev.currentTarget
|
||||
|
@ -63,6 +63,8 @@ class ReadUI:
|
||||
ui_operations.redisplay_book = self.redisplay_book.bind(self)
|
||||
ui_operations.reload_book = self.reload_book.bind(self)
|
||||
ui_operations.forward_gesture = self.forward_gesture.bind(self)
|
||||
ui_operations.update_color_scheme = self.update_color_scheme.bind(self)
|
||||
ui_operations.update_font_size = self.update_font_size.bind(self)
|
||||
|
||||
def on_resize(self):
|
||||
self.view.on_resize()
|
||||
|
@ -218,6 +218,14 @@ def forward_gesture(gesture):
|
||||
view.forward_gesture(gesture)
|
||||
|
||||
|
||||
def update_color_scheme():
|
||||
view.update_color_scheme()
|
||||
|
||||
|
||||
def update_font_size():
|
||||
view.update_font_size()
|
||||
|
||||
|
||||
if window is window.top:
|
||||
# main
|
||||
ui_operations.get_file = get_file
|
||||
@ -227,6 +235,8 @@ if window is window.top:
|
||||
ui_operations.redisplay_book = redisplay_book
|
||||
ui_operations.reload_book = reload_book
|
||||
ui_operations.forward_gesture = forward_gesture
|
||||
ui_operations.update_color_scheme = update_color_scheme
|
||||
ui_operations.update_font_size = update_font_size
|
||||
document.body.appendChild(E.div(id='view'))
|
||||
window.onerror = onerror
|
||||
create_modal_container()
|
||||
|
Loading…
x
Reference in New Issue
Block a user