mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
GUI: bulk convert when multiple books selected.
This commit is contained in:
parent
88beebd0a3
commit
be516ba66b
@ -312,11 +312,11 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
cm.addAction(_('Bulk convert'))
|
||||
self.action_convert.setMenu(cm)
|
||||
QObject.connect(cm.actions()[0],
|
||||
SIGNAL('triggered(bool)'), self.convert_single)
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook, bulk=False))
|
||||
QObject.connect(cm.actions()[1],
|
||||
SIGNAL('triggered(bool)'), self.convert_bulk)
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook, bulk=True))
|
||||
QObject.connect(self.action_convert,
|
||||
SIGNAL('triggered(bool)'), self.convert_single)
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook, bulk=False))
|
||||
self.convert_menu = cm
|
||||
|
||||
pm = QMenu()
|
||||
@ -1156,32 +1156,17 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
return None
|
||||
return [self.library_view.model().db.id(r) for r in rows]
|
||||
|
||||
def convert_bulk(self, checked):
|
||||
def convert_ebook(self, checked, bulk=None):
|
||||
book_ids = self.get_books_for_conversion()
|
||||
if book_ids is None: return
|
||||
previous = self.library_view.currentIndex()
|
||||
rows = [x.row() for x in \
|
||||
self.library_view.selectionModel().selectedRows()]
|
||||
jobs, changed, bad = convert_bulk_ebook(self,
|
||||
if bulk or (not bulk and len(book_ids) > 1):
|
||||
jobs, changed, bad = convert_bulk_ebook(self,
|
||||
self.library_view.model().db, book_ids, out_format=prefs['output_format'])
|
||||
for func, args, desc, fmt, id, temp_files in jobs:
|
||||
if id not in bad:
|
||||
job = self.job_manager.run_job(Dispatcher(self.book_converted),
|
||||
func, args=args, description=desc)
|
||||
self.conversion_jobs[job] = (temp_files, fmt, id)
|
||||
|
||||
if changed:
|
||||
self.library_view.model().refresh_rows(rows)
|
||||
current = self.library_view.currentIndex()
|
||||
self.library_view.model().current_changed(current, previous)
|
||||
|
||||
def convert_single(self, checked):
|
||||
book_ids = self.get_books_for_conversion()
|
||||
if book_ids is None: return
|
||||
previous = self.library_view.currentIndex()
|
||||
rows = [x.row() for x in \
|
||||
self.library_view.selectionModel().selectedRows()]
|
||||
jobs, changed, bad = convert_single_ebook(self,
|
||||
else:
|
||||
jobs, changed, bad = convert_single_ebook(self,
|
||||
self.library_view.model().db, book_ids, out_format=prefs['output_format'])
|
||||
for func, args, desc, fmt, id, temp_files in jobs:
|
||||
if id not in bad:
|
||||
|
Loading…
x
Reference in New Issue
Block a user