More work on in-server conversion UI

This commit is contained in:
Kovid Goyal 2018-07-02 14:45:10 +05:30
parent 166a425b35
commit 21163fb6b5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 19 additions and 5 deletions

View File

@ -219,7 +219,7 @@ def get_conversion_options(input_fmt, output_fmt, book_id, db):
plumber.get_option_by_name, OptionRecommendation.LOW, option_names) plumber.get_option_by_name, OptionRecommendation.LOW, option_names)
specifics.merge_recommendations( specifics.merge_recommendations(
plumber.get_option_by_name, OptionRecommendation.HIGH, option_names, only_existing=True) plumber.get_option_by_name, OptionRecommendation.HIGH, option_names, only_existing=True)
defaults = defs.as_dict() defaults = defs.as_dict()['options']
for k in defs: for k in defs:
if k in specifics: if k in specifics:
defs[k] = specifics[k] defs[k] = specifics[k]

View File

@ -46,8 +46,10 @@ def sanitize_accelerator(text):
return text.replace('&', '') return text.replace('&', '')
# }}} # }}}
def create_simple_widget(name, text, tooltip, input_widget_, getter, setter, reverse): # {{{ def create_simple_widget(name, text, tooltip, input_widget_, getter, setter, reverse=False, suffix=None): # {{{
if not text.endswith(':'): if get_option_default_value(name) is undefined:
raise KeyError(f'{name} is not a known option')
if not reverse and not text.endswith(':'):
text = text + ':' text = text + ':'
div = E.div( div = E.div(
data_option_name=name, data_option_name=name,
@ -57,8 +59,12 @@ def create_simple_widget(name, text, tooltip, input_widget_, getter, setter, rev
E.label(sanitize_accelerator(text) + '\xa0', input_widget_) E.label(sanitize_accelerator(text) + '\xa0', input_widget_)
) )
) )
if suffix:
div.firstChild.appendChild(document.createTextNode('\xa0' + suffix))
def straight_input_widget(container): def straight_input_widget(container):
if suffix:
return container.firstChild.lastChild.previousSibling
return container.firstChild.lastChild return container.firstChild.lastChild
def reverse_input_widget(container): def reverse_input_widget(container):
@ -114,7 +120,7 @@ def lineedit(name, text, tooltip): # {{{
) )
# }}} # }}}
def float_spin(name, text, tooltip=None, step=0.1, min=0, max=100): # {{{ def float_spin(name, text, tooltip=None, step=0.1, min=0, max=100, unit=None): # {{{
f = E.input(type='number', step=str(step), min=str(min), max=str(max), required=True) f = E.input(type='number', step=str(step), min=str(min), max=str(max), required=True)
defval = get_option_default_value(name) defval = get_option_default_value(name)
return create_simple_widget(name, text, tooltip, f, return create_simple_widget(name, text, tooltip, f,
@ -126,6 +132,8 @@ def float_spin(name, text, tooltip=None, step=0.1, min=0, max=100): # {{{
, ,
def setter(w, val): # noqa: unused-local def setter(w, val): # noqa: unused-local
w.value = str(float(val)) w.value = str(float(val))
,
suffix=unit
) )
# }}} # }}}
@ -159,8 +167,14 @@ def look_and_feel(container):
set_disabled(dname, disabled) set_disabled(dname, disabled)
) )
container.appendChild(checkbox('disable_font_rescaling', _('&Disable font size rescaling'))) container.appendChild(checkbox('disable_font_rescaling', _('&Disable font size rescaling')))
container.appendChild(float_spin('base_font_size', _('Base font si&ze:'), step=0.1, min=0, max=50)) container.appendChild(float_spin('base_font_size', _('Base font si&ze:'), max=50, unit='pt'))
container.appendChild(lineedit('font_size_mapping', _('Font size &key:'))) container.appendChild(lineedit('font_size_mapping', _('Font size &key:')))
container.appendChild(float_spin('minimum_line_height', _('Minim&um line height:'), max=900, unit='%'))
container.appendChild(float_spin('line_height', _('Line hei&ght:'), unit='%'))
container.appendChild(lineedit('embed_font_family', _('Embed font fami&ly:')))
container.appendChild(checkbox('embed_all_fonts', _('&Embed all fonts in document')))
container.appendChild(checkbox('subset_embedded_fonts', _('&Subset all embedded fonts')))
container.appendChild(checkbox('keep_ligatures', _('Keep &ligatures')))
# }}} # }}}