From 61ae37d726e6308966b09c9379f55b08afb49e4a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Mar 2016 12:27:42 +0530 Subject: [PATCH] Re-design the Look & Feel section of the conversion dialog to make options better organized --- manual/faq.rst | 2 +- src/calibre/gui2/convert/__init__.py | 6 +- src/calibre/gui2/convert/look_and_feel.py | 6 +- src/calibre/gui2/convert/look_and_feel.ui | 831 ++++++++++++---------- 4 files changed, 451 insertions(+), 394 deletions(-) diff --git a/manual/faq.rst b/manual/faq.rst index 00c346ac51..06d2adba59 100644 --- a/manual/faq.rst +++ b/manual/faq.rst @@ -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? diff --git a/src/calibre/gui2/convert/__init__.py b/src/calibre/gui2/convert/__init__.py index 23d9275182..3f14621baf 100644 --- a/src/calibre/gui2/convert/__init__.py +++ b/src/calibre/gui2/convert/__init__.py @@ -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) diff --git a/src/calibre/gui2/convert/look_and_feel.py b/src/calibre/gui2/convert/look_and_feel.py index 8131051481..80dd7e081a 100644 --- a/src/calibre/gui2/convert/look_and_feel.py +++ b/src/calibre/gui2/convert/look_and_feel.py @@ -6,7 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __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: diff --git a/src/calibre/gui2/convert/look_and_feel.ui b/src/calibre/gui2/convert/look_and_feel.ui index abffd9a248..504ed999fb 100644 --- a/src/calibre/gui2/convert/look_and_feel.ui +++ b/src/calibre/gui2/convert/look_and_feel.ui @@ -6,355 +6,347 @@ 0 0 - 699 + 765 619 - - Form - - - - - - Keep &ligatures - - - - - - - Base &font size: - - - opt_base_font_size - - - - - - - &Line size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - opt_insert_blank_line_size - - - - - - - true - - - - - - - Remove &spacing between paragraphs - - - - - - - &Indent size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - opt_remove_paragraph_spacing_indent_size - - - - - - - pt - - - 1 - - - - - - - Insert &blank line between paragraphs - - - - - - - em - - - 1 - - - - - - - Text &justification: - - - opt_change_justification - - - - - - - - - - Smarten &punctuation - - - - - - - &UnSmarten punctuation - - - - - - - Line &height: - - - opt_line_height - - - - - - - Minimum &line height: - - - opt_minimum_line_height - - - - - - - - - - 0 - 0 - - - - - - - - Wizard to help you choose an appropriate font size key - - - ... - - - - :/images/wizard.png:/images/wizard.png - - - - 32 - 32 - - - - - - - - - - Input character &encoding: - - - opt_input_encoding - - - - - - - % - - - 1 - - - 900.000000000000000 - - - - - - - pt - - - 1 - - - 0.000000000000000 - - - 50.000000000000000 - - - 1.000000000000000 - - - 15.000000000000000 - - - - - - - &Disable font size rescaling - - - - - - - - - - Font size &key: - - - opt_font_size_mapping - - - - - - - &Embed font family: - - - opt_embed_font_family - - - - - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 - + - &Extra CSS + Fonts - - - - - - - - - &Filter Style Information - - - - - - Select what style information you want completely removed: - - - true - - - + - - - Removes the font-family CSS property - + - &Fonts + Base font si&ze: + + + opt_base_font_size - - - Removes the margin CSS properties. Note that page margins are not affected by this setting. + + + pt - - &Margins + + 1 + + + 0.000000000000000 + + + 50.000000000000000 + + + 1.000000000000000 + + + 15.000000000000000 - - - - Removes the padding CSS properties - + + - &Padding + Font size &key: + + + opt_font_size_mapping - - - - Convert floating images/text into static images/text - - - F&loats - - - - - - - Removes foreground and background colors - - - &Colors - - - - - + + - - - &Other CSS Properties: - - - filter_css_others + + + + 0 + 0 + - + - Comma separated list of CSS properties to remove. For example: display, color, font-family + Wizard to help you choose an appropriate font size key + + + ... + + + + :/images/wizard.png:/images/wizard.png + + + + 32 + 32 + + + + + Minim&um line height: + + + opt_minimum_line_height + + + + + + + % + + + 1 + + + 900.000000000000000 + + + + + + + L&ine height: + + + opt_line_height + + + + + + + pt + + + 1 + + + + + + + Embed font fami&ly: + + + opt_embed_font_family + + + + + + + + + + &Embed all fonts in document + + + + + + + &Subset all embedded fonts + + + + + + + E&xpand CSS + + + + + + + Keep &ligatures + + + + + + + &Disable font size rescaling + + + + + + + + Text + + + + + + true + + + + + + + Text &justification: + + + opt_change_justification + + + + + + + + + + Smarten &punctuation + + + + + + + &UnSmarten punctuation + + + + + + + &Transliterate unicode characters to ASCII + + + + + + + I&nput character encoding: + + + opt_input_encoding + + + + + + + + Layout + + + + + + &Line size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + opt_insert_blank_line_size + + + + + + + <p>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. + + + No change + + + em + + + 1 + + + -0.100000000000000 + + + 0.100000000000000 + + + + + + + Insert &blank line between paragraphs + + + + + + + Remove &spacing between paragraphs + + + + + + + em + + + 1 + + + + + + + I&ndent size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + opt_remove_paragraph_spacing_indent_size + + + + + + + &Linearize tables + + + @@ -370,63 +362,119 @@ - - - - - - <p>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. - - - No change - - - em - - - 1 - - - -0.100000000000000 - - - 0.100000000000000 - - - - - - - &Subset all embedded fonts - - - - - - - &Embed all fonts in document - - - - - - - &Transliterate unicode characters to ASCII - - - - - - - E&xpand CSS - - - - - - - &Linearize tables - + + + Styling + + + + + + Extra CSS + + + + + + + + + + + + Filter Style Information + + + + + + Select what style information you want completely removed: + + + true + + + + + + + + + Removes the font-family CSS property + + + &Fonts + + + + + + + Removes the margin CSS properties. Note that page margins are not affected by this setting. + + + &Margins + + + + + + + Removes the padding CSS properties + + + &Padding + + + + + + + Convert floating images/text into static images/text + + + F&loats + + + + + + + Removes foreground and background colors + + + &Colors + + + + + + + + + + + Other CSS Propert&ies: + + + filter_css_others + + + + + + + Comma separated list of CSS properties to remove. For example: display, color, font-family + + + + + + + + + + @@ -442,6 +490,11 @@ QWidget
calibre/gui2/font_family_chooser.h
+ + TextEdit + QPlainTextEdit +
calibre/gui2/tweak_book/editor/text.h
+
@@ -455,12 +508,12 @@ setDisabled(bool) - 154 - 16 + 156 + 45 - 385 - 40 + 577 + 83 @@ -471,12 +524,12 @@ setDisabled(bool) - 80 - 20 + 82 + 49 - 285 - 72 + 478 + 120 @@ -487,12 +540,12 @@ setEnabled(bool) - 20 - 20 + 243 + 42 - 20 - 20 + 410 + 47 @@ -503,12 +556,12 @@ setEnabled(bool) - 20 - 20 + 160 + 49 - 20 - 20 + 544 + 48