mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -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))
|
bad.append(self.library_view.model().title(row))
|
||||||
|
|
||||||
if auto != []:
|
if auto != []:
|
||||||
autos = [self.library_view.model().title(row) for row in auto]
|
format = None
|
||||||
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,))
|
|
||||||
for fmt in self.device_manager.device_class.settings().format_map:
|
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()))):
|
if fmt in list(set(self.device_manager.device_class.settings().format_map).intersection(set(available_output_formats()))):
|
||||||
format = fmt
|
format = fmt
|
||||||
break
|
break
|
||||||
d.exec_()
|
if format is None:
|
||||||
self.auto_convert(_auto_ids, on_card, format)
|
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:
|
if bad:
|
||||||
bad = '\n'.join('<li>%s</li>'%(i,) for i in 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):
|
def auto_convert(self, row_ids, on_card, format):
|
||||||
previous = self.library_view.currentIndex()
|
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
|
if jobs == []: return
|
||||||
for func, args, desc, fmt, id, temp_files in jobs:
|
for func, args, desc, fmt, id, temp_files in jobs:
|
||||||
if id not in bad:
|
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 NoSupportedInputFormats
|
||||||
from calibre.gui2.convert.single import Config as SingleConfig
|
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
|
changed = False
|
||||||
jobs = []
|
jobs = []
|
||||||
bad = []
|
bad = []
|
||||||
@ -28,10 +28,12 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
|||||||
temp_files = []
|
temp_files = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = SingleConfig(parent, db, row_id)
|
d = SingleConfig(parent, db, row_id, None, out_format)
|
||||||
|
|
||||||
if auto_conversion:
|
if auto_conversion:
|
||||||
result = QDialog.Accepted
|
result = QDialog.Accepted
|
||||||
|
if d.output_format != out_format:
|
||||||
|
raise Exception('Output format not supported.')
|
||||||
else:
|
else:
|
||||||
result = d.exec_()
|
result = d.exec_()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user