mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
UI for cols_per_screen preferences
This commit is contained in:
parent
6eac8fd175
commit
924caf3d68
@ -10,6 +10,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')
|
READ_MODE = unique_id('read-mode')
|
||||||
|
COLS = unique_id('cols-per-screen')
|
||||||
|
|
||||||
add_extra_css(def():
|
add_extra_css(def():
|
||||||
sel = '#' + MARGINS
|
sel = '#' + MARGINS
|
||||||
@ -22,7 +23,7 @@ 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 1rem; padding: 1ex 0'))
|
container.appendChild(E.p(_('Change the page margins (in pixels) 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(' '):
|
||||||
@ -43,6 +44,16 @@ def create_layout_panel(container):
|
|||||||
rb('paged', _('Paged mode'))
|
rb('paged', _('Paged mode'))
|
||||||
rb('flow', _('Flow mode'))
|
rb('flow', _('Flow mode'))
|
||||||
|
|
||||||
|
container.appendChild(E.div(
|
||||||
|
_('In paged mode, control the number of pages per screen. A setting of zero means the number of pages is'
|
||||||
|
' set based on the screen size.'),
|
||||||
|
style='margin: 1ex 1rem; padding-top:1ex; border-top: solid 1px'))
|
||||||
|
cps = sd.get('columns_per_screen')
|
||||||
|
container.appendChild(E.table(style='margin: 1ex 1rem', id=COLS,
|
||||||
|
E.tr(E.td(_('In portrait orientation:')), E.td(E.input(type='number', name='portrait', min='0', step='1', max='20', value=str(cps.portrait)))),
|
||||||
|
E.tr(E.td(_('In landscape orientation:')), E.td(E.input(type='number', name='landscape', min='0', step='1', max='20', value=str(cps.landscape)))),
|
||||||
|
))
|
||||||
|
|
||||||
develop = create_layout_panel
|
develop = create_layout_panel
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +75,17 @@ def commit_layout(onchange, container):
|
|||||||
if rm is not crm:
|
if rm is not crm:
|
||||||
was_changed = True
|
was_changed = True
|
||||||
sd.set('read_mode', crm)
|
sd.set('read_mode', crm)
|
||||||
|
cps = sd.get('columns_per_screen')
|
||||||
|
for which in ('portrait', 'landscape'):
|
||||||
|
inp = element(COLS, 'input[name={}]'.format(which))
|
||||||
|
try:
|
||||||
|
val = int(inp.value)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
if cps[which] is not val:
|
||||||
|
cps[which] = val
|
||||||
|
sd.set('columns_per_screen', cps)
|
||||||
|
was_changed = True
|
||||||
|
|
||||||
if was_changed:
|
if was_changed:
|
||||||
onchange()
|
onchange()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user