mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
UI for setting the read mode preference
This commit is contained in:
parent
f4b6f52efe
commit
6eac8fd175
@ -9,6 +9,7 @@ from elementmaker import E
|
|||||||
|
|
||||||
CONTAINER = unique_id('reader-page-layout')
|
CONTAINER = unique_id('reader-page-layout')
|
||||||
MARGINS = unique_id('reader-page-margins')
|
MARGINS = unique_id('reader-page-margins')
|
||||||
|
READ_MODE = unique_id('read-mode')
|
||||||
|
|
||||||
add_extra_css(def():
|
add_extra_css(def():
|
||||||
sel = '#' + MARGINS
|
sel = '#' + MARGINS
|
||||||
@ -21,13 +22,27 @@ def create_layout_panel(container):
|
|||||||
container.appendChild(E.div(id=CONTAINER))
|
container.appendChild(E.div(id=CONTAINER))
|
||||||
container = container.lastChild
|
container = container.lastChild
|
||||||
sd = get_session_data()
|
sd = get_session_data()
|
||||||
container.appendChild(E.p(_('Change the page margins below'), style='margin:1ex 1em; padding: 1ex 0'))
|
container.appendChild(E.p(_('Change the page margins below'), style='margin:1ex 1rem; padding: 1ex 0'))
|
||||||
container.appendChild(E.table(id=MARGINS))
|
container.appendChild(E.table(id=MARGINS))
|
||||||
labels = {'top':_('Top:'), 'bottom':_('Bottom:'), 'left':_('Left:'), 'right':_('Right:')}
|
labels = {'top':_('Top:'), 'bottom':_('Bottom:'), 'left':_('Left:'), 'right':_('Right:')}
|
||||||
for which in 'top bottom left right'.split(' '):
|
for which in 'top bottom left right'.split(' '):
|
||||||
container.lastChild.appendChild(E.tr(
|
container.lastChild.appendChild(E.tr(
|
||||||
E.td(labels[which]), E.td(E.input(type='number', min='0', step='1', name=which, value=str(sd.get('margin_'+which))))
|
E.td(labels[which]), E.td(E.input(type='number', min='0', step='1', name=which, value=str(sd.get('margin_'+which))))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
container.appendChild(E.div(
|
||||||
|
_('Choose the page layout mode. In paged mode, the text is split up into individual pages, as in a paper book. In flow mode'
|
||||||
|
' text is presented as one long scrolling page, as in web browsers.'),
|
||||||
|
style='margin: 1ex 1rem; padding-top:1ex; border-top: solid 1px'))
|
||||||
|
container.appendChild(E.div(id=READ_MODE, style='margin: 1ex 1rem; display: flex; justify-content: space-between'))
|
||||||
|
rm = sd.get('read_mode')
|
||||||
|
rm = 'flow' if rm is 'flow' else 'paged'
|
||||||
|
def rb(name, text):
|
||||||
|
d = container.lastChild
|
||||||
|
d.appendChild(E.label(E.input(type='radio', name='page-layout-mode', checked=rm is name), text))
|
||||||
|
rb('paged', _('Paged mode'))
|
||||||
|
rb('flow', _('Flow mode'))
|
||||||
|
|
||||||
develop = create_layout_panel
|
develop = create_layout_panel
|
||||||
|
|
||||||
|
|
||||||
@ -43,5 +58,12 @@ def commit_layout(onchange, container):
|
|||||||
if val is not sd.get('margin_' + which):
|
if val is not sd.get('margin_' + which):
|
||||||
was_changed = True
|
was_changed = True
|
||||||
sd.set('margin_' + which, val)
|
sd.set('margin_' + which, val)
|
||||||
|
rm = sd.get('read_mode')
|
||||||
|
rm = 'flow' if rm is 'flow' else 'paged'
|
||||||
|
crm = 'paged' if element(READ_MODE, 'input').checked else 'flow'
|
||||||
|
if rm is not crm:
|
||||||
|
was_changed = True
|
||||||
|
sd.set('read_mode', crm)
|
||||||
|
|
||||||
if was_changed:
|
if was_changed:
|
||||||
onchange()
|
onchange()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user