Auto convert: Check for format, use correct format in conversion.

This commit is contained in:
John Schember 2009-05-06 07:01:27 -04:00
parent 067baed7f2
commit dbe4123bc2
3 changed files with 15 additions and 9 deletions

View File

@ -678,14 +678,18 @@ 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
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)

View File

@ -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:

View File

@ -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_()