Re-design the Look & Feel section of the conversion dialog to make options better organized

This commit is contained in:
Kovid Goyal 2016-03-10 12:27:42 +05:30
parent 2da3c9d30b
commit 61ae37d726
4 changed files with 451 additions and 394 deletions

View File

@ -47,7 +47,7 @@ PDF is a terrible format to convert from. For a list of the various issues you w
How do I convert my file containing non-English characters, or smart quotes?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are two aspects to this problem:
1. Knowing the encoding of the source file: calibre tries to guess what character encoding your source files use, but often, this is impossible, so you need to tell it what encoding to use. This can be done in the GUI via the :guilabel:`Input character encoding` field in the :guilabel:`Look & Feel` section of the conversion dialog. The command-line tools all have an :option:`--input-encoding` option.
1. Knowing the encoding of the source file: calibre tries to guess what character encoding your source files use, but often, this is impossible, so you need to tell it what encoding to use. This can be done in the GUI via the :guilabel:`Input character encoding` field in the :guilabel:`Look & Feel->Text` section of the conversion dialog. The command-line tools all have an :option:`--input-encoding` option.
2. When adding HTML files to calibre, you may need to tell calibre what encoding the files are in. To do this go to :guilabel:`Preferences->Plugins->File Type plugins` and customize the HTML2Zip plugin, telling it what encoding your HTML files are in. Now when you add HTML files to calibre they will be correctly processed. HTML files from different sources often have different encodings, so you may have to change this setting repeatedly. A common encoding for many files from the web is ``cp1252`` and I would suggest you try that first. Note that when converting HTML files, leave the input encoding setting mentioned above blank. This is because the HTML2ZIP plugin automatically converts the HTML files to a standard encoding (utf-8).
What's the deal with Table of Contents in MOBI files?

View File

