mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix margins not being adjusted immediately when preferences are changed
This commit is contained in:
parent
1fd071971b
commit
5765cd3007
@ -152,22 +152,26 @@ def show_controls_help():
|
||||
# }}}
|
||||
|
||||
|
||||
def maximum_font_size():
|
||||
ans = maximum_font_size.ans
|
||||
def body_font_size():
|
||||
ans = body_font_size.ans
|
||||
if not ans:
|
||||
q = window.getComputedStyle(document.body).fontSize
|
||||
if q and q.endsWith('px'):
|
||||
q = parseInt(q)
|
||||
if q and not isNaN(q):
|
||||
ans = maximum_font_size.ans = q
|
||||
ans = body_font_size.ans = q
|
||||
return ans
|
||||
ans = maximum_font_size.ans = 12
|
||||
ans = body_font_size.ans = 12
|
||||
return ans
|
||||
|
||||
|
||||
def header_footer_font_size(sz):
|
||||
return min(max(0, sz - 6), body_font_size())
|
||||
|
||||
|
||||
def margin_elem(sd, which, id, onclick, oncontextmenu):
|
||||
sz = sd.get(which, 20)
|
||||
fsz = min(max(0, sz - 6), maximum_font_size())
|
||||
fsz = header_footer_font_size(sz)
|
||||
s = '; text-overflow: ellipsis; white-space: nowrap; overflow: hidden'
|
||||
ans = E.div(
|
||||
style=f'height:{sz}px; overflow: hidden; font-size:{fsz}px; width:100%; padding: 0; display: flex; justify-content: space-between; align-items: center; user-select: none',
|
||||
@ -782,8 +786,8 @@ class View:
|
||||
extra = (tw - max_text_width) // 2
|
||||
margin_left += extra
|
||||
margin_right += extra
|
||||
set_css(document.getElementById('book-top-margin'), height=margin_top + 'px')
|
||||
set_css(document.getElementById('book-bottom-margin'), height=margin_bottom + 'px')
|
||||
set_css(document.getElementById('book-top-margin'), height=margin_top + 'px', font_size=header_footer_font_size(margin_top) + 'px')
|
||||
set_css(document.getElementById('book-bottom-margin'), height=margin_bottom + 'px', font_size=header_footer_font_size(margin_bottom) + 'px')
|
||||
def side_margin(which, val):
|
||||
m = document.getElementById('book-{}-margin'.format(which))
|
||||
if which is 'left':
|
||||
@ -969,6 +973,7 @@ class View:
|
||||
sd.set('controls_help_shown_count' + ('_rtl_page_progression' if rtl_page_progression() else ''), c + 1)
|
||||
|
||||
def preferences_changed(self):
|
||||
self.set_margins()
|
||||
ui_operations.update_url_state(True)
|
||||
ui_operations.redisplay_book()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user