mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix Comin Input default settings not being used when bulk converting comics
This commit is contained in:
parent
a81bb5737a
commit
3b3cc6959f
@ -16,18 +16,39 @@ from calibre.ebooks.conversion.config import load_defaults, \
|
||||
save_defaults as save_defaults_, \
|
||||
load_specifics, GuiRecommendations
|
||||
from calibre import prepare_string_for_xml
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
|
||||
def config_widget_for_input_plugin(plugin):
|
||||
name = plugin.name.lower().replace(' ', '_')
|
||||
try:
|
||||
return __import__('calibre.gui2.convert.'+name,
|
||||
fromlist=[1])
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def bulk_defaults_for_input_format(fmt):
|
||||
plugin = plugin_for_input_format(fmt)
|
||||
if plugin is not None:
|
||||
w = config_widget_for_input_plugin(plugin)
|
||||
if w is not None:
|
||||
return load_defaults(w.COMMIT_NAME)
|
||||
return {}
|
||||
|
||||
|
||||
|
||||
class Widget(QWidget):
|
||||
|
||||
TITLE = _('Unknown')
|
||||
ICON = I('config.svg')
|
||||
HELP = ''
|
||||
COMMIT_NAME = None
|
||||
|
||||
def __init__(self, parent, name, options):
|
||||
def __init__(self, parent, options):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self._options = options
|
||||
self._name = name
|
||||
self._name = self.commit_name = self.COMMIT_NAME
|
||||
assert self._name is not None
|
||||
self._icon = QIcon(self.ICON)
|
||||
for name in self._options:
|
||||
if not hasattr(self, 'opt_'+name):
|
||||
@ -58,7 +79,7 @@ class Widget(QWidget):
|
||||
def commit_options(self, save_defaults=False):
|
||||
recs = self.create_recommendations()
|
||||
if save_defaults:
|
||||
save_defaults_(self._name, recs)
|
||||
save_defaults_(self.commit_name, recs)
|
||||
return recs
|
||||
|
||||
def create_recommendations(self):
|
||||
|
@ -14,9 +14,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('Comic Input')
|
||||
HELP = _('Options specific to')+' comic '+_('input')
|
||||
COMMIT_NAME = 'comic_input'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'comic_input',
|
||||
Widget.__init__(self, parent,
|
||||
['colors', 'dont_normalize', 'keep_aspect_ratio', 'right2left',
|
||||
'despeckle', 'no_sort', 'no_process', 'landscape',
|
||||
'dont_sharpen', 'disable_trim', 'wide', 'output_format',
|
||||
|
@ -19,9 +19,10 @@ class DebugWidget(Widget, Ui_Form):
|
||||
TITLE = _('Debug')
|
||||
ICON = I('debug.svg')
|
||||
HELP = _('Debug the conversion process.')
|
||||
COMMIT_NAME = 'debug'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'debug',
|
||||
Widget.__init__(self, parent,
|
||||
['debug_pipeline']
|
||||
)
|
||||
self.db, self.book_id = db, book_id
|
||||
|
@ -14,9 +14,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('EPUB Output')
|
||||
HELP = _('Options specific to')+' EPUB '+_('output')
|
||||
COMMIT_NAME = 'epub_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'epub_output',
|
||||
Widget.__init__(self, parent,
|
||||
['dont_split_on_page_breaks', 'flow_size',
|
||||
'no_default_epub_cover', 'no_svg_cover',
|
||||
'preserve_cover_aspect_ratio',]
|
||||
|
@ -11,9 +11,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('FB2 Input')
|
||||
HELP = _('Options specific to')+' FB2 '+_('input')
|
||||
COMMIT_NAME = 'fb2_input'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'fb2_input',
|
||||
Widget.__init__(self, parent,
|
||||
['no_inline_fb2_toc'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -13,8 +13,9 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('FB2 Output')
|
||||
HELP = _('Options specific to')+' FB2 '+_('output')
|
||||
COMMIT_NAME = 'fb2_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'fb2_output', ['inline_toc'])
|
||||
Widget.__init__(self, parent, ['inline_toc'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -16,9 +16,10 @@ class LookAndFeelWidget(Widget, Ui_Form):
|
||||
TITLE = _('Look & Feel')
|
||||
ICON = I('lookfeel.svg')
|
||||
HELP = _('Control the look and feel of the output')
|
||||
COMMIT_NAME = 'look_and_feel'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'look_and_feel',
|
||||
Widget.__init__(self, parent,
|
||||
['change_justification', 'extra_css', 'base_font_size',
|
||||
'font_size_mapping', 'line_height',
|
||||
'linearize_tables',
|
||||
|
@ -18,9 +18,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('LRF Output')
|
||||
HELP = _('Options specific to')+' LRF '+_('output')
|
||||
COMMIT_NAME = 'lrf_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'lrf_output',
|
||||
Widget.__init__(self, parent,
|
||||
['wordspace', 'header', 'header_format',
|
||||
'minimum_indent', 'serif_family',
|
||||
'render_tables_as_images', 'sans_family', 'mono_family',
|
||||
|
@ -42,9 +42,10 @@ class MetadataWidget(Widget, Ui_Form):
|
||||
ICON = I('dialog_information.svg')
|
||||
HELP = _('Set the metadata. The output file will contain as much of this '
|
||||
'metadata as possible.')
|
||||
COMMIT_NAME = 'metadata'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'metadata', ['prefer_metadata_cover'])
|
||||
Widget.__init__(self, parent, ['prefer_metadata_cover'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.cover_changed = False
|
||||
self.cover_data = None
|
||||
|
@ -19,10 +19,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('MOBI Output')
|
||||
HELP = _('Options specific to')+' MOBI '+_('output')
|
||||
|
||||
COMMIT_NAME = 'mobi_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'mobi_output',
|
||||
Widget.__init__(self, parent,
|
||||
['prefer_author_sort', 'rescale_images', 'toc_title',
|
||||
'dont_compress', 'no_inline_toc', 'masthead_font','personal_doc']
|
||||
)
|
||||
|
@ -33,9 +33,10 @@ class ProfileModel(QAbstractListModel):
|
||||
class PageSetupWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('Page Setup')
|
||||
COMMIT_NAME = 'page_setup'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'page_setup',
|
||||
Widget.__init__(self, parent,
|
||||
['margin_top', 'margin_left', 'margin_right', 'margin_bottom',
|
||||
'input_profile', 'output_profile']
|
||||
)
|
||||
|
@ -11,9 +11,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('PDB Input')
|
||||
HELP = _('Options specific to')+' PDB '+_('input')
|
||||
COMMIT_NAME = 'pdb_input'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'pdb_input',
|
||||
Widget.__init__(self, parent,
|
||||
['single_line_paras', 'print_formatted_paras'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -15,9 +15,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('PDB Output')
|
||||
HELP = _('Options specific to')+' PDB '+_('output')
|
||||
COMMIT_NAME = 'pdb_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'pdb_output', ['format', 'inline_toc'])
|
||||
Widget.__init__(self, parent, ['format', 'inline_toc'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
||||
|
@ -11,9 +11,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('PDF Input')
|
||||
HELP = _('Options specific to')+' PDF '+_('input')
|
||||
COMMIT_NAME = 'pdf_input'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'pdf_input',
|
||||
Widget.__init__(self, parent,
|
||||
['no_images', 'unwrap_factor'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -16,9 +16,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('PDF Output')
|
||||
HELP = _('Options specific to')+' PDF '+_('output')
|
||||
COMMIT_NAME = 'pdf_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'pdf_output', ['paper_size',
|
||||
Widget.__init__(self, parent, ['paper_size',
|
||||
'orientation', 'preserve_cover_aspect_ratio'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -13,8 +13,9 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('RB Output')
|
||||
HELP = _('Options specific to')+' RB '+_('output')
|
||||
COMMIT_NAME = 'rb_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'rb_output', ['inline_toc'])
|
||||
Widget.__init__(self, parent, ['inline_toc'])
|
||||
self.db, self.book_id = db, book_id
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
@ -18,9 +18,10 @@ class StructureDetectionWidget(Widget, Ui_Form):
|
||||
ICON = I('chapters.svg')
|
||||
HELP = _('Fine tune the detection of chapter headings and '
|
||||
'other document structure.')
|
||||
COMMIT_NAME = 'structure_detection'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'structure_detection',
|
||||
Widget.__init__(self, parent,
|
||||
['chapter', 'chapter_mark',
|
||||
'remove_first_image',
|
||||
'insert_metadata', 'page_breaks_before',
|
||||
|
@ -16,9 +16,10 @@ class TOCWidget(Widget, Ui_Form):
|
||||
TITLE = _('Table of\nContents')
|
||||
ICON = I('series.svg')
|
||||
HELP = _('Control the creation/conversion of the Table of Contents.')
|
||||
COMMIT_NAME = 'toc'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'toc',
|
||||
Widget.__init__(self, parent,
|
||||
['level1_toc', 'level2_toc', 'level3_toc',
|
||||
'toc_threshold', 'max_toc_links', 'no_chapters_in_toc',
|
||||
'use_auto_toc', 'toc_filter',
|
||||
|
@ -11,9 +11,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('TXT Input')
|
||||
HELP = _('Options specific to')+' TXT '+_('input')
|
||||
COMMIT_NAME = 'txt_input'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'txt_input',
|
||||
Widget.__init__(self, parent,
|
||||
['single_line_paras', 'print_formatted_paras', 'markdown',
|
||||
'markdown_disable_toc', 'preserve_spaces'])
|
||||
self.db, self.book_id = db, book_id
|
||||
|
@ -15,9 +15,10 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
TITLE = _('TXT Output')
|
||||
HELP = _('Options specific to')+' TXT '+_('output')
|
||||
COMMIT_NAME = 'txt_output'
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent, 'txt_output',
|
||||
Widget.__init__(self, parent,
|
||||
['newline', 'max_line_length', 'force_max_line_length',
|
||||
'inline_toc'])
|
||||
self.db, self.book_id = db, book_id
|
||||
|
@ -29,6 +29,7 @@ from calibre.customize.ui import initialized_plugins, is_disabled, enable_plugin
|
||||
input_format_plugins, \
|
||||
output_format_plugins, available_output_formats
|
||||
from calibre.utils.smtp import config as smtp_prefs
|
||||
from calibre.gui2.convert import config_widget_for_input_plugin
|
||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||
from calibre.gui2.convert.page_setup import PageSetupWidget
|
||||
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
||||
@ -36,6 +37,7 @@ from calibre.ebooks.conversion.plumber import Plumber
|
||||
from calibre.utils.logging import Log
|
||||
from calibre.gui2.convert.toc import TOCWidget
|
||||
|
||||
|
||||
class ConfigTabs(QTabWidget):
|
||||
|
||||
def __init__(self, parent):
|
||||
@ -58,15 +60,11 @@ class ConfigTabs(QTabWidget):
|
||||
self.widgets = [lf, ps, sd, toc]
|
||||
|
||||
for plugin in input_format_plugins():
|
||||
name = plugin.name.lower().replace(' ', '_')
|
||||
try:
|
||||
input_widget = __import__('calibre.gui2.convert.'+name,
|
||||
fromlist=[1])
|
||||
input_widget = config_widget_for_input_plugin(plugin)
|
||||
if input_widget is not None:
|
||||
pw = input_widget.PluginWidget
|
||||
pw.ICON = I('forward.svg')
|
||||
self.widgets.append(widget_factory(pw))
|
||||
except ImportError:
|
||||
continue
|
||||
|
||||
for plugin in output_format_plugins():
|
||||
name = plugin.name.lower().replace(' ', '_')
|
||||
|
@ -22,6 +22,7 @@ from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.ebooks.conversion.config import GuiRecommendations, \
|
||||
load_defaults, load_specifics, save_specifics
|
||||
from calibre.gui2.convert import bulk_defaults_for_input_format
|
||||
|
||||
def convert_single_ebook(parent, db, book_ids, auto_conversion=False, out_format=None):
|
||||
changed = False
|
||||
@ -148,7 +149,7 @@ class QueueBulk(QProgressDialog):
|
||||
temp_files = []
|
||||
|
||||
combined_recs = GuiRecommendations()
|
||||
default_recs = load_defaults('%s_input' % input_format)
|
||||
default_recs = bulk_defaults_for_input_format(input_format)
|
||||
for key in default_recs:
|
||||
combined_recs[key] = default_recs[key]
|
||||
if self.use_saved_single_settings:
|
||||
@ -208,7 +209,6 @@ class QueueBulk(QProgressDialog):
|
||||
self.queue(self.jobs, self.changed, self.bad, *self.args)
|
||||
|
||||
def fetch_scheduled_recipe(arg):
|
||||
from calibre.ebooks.conversion.config import load_defaults
|
||||
fmt = prefs['output_format'].lower()
|
||||
pt = PersistentTemporaryFile(suffix='_recipe_out.%s'%fmt.lower())
|
||||
pt.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user