diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index e3aa0e6b8c..1fad75fb96 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -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: