mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
PDF output options UI
This commit is contained in:
parent
43fba1faa9
commit
e77c8cc7ab
@ -51,8 +51,9 @@ class PDFOutput(OutputFormatPlugin):
|
|||||||
author = 'Kovid Goyal'
|
author = 'Kovid Goyal'
|
||||||
file_type = 'pdf'
|
file_type = 'pdf'
|
||||||
commit_name = 'pdf_output'
|
commit_name = 'pdf_output'
|
||||||
|
ui_data = {'paper_sizes': PAPER_SIZES, 'units': UNITS, 'font_types': ['serif', 'sans', 'mono']}
|
||||||
|
|
||||||
options = set([
|
options = {
|
||||||
OptionRecommendation(name='use_profile_size', recommended_value=False,
|
OptionRecommendation(name='use_profile_size', recommended_value=False,
|
||||||
help=_('Instead of using the paper size specified in the PDF Output options,'
|
help=_('Instead of using the paper size specified in the PDF Output options,'
|
||||||
' use a paper size corresponding to the current output profile.'
|
' use a paper size corresponding to the current output profile.'
|
||||||
@ -85,8 +86,7 @@ class PDFOutput(OutputFormatPlugin):
|
|||||||
OptionRecommendation(name='pdf_mono_family',
|
OptionRecommendation(name='pdf_mono_family',
|
||||||
recommended_value='Liberation Mono', help=_(
|
recommended_value='Liberation Mono', help=_(
|
||||||
'The font family used to render monospace fonts')),
|
'The font family used to render monospace fonts')),
|
||||||
OptionRecommendation(name='pdf_standard_font', choices=['serif',
|
OptionRecommendation(name='pdf_standard_font', choices=ui_data['font_types'],
|
||||||
'sans', 'mono'],
|
|
||||||
recommended_value='serif', help=_(
|
recommended_value='serif', help=_(
|
||||||
'The font family used to render monospace fonts')),
|
'The font family used to render monospace fonts')),
|
||||||
OptionRecommendation(name='pdf_default_font_size',
|
OptionRecommendation(name='pdf_default_font_size',
|
||||||
@ -148,7 +148,7 @@ class PDFOutput(OutputFormatPlugin):
|
|||||||
' This will cause the margins specified in the conversion settings to be ignored.'
|
' This will cause the margins specified in the conversion settings to be ignored.'
|
||||||
' If the document does not specify page margins, the conversion settings will be used as a fallback.')
|
' If the document does not specify page margins, the conversion settings will be used as a fallback.')
|
||||||
),
|
),
|
||||||
])
|
}
|
||||||
|
|
||||||
def specialize_options(self, log, opts, input_fmt):
|
def specialize_options(self, log, opts, input_fmt):
|
||||||
if opts.pdf_use_document_margins:
|
if opts.pdf_use_document_margins:
|
||||||
|
@ -43,6 +43,13 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
self.layout().setFieldGrowthPolicy(self.layout().ExpandingFieldsGrow)
|
self.layout().setFieldGrowthPolicy(self.layout().ExpandingFieldsGrow)
|
||||||
self.template_box.layout().setFieldGrowthPolicy(self.layout().AllNonFixedFieldsGrow)
|
self.template_box.layout().setFieldGrowthPolicy(self.layout().AllNonFixedFieldsGrow)
|
||||||
self.toggle_margins()
|
self.toggle_margins()
|
||||||
|
self.profile_size_toggled()
|
||||||
|
|
||||||
|
def profile_size_toggled(self):
|
||||||
|
enabled = not self.opt_use_profile_size.isChecked()
|
||||||
|
self.opt_paper_size.setEnabled(enabled)
|
||||||
|
self.opt_custom_size.setEnabled(enabled)
|
||||||
|
self.opt_unit.setEnabled(enabled)
|
||||||
|
|
||||||
def toggle_margins(self):
|
def toggle_margins(self):
|
||||||
enabled = not self.opt_pdf_use_document_margins.isChecked()
|
enabled = not self.opt_pdf_use_document_margins.isChecked()
|
||||||
@ -71,3 +78,4 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
l.addRow(_('&Right:'), margin('right'))
|
l.addRow(_('&Right:'), margin('right'))
|
||||||
r.addRow(_('&Top:'), margin('top'))
|
r.addRow(_('&Top:'), margin('top'))
|
||||||
r.addRow(_('&Bottom:'), margin('bottom'))
|
r.addRow(_('&Bottom:'), margin('bottom'))
|
||||||
|
self.opt_use_profile_size.toggled.connect(self.profile_size_toggled)
|
||||||
|
@ -627,6 +627,46 @@ def pdb_output(container):
|
|||||||
g.appendChild(checkbox('inline_toc', _('&Inline TOC')))
|
g.appendChild(checkbox('inline_toc', _('&Inline TOC')))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
# PDF Output {{{
|
||||||
|
@ep
|
||||||
|
def pdf_output(container):
|
||||||
|
add_listener('use_profile_size', def (name):
|
||||||
|
disabled = get('use_profile_size')
|
||||||
|
for dname in 'paper_size', 'custom_size', 'unit':
|
||||||
|
set_disabled(dname, disabled)
|
||||||
|
)
|
||||||
|
add_listener('pdf_use_document_margins', def (name):
|
||||||
|
disabled = get('pdf_use_document_margins')
|
||||||
|
for dname in 'left', 'top', 'right', 'bottom':
|
||||||
|
set_disabled(f'pdf_page_margin_{dname}', disabled)
|
||||||
|
)
|
||||||
|
|
||||||
|
g = E.div(class_='simple-group')
|
||||||
|
container.appendChild(g)
|
||||||
|
g.appendChild(checkbox('use_profile_size', _('&Use the paper size set in output profile')))
|
||||||
|
g.appendChild(choices('paper_size', indent + _('&Paper size:'), ui_data.paper_sizes))
|
||||||
|
g.appendChild(lineedit('custom_size', indent + _('&Custom size:')))
|
||||||
|
g.appendChild(choices('unit', indent + _('Custom size unit:'), ui_data.units))
|
||||||
|
g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve &aspect ratio of cover')))
|
||||||
|
g.appendChild(checkbox('pdf_page_numbers', _('Add page &numbers to the bottom of every page')))
|
||||||
|
g.appendChild(checkbox('pdf_hyphenate', _('&Break long words at the end of lines')))
|
||||||
|
g.appendChild(checkbox('pdf_add_toc', _('Add a printable &Table of Contents at the end')))
|
||||||
|
g.appendChild(lineedit('toc_title', indent + _('&Title for ToC:')))
|
||||||
|
g.appendChild(lineedit('pdf_serif_family', _('Serif famil&y:')))
|
||||||
|
g.appendChild(lineedit('pdf_sans_family', _('Sans fami&ly:')))
|
||||||
|
g.appendChild(lineedit('pdf_mono_family', _('&Monospace family:')))
|
||||||
|
g.appendChild(choices('pdf_standard_font', _('S&tandard font:'), ui_data.font_types))
|
||||||
|
g.appendChild(int_spin('pdf_default_font_size', _('Default font si&ze:'), unit='px'))
|
||||||
|
g.appendChild(int_spin('pdf_mono_font_size', _('Default font si&ze:'), unit='px'))
|
||||||
|
g.appendChild(checkbox('pdf_use_document_margins', _('Use page margins from the &document being converted')))
|
||||||
|
g.appendChild(float_spin('pdf_page_margin_left', indent + _('Left page margin'), unit='pt', min=-100, max=500))
|
||||||
|
g.appendChild(float_spin('pdf_page_margin_top', indent + _('Top page margin'), unit='pt', min=-100, max=500))
|
||||||
|
g.appendChild(float_spin('pdf_page_margin_right', indent + _('Right page margin'), unit='pt', min=-100, max=500))
|
||||||
|
g.appendChild(float_spin('pdf_page_margin_bottom', indent + _('Bottom page margin'), unit='pt', min=-100, max=500))
|
||||||
|
g.appendChild(lineedit('pdf_header_template', _('&Header template:')))
|
||||||
|
g.appendChild(lineedit('pdf_footer_template', _('&Footer template:')))
|
||||||
|
# }}}
|
||||||
|
|
||||||
def restore_defaults():
|
def restore_defaults():
|
||||||
for setting in registry:
|
for setting in registry:
|
||||||
set(setting, get_option_default_value(setting))
|
set(setting, get_option_default_value(setting))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user