GUI for LRF and MOBI output

This commit is contained in:
Kovid Goyal 2009-05-04 18:39:12 -07:00
parent 624390db05
commit b6fdd33237
7 changed files with 390 additions and 5 deletions

View File

@ -53,6 +53,7 @@ class LRFOptions(object):
self.lrs = False
self.minimize_memory_usage = False
self.autorotation = opts.enable_autorotation
self.header_separation = (self.profile.dpi/72.) * opts.header_separation
for x in ('top', 'bottom', 'left', 'right'):
@ -60,7 +61,7 @@ class LRFOptions(object):
'margin_'+x))
for x in ('wordspace', 'header', 'header_format',
'header_separation', 'minimum_indent', 'serif_family',
'minimum_indent', 'serif_family',
'render_tables_as_images', 'sans_family', 'mono_family',
'text_size_multiplier_for_rendered_tables'):
setattr(self, x, getattr(opts, x))
@ -87,7 +88,7 @@ class LRFOutput(OutputFormatPlugin):
'and %t by the title. Default is %default')
),
OptionRecommendation(name='header_separation', recommended_value=0,
help=_('Add extra spacing below the header. Default is %default px.')
help=_('Add extra spacing below the header. Default is %default pt.')
),
OptionRecommendation(name='minimum_indent', recommended_value=0,
help=_('Minimum paragraph indent (the indent of the first line '
@ -99,7 +100,7 @@ class LRFOutput(OutputFormatPlugin):
'document has large or complex tables)')
),
OptionRecommendation(name='text_size_multiplier_for_rendered_tables',
recommended_value=1,
recommended_value=1.0,
help=_('Multiply the size of text in rendered tables by this '
'factor. Default is %default')
),

View File

@ -190,7 +190,7 @@ class Widget(QWidget):
elif isinstance(g, QCheckBox):
g.setCheckState(Qt.Checked if bool(val) else Qt.Unchecked)
else:
raise Exception('Can\'t set value in %s'%type(g))
raise Exception('Can\'t set value %s in %s'%(repr(val), type(g)))
self.post_set_value(g, val)
def set_help(self, msg):

View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.gui2.convert.lrf_output_ui import Ui_Form
from calibre.gui2.convert import Widget
from calibre.gui2.widgets import FontFamilyModel
font_family_model = None
class PluginWidget(Widget, Ui_Form):
TITLE = _('LRF Output')
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, 'lrf_output',
['wordspace', 'header', 'header_format',
'minimum_indent', 'serif_family',
'render_tables_as_images', 'sans_family', 'mono_family',
'text_size_multiplier_for_rendered_tables', 'autorotation',
'header_separation', 'minimum_indent']
)
self.db, self.book_id = db, book_id
global font_family_model
if font_family_model is None:
font_family_model = FontFamilyModel()
self.font_family_model = font_family_model
self.opt_serif_family.setModel(self.font_family_model)
self.opt_sans_family.setModel(self.font_family_model)
self.opt_mono_family.setModel(self.font_family_model)
self.initialize_options(get_option, get_help, db, book_id)
def set_value_handler(self, g, val):
if val is None and unicode(g.objectName()) in ('opt_serif_family',
'opt_sans_family', 'opt_mono_family'):
g.setCurrentIndex(0)
return True
return False

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<height>481</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="opt_autorotation">
<property name="text">
<string>Enable &amp;autorotation of wide images</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Wordspace:</string>
</property>
<property name="buddy">
<cstring>opt_wordspace</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="opt_wordspace">
<property name="suffix">
<string> pt</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
<property name="value">
<double>2.500000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Minimum para. &amp;indent:</string>
</property>
<property name="buddy">
<cstring>opt_minimum_indent</cstring>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="opt_minimum_indent">
<property name="suffix">
<string> pt</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="opt_render_tables_as_images">
<property name="text">
<string>Render &amp;tables as images</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Text size multiplier for text in rendered tables:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="opt_text_size_multiplier_for_rendered_tables"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="opt_header">
<property name="text">
<string>Add &amp;header</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Header &amp;separation:</string>
</property>
<property name="buddy">
<cstring>opt_header_separation</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="opt_header_separation">
<property name="suffix">
<string> pt</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Header &amp;format:</string>
</property>
<property name="buddy">
<cstring>opt_header_format</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="opt_header_format"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>&amp;Embed fonts</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Serif font family:</string>
</property>
<property name="buddy">
<cstring>opt_serif_family</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>S&amp;ans-serif font family:</string>
</property>
<property name="buddy">
<cstring>opt_sans_family</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&amp;Monospaced font family:</string>
</property>
<property name="buddy">
<cstring>opt_mono_family</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="opt_serif_family"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="opt_sans_family"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="opt_mono_family"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>opt_render_tables_as_images</sender>
<signal>toggled(bool)</signal>
<receiver>opt_text_size_multiplier_for_rendered_tables</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>76</x>
<y>80</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>105</y>
</hint>
</hints>
</connection>
<connection>
<sender>opt_header</sender>
<signal>toggled(bool)</signal>
<receiver>opt_header_separation</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>346</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>408</x>
<y>167</y>
</hint>
</hints>
</connection>
<connection>
<sender>opt_header</sender>
<signal>toggled(bool)</signal>
<receiver>opt_header_format</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>124</x>
<y>138</y>
</hint>
<hint type="destinationlabel">
<x>230</x>
<y>208</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.gui2.convert.mobi_output_ui import Ui_Form
from calibre.gui2.convert import Widget
class PluginWidget(Widget, Ui_Form):
TITLE = _('MOBI Output')
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, 'mobi_output',
['prefer_author_sort', 'rescale_images', 'toc_title']
)
self.db, self.book_id = db, book_id
self.initialize_options(get_option, get_help, db, book_id)

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Title for Table of Contents:</string>
</property>
<property name="buddy">
<cstring>opt_toc_title</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="opt_toc_title"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="opt_rescale_images">
<property name="text">
<string>Rescale images for &amp;Palm devices</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="opt_prefer_author_sort">
<property name="text">
<string>Use author &amp;sort for author</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -285,7 +285,7 @@ class FontFamilyModel(QAbstractListModel):
print 'WARNING: Could not load fonts'
traceback.print_exc()
self.families.sort()
self.families[:0] = ['None']
self.families[:0] = [_('None')]
def rowCount(self, *args):
return len(self.families)