mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Auto convert work
This commit is contained in:
parent
ed1c56d637
commit
4f0dc1d8c7
@ -493,6 +493,7 @@ class DeviceGUI(object):
|
|||||||
return
|
return
|
||||||
files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(ids,
|
files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(ids,
|
||||||
fmts, paths=True, set_metadata=True,
|
fmts, paths=True, set_metadata=True,
|
||||||
|
specific_format=specific_format,
|
||||||
exclude_auto=do_auto_convert)
|
exclude_auto=do_auto_convert)
|
||||||
if do_auto_convert:
|
if do_auto_convert:
|
||||||
ids = list(set(ids).difference(_auto_ids))
|
ids = list(set(ids).difference(_auto_ids))
|
||||||
@ -563,9 +564,9 @@ class DeviceGUI(object):
|
|||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
||||||
autos = '\n'.join('%s'%i for i in autos)
|
autos = '\n'.join('%s'%i for i in autos)
|
||||||
info_dialog(self, _('No suitable formats'),
|
info_dialog(self, _('No suitable formats'),
|
||||||
_('Auto converting the following books before uploading to '
|
_('Auto converting the following books before sending via '
|
||||||
'the device:'), det_msg=autos, show=True)
|
'email:'), det_msg=autos, show=True)
|
||||||
self.auto_convert_mail(to, delete_from_library, auto, format)
|
self.auto_convert_mail(to, fmts, delete_from_library, auto, format)
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
bad = '\n'.join('%s'%(i,) for i in bad)
|
bad = '\n'.join('%s'%(i,) for i in bad)
|
||||||
|
@ -1062,7 +1062,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
current = self.library_view.currentIndex()
|
current = self.library_view.currentIndex()
|
||||||
self.library_view.model().current_changed(current, previous)
|
self.library_view.model().current_changed(current, previous)
|
||||||
|
|
||||||
def auto_convert_mail(self, to, delete_from_library, book_ids, format):
|
def auto_convert_mail(self, to, fmts, delete_from_library, book_ids, format):
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.library_view.selectionModel().selectedRows()]
|
||||||
@ -1073,7 +1073,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
job = self.job_manager.run_job(Dispatcher(self.book_auto_converted_mail),
|
job = self.job_manager.run_job(Dispatcher(self.book_auto_converted_mail),
|
||||||
func, args=args, description=desc)
|
func, args=args, description=desc)
|
||||||
self.conversion_jobs[job] = (temp_files, fmt, id,
|
self.conversion_jobs[job] = (temp_files, fmt, id,
|
||||||
delete_from_library, to)
|
delete_from_library, to, fmts)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
self.library_view.model().refresh_rows(rows)
|
self.library_view.model().refresh_rows(rows)
|
||||||
@ -1152,7 +1152,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.sync_to_device(on_card, False, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
self.sync_to_device(on_card, False, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_auto_converted_mail(self, job):
|
def book_auto_converted_mail(self, job):
|
||||||
temp_files, fmt, book_id, delete_from_library, to = self.conversion_jobs.pop(job)
|
temp_files, fmt, book_id, delete_from_library, to, fmts = self.conversion_jobs.pop(job)
|
||||||
try:
|
try:
|
||||||
if job.failed:
|
if job.failed:
|
||||||
self.job_exception(job)
|
self.job_exception(job)
|
||||||
@ -1173,7 +1173,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
current = self.library_view.currentIndex()
|
current = self.library_view.currentIndex()
|
||||||
self.library_view.model().current_changed(current, QModelIndex())
|
self.library_view.model().current_changed(current, QModelIndex())
|
||||||
|
|
||||||
self.send_by_mail(to, fmt, delete_from_library, send_ids=[book_id], do_auto_convert=False)
|
self.send_by_mail(to, fmts, delete_from_library, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_converted(self, job):
|
def book_converted(self, job):
|
||||||
temp_files, fmt, book_id = self.conversion_jobs.pop(job)
|
temp_files, fmt, book_id = self.conversion_jobs.pop(job)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user