mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Auto convert: Check for format, use correct format in conversion.
This commit is contained in:
parent
067baed7f2
commit
dbe4123bc2
@ -678,16 +678,20 @@ class DeviceGUI(object):
|
||||
bad.append(self.library_view.model().title(row))
|
||||
|
||||
if auto != []:
|
||||
autos = [self.library_view.model().title(row) for row in auto]
|
||||
autos = '\n'.join('<li>%s</li>'%(i,) for i in autos)
|
||||
d = info_dialog(self, _('No suitable formats'),
|
||||
_('Auto converting the following books before uploading to the device:<br><ul>%s</ul>')%(autos,))
|
||||
format = None
|
||||
for fmt in self.device_manager.device_class.settings().format_map:
|
||||
if fmt in list(set(self.device_manager.device_class.settings().format_map).intersection(set(available_output_formats()))):
|
||||
format = fmt
|
||||
break
|
||||
d.exec_()
|
||||
self.auto_convert(_auto_ids, on_card, format)
|
||||
if format is None:
|
||||
bad += auto
|
||||
else:
|
||||
autos = [self.library_view.model().title(row) for row in auto]
|
||||
autos = '\n'.join('<li>%s</li>'%(i,) for i in autos)
|
||||
d = info_dialog(self, _('No suitable formats'),
|
||||
_('Auto converting the following books before uploading to the device:<br><ul>%s</ul>')%(autos,))
|
||||
d.exec_()
|
||||
self.auto_convert(_auto_ids, on_card, format)
|
||||
|
||||
if bad:
|
||||
bad = '\n'.join('<li>%s</li>'%(i,) for i in bad)
|
||||
|
@ -973,7 +973,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
def auto_convert(self, row_ids, on_card, format):
|
||||
previous = self.library_view.currentIndex()
|
||||
|
||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, row_ids, True)
|
||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, row_ids, True, format)
|
||||
if jobs == []: return
|
||||
for func, args, desc, fmt, id, temp_files in jobs:
|
||||
if id not in bad:
|
||||
|
@ -14,7 +14,7 @@ from calibre.gui2.convert import load_specifics
|
||||
from calibre.gui2.convert.single import NoSupportedInputFormats
|
||||
from calibre.gui2.convert.single import Config as SingleConfig
|
||||
|
||||
def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
||||
def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=None):
|
||||
changed = False
|
||||
jobs = []
|
||||
bad = []
|
||||
@ -28,10 +28,12 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
||||
temp_files = []
|
||||
|
||||
try:
|
||||
d = SingleConfig(parent, db, row_id)
|
||||
d = SingleConfig(parent, db, row_id, None, out_format)
|
||||
|
||||
if auto_conversion:
|
||||
result = QDialog.Accepted
|
||||
if d.output_format != out_format:
|
||||
raise Exception('Output format not supported.')
|
||||
else:
|
||||
result = d.exec_()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user