mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	Show profile descriptions
This commit is contained in:
		
							parent
							
								
									ef10150149
								
							
						
					
					
						commit
						f7eef4f54c
					
				@ -245,9 +245,18 @@ def get_conversion_options(input_fmt, output_fmt, book_id, db):
 | 
				
			|||||||
def profiles():
 | 
					def profiles():
 | 
				
			||||||
    ans = getattr(profiles, 'ans', None)
 | 
					    ans = getattr(profiles, 'ans', None)
 | 
				
			||||||
    if ans is None:
 | 
					    if ans is None:
 | 
				
			||||||
 | 
					        def desc(profile):
 | 
				
			||||||
 | 
					            w, h = profile.screen_size
 | 
				
			||||||
 | 
					            if w >= 10000:
 | 
				
			||||||
 | 
					                ss = _('unlimited')
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                ss = _('%(width)d x %(height)d pixels') % dict(width=w, height=h)
 | 
				
			||||||
 | 
					            ss = _('Screen size: %s') % ss
 | 
				
			||||||
 | 
					            return {'name': profile.name, 'description': ('%s [%s]' % (profile.description, ss))}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ans = profiles.ans = {}
 | 
					        ans = profiles.ans = {}
 | 
				
			||||||
        ans['input'] = {p.short_name: {'name': p.name} for p in input_profiles()}
 | 
					        ans['input'] = {p.short_name: desc(p) for p in input_profiles()}
 | 
				
			||||||
        ans['output'] = {p.short_name: {'name': p.name} for p in output_profiles()}
 | 
					        ans['output'] = {p.short_name: desc(p) for p in output_profiles()}
 | 
				
			||||||
    return ans
 | 
					    return ans
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ add_extra_css(def():
 | 
				
			|||||||
    style += build_rule(sel + '.simple-group > label > *', display='table-cell', padding_bottom='1ex', padding_right='1rem')
 | 
					    style += build_rule(sel + '.simple-group > label > *', display='table-cell', padding_bottom='1ex', padding_right='1rem')
 | 
				
			||||||
    style += build_rule(sel + 'label.vertical', display='block')
 | 
					    style += build_rule(sel + 'label.vertical', display='block')
 | 
				
			||||||
    style += build_rule(sel + 'label.vertical > *', display='block', padding_bottom='1ex', padding_right='1rem')
 | 
					    style += build_rule(sel + 'label.vertical > *', display='block', padding_bottom='1ex', padding_right='1rem')
 | 
				
			||||||
 | 
					    style += build_rule(sel + '[data-profile]', margin_left='2em', text_indent='-2em', font_size='smaller', margin_bottom='1ex')
 | 
				
			||||||
    return style
 | 
					    return style
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -280,6 +281,15 @@ def heuristics(container):
 | 
				
			|||||||
# Page setup {{{
 | 
					# Page setup {{{
 | 
				
			||||||
@ep
 | 
					@ep
 | 
				
			||||||
def page_setup(container):
 | 
					def page_setup(container):
 | 
				
			||||||
 | 
					    def show_profile_desc(name):
 | 
				
			||||||
 | 
					        profile = get(name)
 | 
				
			||||||
 | 
					        data = profiles.input if name is 'input_profile' else profiles.output
 | 
				
			||||||
 | 
					        profile = data[profile]
 | 
				
			||||||
 | 
					        container_for_option(name).parentNode.querySelector('[data-profile="{}"'.format(
 | 
				
			||||||
 | 
					            'input' if name is 'input_profile' else 'output')).textContent = indent + profile.description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    add_listener('input_profile', show_profile_desc)
 | 
				
			||||||
 | 
					    add_listener('output_profile', show_profile_desc)
 | 
				
			||||||
    g = E.div(class_='simple-group')
 | 
					    g = E.div(class_='simple-group')
 | 
				
			||||||
    container.appendChild(g)
 | 
					    container.appendChild(g)
 | 
				
			||||||
    g.appendChild(float_spin('margin_left', _('Left page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
					    g.appendChild(float_spin('margin_left', _('Left page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
				
			||||||
@ -287,9 +297,12 @@ def page_setup(container):
 | 
				
			|||||||
    g.appendChild(float_spin('margin_right', _('Right page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
					    g.appendChild(float_spin('margin_right', _('Right page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
				
			||||||
    g.appendChild(float_spin('margin_bottom', _('Bottom page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
					    g.appendChild(float_spin('margin_bottom', _('Bottom page margin'), unit='pt', step=0.1, min=-1, max=200))
 | 
				
			||||||
    g.appendChild(choices('input_profile', _('&Input profile:'), {name: profiles.input[name].name for name in profiles.input}))
 | 
					    g.appendChild(choices('input_profile', _('&Input profile:'), {name: profiles.input[name].name for name in profiles.input}))
 | 
				
			||||||
 | 
					    g.appendChild(E.div(data_profile='input'))
 | 
				
			||||||
    g.appendChild(choices('output_profile', _('&Output profile:'), {name: profiles.output[name].name for name in profiles.output}))
 | 
					    g.appendChild(choices('output_profile', _('&Output profile:'), {name: profiles.output[name].name for name in profiles.output}))
 | 
				
			||||||
 | 
					    g.appendChild(E.div(data_profile='output'))
 | 
				
			||||||
# }}}
 | 
					# }}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def create_option_group(group_name, profiles_, container, get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_):
 | 
					def create_option_group(group_name, profiles_, container, get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_):
 | 
				
			||||||
    nonlocal get_option_value, get_option_default_value, is_option_disabled, container_id, registry, listeners, get_option_help, profiles
 | 
					    nonlocal get_option_value, get_option_default_value, is_option_disabled, container_id, registry, listeners, get_option_help, profiles
 | 
				
			||||||
    get_option_value, get_option_default_value, is_option_disabled, get_option_help = get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_
 | 
					    get_option_value, get_option_default_value, is_option_disabled, get_option_help = get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user