LRF output: Add option to control header separation from body text

This commit is contained in:
Kovid Goyal 2008-12-31 12:42:51 -08:00
parent 8fe381e502
commit e14b37bad2
2 changed files with 63 additions and 27 deletions

View File

@ -108,6 +108,8 @@ def option_parser(usage, gui_mode=False):
help=_('Add a header to all the pages with title and author.')) help=_('Add a header to all the pages with title and author.'))
laf.add_option('--headerformat', default="%t by %a", dest='headerformat', type='string', laf.add_option('--headerformat', default="%t by %a", dest='headerformat', type='string',
help=_('Set the format of the header. %a is replaced by the author and %t by the title. Default is %default')) help=_('Set the format of the header. %a is replaced by the author and %t by the title. Default is %default'))
laf.add_option('--header-separation', default=0, type='int',
help=_('Add extra spacing below the header. Default is %default px.'))
laf.add_option('--override-css', default=None, dest='_override_css', type='string', laf.add_option('--override-css', default=None, dest='_override_css', type='string',
help=_('Override the CSS. Can be either a path to a CSS stylesheet or a string. If it is a string it is interpreted as CSS.')) help=_('Override the CSS. Can be either a path to a CSS stylesheet or a string. If it is a string it is interpreted as CSS.'))
laf.add_option('--use-spine', default=False, dest='use_spine', action='store_true', laf.add_option('--use-spine', default=False, dest='use_spine', action='store_true',
@ -260,10 +262,11 @@ def Book(options, logger, font_delta=0, header=None,
hb.append(header) hb.append(header)
hdr.PutObj(hb) hdr.PutObj(hb)
ps['headheight'] = profile.header_height ps['headheight'] = profile.header_height
ps['headsep'] = options.header_separation
ps['header'] = hdr ps['header'] = hdr
ps['topmargin'] = 0 ps['topmargin'] = 0
ps['textheight'] = profile.screen_height - (options.bottom_margin + ps['topmargin']) \ ps['textheight'] = profile.screen_height - (options.bottom_margin + ps['topmargin']) \
- ps['headheight'] - profile.fudge - ps['headheight'] - ps['headsep'] - profile.fudge
fontsize = int(10*profile.font_size+font_delta*20) fontsize = int(10*profile.font_size+font_delta*20)
baselineskip = fontsize + 20 baselineskip = fontsize + 20

View File

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>866</width> <width>866</width>
<height>671</height> <height>679</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -115,7 +115,7 @@
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QStackedWidget" name="stack" > <widget class="QStackedWidget" name="stack" >
<property name="currentIndex" > <property name="currentIndex" >
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="metadata_page" > <widget class="QWidget" name="metadata_page" >
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
@ -652,7 +652,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="2" column="0" >
<widget class="QLabel" name="label_10" > <widget class="QLabel" name="label_10" >
<property name="text" > <property name="text" >
<string>&amp;Header format:</string> <string>&amp;Header format:</string>
@ -662,9 +662,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="2" column="1" >
<widget class="QLineEdit" name="gui_headerformat" /> <widget class="QLineEdit" name="gui_headerformat" />
</item> </item>
<item row="1" column="1" >
<widget class="QSpinBox" name="gui_header_separation" >
<property name="suffix" >
<string> px</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_29" >
<property name="text" >
<string>Header &amp;separation:</string>
</property>
<property name="buddy" >
<cstring>gui_header_separation</cstring>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -985,8 +1002,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> &lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;"> &lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string> &lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';">&lt;/p>&lt;/body>&lt;/html></string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1078,12 +1095,12 @@ p, li { white-space: pre-wrap; }
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>650</x> <x>308</x>
<y>122</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>788</x> <x>308</x>
<y>140</y> <y>74</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1094,12 +1111,12 @@ p, li { white-space: pre-wrap; }
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>543</x> <x>308</x>
<y>122</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>544</x> <x>308</x>
<y>211</y> <y>74</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1110,12 +1127,12 @@ p, li { white-space: pre-wrap; }
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>298</x> <x>308</x>
<y>398</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>660</x> <x>308</x>
<y>435</y> <y>74</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1126,12 +1143,12 @@ p, li { white-space: pre-wrap; }
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>330</x> <x>345</x>
<y>367</y> <y>363</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>823</x> <x>837</x>
<y>372</y> <y>435</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1142,12 +1159,28 @@ p, li { white-space: pre-wrap; }
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel" >
<x>344</x> <x>308</x>
<y>107</y> <y>74</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel" >
<x>489</x> <x>308</x>
<y>465</y> <y>74</y>
</hint>
</hints>
</connection>
<connection>
<sender>gui_header</sender>
<signal>toggled(bool)</signal>
<receiver>gui_header_separation</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>261</x>
<y>346</y>
</hint>
<hint type="destinationlabel" >
<x>379</x>
<y>378</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>