From f0cedba6c729c9caa8dd13c3b77f7af605aaf273 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 4 Jun 2015 12:06:36 +0530 Subject: [PATCH] An option to auto-convert a book on adding even if it is already in the output format (Preferences->Adding Books). Fixes #1460477 [Request - automatic epub to epub conversion](https://bugs.launchpad.net/calibre/+bug/1460477) --- src/calibre/gui2/__init__.py | 1 + src/calibre/gui2/actions/convert.py | 4 ++-- src/calibre/gui2/preferences/adding.py | 1 + src/calibre/gui2/preferences/adding.ui | 20 +++++++++++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 741c50b409..45d1714513 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -102,6 +102,7 @@ defs['edit_metadata_single_layout'] = 'default' defs['default_author_link'] = 'https://en.wikipedia.org/w/index.php?search={author}' defs['preserve_date_on_ctl'] = True defs['manual_add_auto_convert'] = False +defs['auto_convert_same_fmt'] = False defs['cb_fullscreen'] = False defs['worker_max_time'] = 0 defs['show_files_after_save'] = True diff --git a/src/calibre/gui2/actions/convert.py b/src/calibre/gui2/actions/convert.py index 959dd49e71..f831be5185 100644 --- a/src/calibre/gui2/actions/convert.py +++ b/src/calibre/gui2/actions/convert.py @@ -10,7 +10,7 @@ from functools import partial from PyQt5.Qt import QModelIndex, QTimer -from calibre.gui2 import error_dialog, Dispatcher +from calibre.gui2 import error_dialog, Dispatcher, gprefs from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook from calibre.utils.config import prefs, tweaks from calibre.gui2.actions import InterfaceAction @@ -87,7 +87,7 @@ class ConvertAction(InterfaceAction): for book_id in book_ids: fmts = db.formats(book_id, index_is_id=True) fmts = set(x.lower() for x in fmts.split(',')) if fmts else set() - if of not in fmts: + if gprefs['auto_convert_same_fmt'] or of not in fmts: needed.add(book_id) if needed: jobs, changed, bad = convert_single_ebook(self.gui, diff --git a/src/calibre/gui2/preferences/adding.py b/src/calibre/gui2/preferences/adding.py index b468c1c3bc..cb3cdd81de 100644 --- a/src/calibre/gui2/preferences/adding.py +++ b/src/calibre/gui2/preferences/adding.py @@ -41,6 +41,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('auto_add_everything', gprefs, restart_required=True) r('auto_add_check_for_duplicates', gprefs) r('auto_add_auto_convert', gprefs) + r('auto_convert_same_fmt', gprefs) self.filename_pattern = FilenamePattern(self) self.metadata_box.layout().insertWidget(0, self.filename_pattern) diff --git a/src/calibre/gui2/preferences/adding.ui b/src/calibre/gui2/preferences/adding.ui index 98835bea38..40bf3ec77e 100644 --- a/src/calibre/gui2/preferences/adding.ui +++ b/src/calibre/gui2/preferences/adding.ui @@ -51,7 +51,7 @@ - + &Tags to apply when adding a book: @@ -61,14 +61,14 @@ - + A comma-separated list of tags that will be applied to books added to the library - + &Configure metadata from file name @@ -104,7 +104,7 @@ - + Automerge: If books with similar titles and authors found, merge the incoming formats automatically into @@ -144,7 +144,7 @@ Author matching is exact. - + Automerge: If books with similar titles and authors found, merge the incoming formats automatically into @@ -165,6 +165,16 @@ Title match ignores leading indefinite articles ("the", "a", + + + + This will force an automatic conversion even if the file being added is the same format as the output format. For example, if you set your output format to EPUB and add an EPUB file, an EPUB to EPUB conversion will be run. + + + When autoconverting, convert even if the format being added is the &same as the output format + + +