@ -11,7 +11,7 @@ from functools import partial
from PyQt5.Qt import (QWidget, QSpinBox, QDoubleSpinBox, QLineEdit, QTextEdit,
QCheckBox, QComboBox, Qt, QIcon, pyqtSignal, QLabel, QFontComboBox, QFont,
QFontInfo)
QFontInfo, QPlainTextEdit)
from calibre.customize.conversion import OptionRecommendation
from calibre.ebooks.conversion.config import (
@ -143,7 +143,7 @@ class Widget(QWidget):
return ret
if isinstance(g, (QSpinBox, QDoubleSpinBox)):
return g.value()
elif isinstance(g, (QLineEdit, QTextEdit)):
elif isinstance(g, (QLineEdit, QTextEdit, QPlainTextEdit)):
func = getattr(g, 'toPlainText', getattr(g, 'text', None))()
ans = unicode(func)
if self.STRIP_TEXT_FIELDS:
@ -189,7 +189,7 @@ class Widget(QWidget):
from calibre.gui2.convert.regex_builder import RegexEdit
if isinstance(g, (QSpinBox, QDoubleSpinBox)):
g.valueChanged.connect(f)
elif isinstance(g, (QLineEdit, QTextEdit)):
elif isinstance(g, (QLineEdit, QTextEdit, QPlainTextEdit)):
g.textChanged.connect(f)
elif isinstance(g, QComboBox):
g.editTextChanged.connect(f)

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from PyQt5.Qt import Qt
from PyQt5.Qt import Qt, QSize
from calibre.gui2.convert.look_and_feel_ui import Ui_Form
from calibre.gui2.convert import Widget
@ -61,6 +61,7 @@ class LookAndFeelWidget(Widget, Ui_Form):
self.opt_unsmarten_punctuation.stateChanged.connect(
lambda state: state != Qt.Unchecked and
self.opt_smarten_punctuation.setCheckState(Qt.Unchecked))
self.opt_extra_css.size_hint = QSize(400, 300)
def get_value_handler(self, g):
if g is self.opt_change_justification:
@ -102,6 +103,9 @@ class LookAndFeelWidget(Widget, Ui_Form):
w.setChecked(False)
self.filter_css_others.setText(', '.join(items))
return True
if g is self.opt_extra_css:
g.load_text(val or '', 'css')
return True
def connect_gui_obj_handler(self, gui_obj, slot):
if gui_obj is self.opt_filter_css:

View File

@ -6,146 +6,79 @@
<rect>
<x>0</x>
<y>0</y>
<width>699</width>
<width>765</width>
<height>619</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="12" column="1" colspan="2">
<widget class="QCheckBox" name="opt_keep_ligatures">
<property name="text">
<string>Keep &amp;ligatures</string>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
</item>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="MainTabs">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab1">
<attribute name="title">
<string>Fonts</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Base &amp;font size:</string>
<string>Base font si&amp;ze:</string>
</property>
<property name="buddy">
<cstring>opt_base_font_size</cstring>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&amp;Line size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>opt_insert_blank_line_size</cstring>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="EncodingComboBox" name="opt_input_encoding">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="opt_remove_paragraph_spacing">
<property name="text">
<string>Remove &amp;spacing between paragraphs</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&amp;Indent size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>opt_remove_paragraph_spacing_indent_size</cstring>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QDoubleSpinBox" name="opt_line_height">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="opt_base_font_size">
<property name="suffix">
<string> pt</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>50.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>15.000000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="opt_insert_blank_line">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Insert &amp;blank line between paragraphs</string>
</property>
</widget>
</item>
<item row="9" column="4">
<widget class="QDoubleSpinBox" name="opt_insert_blank_line_size">
<property name="suffix">
<string> em</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Text &amp;justification:</string>
<string>Font size &amp;key:</string>
</property>
<property name="buddy">
<cstring>opt_change_justification</cstring>
<cstring>opt_font_size_mapping</cstring>
</property>
</widget>
</item>
<item row="10" column="2" colspan="3">
<widget class="QComboBox" name="opt_change_justification"/>
</item>
<item row="11" column="0">
<widget class="QCheckBox" name="opt_smarten_punctuation">
<property name="text">
<string>Smarten &amp;punctuation</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="opt_unsmarten_punctuation">
<property name="text">
<string>&amp;UnSmarten punctuation</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Line &amp;height:</string>
</property>
<property name="buddy">
<cstring>opt_line_height</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Minimum &amp;line height:</string>
</property>
<property name="buddy">
<cstring>opt_minimum_line_height</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="opt_font_size_mapping">
@ -179,13 +112,13 @@
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Input character &amp;encoding:</string>
<string>Minim&amp;um line height:</string>
</property>
<property name="buddy">
<cstring>opt_input_encoding</cstring>
<cstring>opt_minimum_line_height</cstring>
</property>
</widget>
</item>
@ -202,177 +135,153 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="opt_base_font_size">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>L&amp;ine height:</string>
</property>
<property name="buddy">
<cstring>opt_line_height</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="opt_line_height">
<property name="suffix">
<string> pt</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>50.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>15.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QCheckBox" name="opt_disable_font_rescaling">
<property name="text">
<string>&amp;Disable font size rescaling</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="FontFamilyChooser" name="opt_embed_font_family" native="true"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Font size &amp;key:</string>
</property>
<property name="buddy">
<cstring>opt_font_size_mapping</cstring>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>&amp;Embed font family:</string>
<string>Embed font fami&amp;ly:</string>
</property>
<property name="buddy">
<cstring>opt_embed_font_family</cstring>
</property>
</widget>
</item>
<item row="13" column="0" colspan="5">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<item row="5" column="1">
<widget class="FontFamilyChooser" name="opt_embed_font_family" native="true"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="opt_embed_all_fonts">
<property name="text">
<string>&amp;Embed all fonts in document</string>
</property>
<widget class="QWidget" name="extra_css_tab">
<attribute name="title">
<string>&amp;Extra CSS</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTextEdit" name="opt_extra_css"/>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_subset_embedded_fonts">
<property name="text">
<string>&amp;Subset all embedded fonts</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="opt_expand_css">
<property name="text">
<string>E&amp;xpand CSS</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="opt_keep_ligatures">
<property name="text">
<string>Keep &amp;ligatures</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="opt_disable_font_rescaling">
<property name="text">
<string>&amp;Disable font size rescaling</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="opt_filter_css">
<widget class="QWidget" name="tab">
<attribute name="title">
<string>&amp;Filter Style Information</string>
<string>Text</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="5">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Select what style information you want completely removed:</string>
</property>
<property name="wordWrap">
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="1">
<widget class="EncodingComboBox" name="opt_input_encoding">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="filter_css_fonts">
<property name="toolTip">
<string>Removes the font-family CSS property</string>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&amp;Fonts</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="filter_css_margins">
<property name="toolTip">
<string>Removes the margin CSS properties. Note that page margins are not affected by this setting.</string>
</property>
<property name="text">
<string>&amp;Margins</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="filter_css_padding">
<property name="toolTip">
<string>Removes the padding CSS properties</string>
</property>
<property name="text">
<string>&amp;Padding</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="filter_css_floats">
<property name="toolTip">
<string>Convert floating images/text into static images/text</string>
</property>
<property name="text">
<string>F&amp;loats</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="filter_css_colors">
<property name="toolTip">
<string>Removes foreground and background colors</string>
</property>
<property name="text">
<string>&amp;Colors</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>&amp;Other CSS Properties:</string>
<string>Text &amp;justification:</string>
</property>
<property name="buddy">
<cstring>filter_css_others</cstring>
<cstring>opt_change_justification</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filter_css_others">
<property name="toolTip">
<string>Comma separated list of CSS properties to remove. For example: display, color, font-family</string>
<item row="2" column="1">
<widget class="QComboBox" name="opt_change_justification"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="opt_smarten_punctuation">
<property name="text">
<string>Smarten &amp;punctuation</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="opt_unsmarten_punctuation">
<property name="text">
<string>&amp;UnSmarten punctuation</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="opt_asciiize">
<property name="text">
<string>&amp;Transliterate unicode characters to ASCII</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>I&amp;nput character encoding:</string>
</property>
<property name="buddy">
<cstring>opt_input_encoding</cstring>
</property>
</widget>
</item>
</layout>
</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>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Layout</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&amp;Line size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>opt_insert_blank_line_size</cstring>
</property>
</widget>
</item>
<item row="8" column="4">
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="opt_remove_paragraph_spacing_indent_size">
<property name="toolTip">
<string>&lt;p&gt;When calibre removes inter paragraph spacing, it automatically sets a paragraph indent, to ensure that paragraphs can be easily distinguished. This option controls the width of that indent.</string>
@ -394,41 +303,180 @@
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QCheckBox" name="opt_subset_embedded_fonts">
<item row="1" column="0">
<widget class="QCheckBox" name="opt_insert_blank_line">
<property name="text">
<string>&amp;Subset all embedded fonts</string>
<string>Insert &amp;blank line between paragraphs</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="opt_embed_all_fonts">
<item row="0" column="0">
<widget class="QCheckBox" name="opt_remove_paragraph_spacing">
<property name="text">
<string>&amp;Embed all fonts in document</string>
<string>Remove &amp;spacing between paragraphs</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QCheckBox" name="opt_asciiize">
<property name="text">
<string>&amp;Transliterate unicode characters to ASCII</string>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="opt_insert_blank_line_size">
<property name="suffix">
<string> em</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="11" column="3" colspan="2">
<widget class="QCheckBox" name="opt_expand_css">
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>E&amp;xpand CSS</string>
<string>I&amp;ndent size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>opt_remove_paragraph_spacing_indent_size</cstring>
</property>
</widget>
</item>
<item row="12" column="3" colspan="2">
<item row="2" column="0">
<widget class="QCheckBox" name="opt_linearize_tables">
<property name="text">
<string>&amp;Linearize tables</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>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Styling</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Extra CSS</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="TextEdit" name="opt_extra_css"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="opt_filter_css">
<property name="title">
<string>Filter Style Information</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Select what style information you want completely removed:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="filter_css_fonts">
<property name="toolTip">
<string>Removes the font-family CSS property</string>
</property>
<property name="text">
<string>&amp;Fonts</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="filter_css_margins">
<property name="toolTip">
<string>Removes the margin CSS properties. Note that page margins are not affected by this setting.</string>
</property>
<property name="text">
<string>&amp;Margins</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="filter_css_padding">
<property name="toolTip">
<string>Removes the padding CSS properties</string>
</property>
<property name="text">
<string>&amp;Padding</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="filter_css_floats">
<property name="toolTip">
<string>Convert floating images/text into static images/text</string>
</property>
<property name="text">
<string>F&amp;loats</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="filter_css_colors">
<property name="toolTip">
<string>Removes foreground and background colors</string>
</property>
<property name="text">
<string>&amp;Colors</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Other CSS Propert&amp;ies:</string>
</property>
<property name="buddy">
<cstring>filter_css_others</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filter_css_others">
<property name="toolTip">
<string>Comma separated list of CSS properties to remove. For example: display, color, font-family</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@ -442,6 +490,11 @@
<extends>QWidget</extends>
<header>calibre/gui2/font_family_chooser.h</header>
</customwidget>
<customwidget>
<class>TextEdit</class>
<extends>QPlainTextEdit</extends>
<header>calibre/gui2/tweak_book/editor/text.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>
@ -455,12 +508,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>154</x>
<y>16</y>
<x>156</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>385</x>
<y>40</y>
<x>577</x>
<y>83</y>
</hint>
</hints>
</connection>
@ -471,12 +524,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>80</x>
<y>20</y>
<x>82</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>285</x>
<y>72</y>
<x>478</x>
<y>120</y>
</hint>
</hints>
</connection>
@ -487,12 +540,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
<x>243</x>
<y>42</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
<x>410</x>
<y>47</y>
</hint>
</hints>
</connection>
@ -503,12 +556,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
<x>160</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
<x>544</x>
<y>48</y>
</hint>
</hints>
</connection>