diff --git a/resources/images/heuristics.png b/resources/images/heuristics.png new file mode 100644 index 0000000000..92c53ae8ff Binary files /dev/null and b/resources/images/heuristics.png differ diff --git a/src/calibre/gui2/convert/heuristics.py b/src/calibre/gui2/convert/heuristics.py index 0655d7400f..e788888257 100644 --- a/src/calibre/gui2/convert/heuristics.py +++ b/src/calibre/gui2/convert/heuristics.py @@ -11,9 +11,10 @@ from calibre.gui2.convert import Widget class HeuristicsWidget(Widget, Ui_Form): - TITLE = _('Heuristic Processing') + TITLE = _('Heuristic\nProcessing') HELP = _('Modify the document text and structure using common patterns.') COMMIT_NAME = 'heuristics' + ICON = I('heuristics.png') def __init__(self, parent, get_option, get_help, db=None, book_id=None): Widget.__init__(self, parent, @@ -46,23 +47,8 @@ class HeuristicsWidget(Widget, Ui_Form): return True def enable_heuristics(self, state): - if state == Qt.Checked: - state = True - else: - state = False - self.opt_markup_chapter_headings.setEnabled(state) - self.opt_italicize_common_cases.setEnabled(state) - self.opt_fix_indents.setEnabled(state) - self.opt_delete_blank_paragraphs.setEnabled(state) - self.opt_format_scene_breaks.setEnabled(state) - self.opt_dehyphenate.setEnabled(state) - self.opt_renumber_headings.setEnabled(state) - - self.opt_unwrap_lines.setEnabled(state) - if state and self.opt_unwrap_lines.checkState() == Qt.Checked: - self.opt_html_unwrap_factor.setEnabled(True) - else: - self.opt_html_unwrap_factor.setEnabled(False) + state = state == Qt.Checked + self.heuristic_options.setEnabled(state) def enable_unwrap(self, state): if state == Qt.Checked: diff --git a/src/calibre/gui2/convert/heuristics.ui b/src/calibre/gui2/convert/heuristics.ui index 8048bef204..4358512996 100644 --- a/src/calibre/gui2/convert/heuristics.ui +++ b/src/calibre/gui2/convert/heuristics.ui @@ -6,7 +6,7 @@ 0 0 - 938 + 724 470 @@ -15,114 +15,160 @@ - + - &Preprocess input file to possibly improve structure detection + <b>Heuristic processing</b> means that calibre will scan your book for common patterns and fix them. As the name implies, this involves guesswork, which means that it could end up worsening the result of a conversion, if calibre guesses wrong. Therefore, it is disabled by default. Often, if a conversion does not turn out as you expect, turning on heuristics can improve matters. + + + true - + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 15 + + + + + + + + Enable &heuristic processing + + + + + Heuristic Processing - - + + Unwrap lines - - - - Line &un-wrap factor during preprocess: - - - opt_html_unwrap_factor - - + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Line &un-wrap factor : + + + opt_html_unwrap_factor + + + + + + + + + + 1.000000000000000 + + + 0.050000000000000 + + + 0.400000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - - - - 1.000000000000000 - - - 0.050000000000000 - - - 0.400000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + Detect and markup unformatted chapter headings and sub headings - + Renumber sequences of <h1> or <h2> tags to prevent splitting - + Delete blank lines between paragraphs - + Ensure scene breaks are consistently formatted - + Remove unnecessary hyphens - + Italicize common words and patterns - + Replace entity indents with CSS indents - + Qt::Vertical diff --git a/src/calibre/gui2/convert/structure_detection.py b/src/calibre/gui2/convert/structure_detection.py index 2c64303ee7..d8e2f4f122 100644 --- a/src/calibre/gui2/convert/structure_detection.py +++ b/src/calibre/gui2/convert/structure_detection.py @@ -31,7 +31,7 @@ class StructureDetectionWidget(Widget, Ui_Form): self.opt_chapter.set_msg(_('Detect chapters at (XPath expression):')) self.opt_page_breaks_before.set_msg(_('Insert page breaks before ' '(XPath expression):')) - + def break_cycles(self): Widget.break_cycles(self)