mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
UI for showing data in side margins
This commit is contained in:
parent
d768e69e2a
commit
3b45583ddb
@ -46,12 +46,20 @@ def create_item(region, label):
|
|||||||
|
|
||||||
|
|
||||||
def create_items(which):
|
def create_items(which):
|
||||||
ans = E.table(
|
if which is 'header' or which is 'footer':
|
||||||
data_which=which,
|
ans = E.table(
|
||||||
create_item('left', _('Left')),
|
data_which=which,
|
||||||
create_item('middle', _('Middle')),
|
create_item('left', _('Left')),
|
||||||
create_item('right', _('Right'))
|
create_item('middle', _('Middle')),
|
||||||
)
|
create_item('right', _('Right'))
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
ans = E.table(
|
||||||
|
data_which=which,
|
||||||
|
create_item('left', _('Top')),
|
||||||
|
create_item('middle', _('Middle')),
|
||||||
|
create_item('right', _('Bottom'))
|
||||||
|
)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +87,7 @@ def get_setting(table):
|
|||||||
|
|
||||||
def restore_defaults():
|
def restore_defaults():
|
||||||
container = document.getElementById(CONTAINER)
|
container = document.getElementById(CONTAINER)
|
||||||
for which in 'header footer'.split(' '):
|
for which in 'header footer left-margin right-margin'.split(' '):
|
||||||
table = container.querySelector(f'table[data-which={which}]')
|
table = container.querySelector(f'table[data-which={which}]')
|
||||||
apply_setting(table, defaults[which] or {})
|
apply_setting(table, defaults[which] or {})
|
||||||
|
|
||||||
@ -92,9 +100,15 @@ def create_head_foot_panel(container, apply_func, cancel_func):
|
|||||||
container.appendChild(E.hr())
|
container.appendChild(E.hr())
|
||||||
container.appendChild(E.h4(_('Footer'), style="margin: 1rem; margin-top: 0"))
|
container.appendChild(E.h4(_('Footer'), style="margin: 1rem; margin-top: 0"))
|
||||||
container.appendChild(create_items('footer'))
|
container.appendChild(create_items('footer'))
|
||||||
|
container.appendChild(E.hr())
|
||||||
|
container.appendChild(E.h4(_('Left margin'), style="margin: 1rem; margin-top: 0"))
|
||||||
|
container.appendChild(create_items('left-margin'))
|
||||||
|
container.appendChild(E.hr())
|
||||||
|
container.appendChild(E.h4(_('Right margin'), style="margin: 1rem; margin-top: 0"))
|
||||||
|
container.appendChild(create_items('right-margin'))
|
||||||
|
|
||||||
sd = get_session_data()
|
sd = get_session_data()
|
||||||
for which in 'header footer'.split(' '):
|
for which in 'header footer left-margin right-margin'.split(' '):
|
||||||
table = container.querySelector(f'table[data-which={which}]')
|
table = container.querySelector(f'table[data-which={which}]')
|
||||||
apply_setting(table, sd.get(which) or {})
|
apply_setting(table, sd.get(which) or {})
|
||||||
container.appendChild(E.div(style='margin: 1rem', create_button_box(restore_defaults, apply_func, cancel_func)))
|
container.appendChild(E.div(style='margin: 1rem', create_button_box(restore_defaults, apply_func, cancel_func)))
|
||||||
@ -103,7 +117,7 @@ def create_head_foot_panel(container, apply_func, cancel_func):
|
|||||||
def commit_head_foot(onchange, container):
|
def commit_head_foot(onchange, container):
|
||||||
sd = get_session_data()
|
sd = get_session_data()
|
||||||
changed = False
|
changed = False
|
||||||
for which in 'header footer'.split(' '):
|
for which in 'header footer left-margin right-margin'.split(' '):
|
||||||
prev = sd.get(which) or {}
|
prev = sd.get(which) or {}
|
||||||
table = container.querySelector(f'table[data-which={which}]')
|
table = container.querySelector(f'table[data-which={which}]')
|
||||||
current = get_setting(table)
|
current = get_setting(table)
|
||||||
|
@ -35,6 +35,8 @@ defaults = {
|
|||||||
'current_color_scheme': 'system',
|
'current_color_scheme': 'system',
|
||||||
'footer': {'right': 'progress'},
|
'footer': {'right': 'progress'},
|
||||||
'header': {},
|
'header': {},
|
||||||
|
'left-margin': {},
|
||||||
|
'right-margin': {},
|
||||||
'hide_tooltips': False,
|
'hide_tooltips': False,
|
||||||
'keyboard_shortcuts': {},
|
'keyboard_shortcuts': {},
|
||||||
'lines_per_sec_auto': 1,
|
'lines_per_sec_auto': 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user