mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
View specific format window: If a conversion finishes in the background making a new format available, update the window. Fixes #1363416 [[Feature Request] eBook conversion jobs should automatically update the book's "View specific format" window upon job completion](https://bugs.launchpad.net/calibre/+bug/1363416)
This commit is contained in:
parent
69362feb1e
commit
680f599f32
@ -259,6 +259,7 @@ class ConvertAction(InterfaceAction):
|
||||
|
||||
with open(temp_files[-1].name, 'rb') as data:
|
||||
db.add_format(book_id, fmt, data, index_is_id=True)
|
||||
self.gui.book_converted.emit(book_id, fmt)
|
||||
self.gui.status_bar.show_message(job.description +
|
||||
(' completed'), 2000)
|
||||
finally:
|
||||
|
@ -158,8 +158,8 @@ class ViewAction(InterfaceAction):
|
||||
|
||||
db = self.gui.library_view.model().db
|
||||
rows = [r.row() for r in rows]
|
||||
formats = [db.formats(row) for row in rows]
|
||||
formats = [list(f.upper().split(',')) if f else None for f in formats]
|
||||
book_ids = [db.id(r) for r in rows]
|
||||
formats = [[x.upper() for x in db.new_api.formats(book_id)] for book_id in book_ids]
|
||||
all_fmts = set([])
|
||||
for x in formats:
|
||||
if x:
|
||||
@ -171,7 +171,9 @@ class ViewAction(InterfaceAction):
|
||||
return
|
||||
d = ChooseFormatDialog(self.gui, _('Choose the format to view'),
|
||||
list(sorted(all_fmts)))
|
||||
self.gui.book_converted.connect(d.book_converted)
|
||||
if d.exec_() == d.Accepted:
|
||||
formats = [[x.upper() for x in db.new_api.formats(book_id)] for book_id in book_ids]
|
||||
fmt = d.format()
|
||||
orig_num = len(rows)
|
||||
rows = [rows[i] for i in range(len(rows)) if formats[i] and fmt in
|
||||
@ -184,6 +186,7 @@ class ViewAction(InterfaceAction):
|
||||
_('Not all the selected books were available in'
|
||||
' the %s format. You should convert'
|
||||
' them first.')%fmt, show=True)
|
||||
self.gui.book_converted.disconnect(d.book_converted)
|
||||
|
||||
def _view_check(self, num, max_=3):
|
||||
if num <= max_:
|
||||
@ -283,8 +286,7 @@ class ViewAction(InterfaceAction):
|
||||
self.persistent_files.append(pt)
|
||||
pt.close()
|
||||
self.gui.device_manager.view_book(
|
||||
Dispatcher(self.book_downloaded_for_viewing),
|
||||
path, pt.name)
|
||||
Dispatcher(self.book_downloaded_for_viewing), path, pt.name)
|
||||
|
||||
def _view_books(self, rows):
|
||||
if not rows or len(rows) == 0:
|
||||
|
@ -22,6 +22,13 @@ class ChooseFormatDialog(QDialog, Ui_ChooseFormatDialog):
|
||||
self.formats.setCurrentRow(0)
|
||||
self._format = None
|
||||
|
||||
def book_converted(self, book_id, fmt):
|
||||
fmt = fmt.upper()
|
||||
if fmt not in self._formats:
|
||||
self._formats.append(fmt)
|
||||
self.formats.addItem(QListWidgetItem(
|
||||
file_icon_provider().icon_from_ext(fmt.lower()), fmt.upper()))
|
||||
|
||||
def activated_slot(self, *args):
|
||||
self.accept()
|
||||
|
||||
|
@ -142,6 +142,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
'The main GUI'
|
||||
|
||||
proceed_requested = pyqtSignal(object, object)
|
||||
book_converted = pyqtSignal(object, object)
|
||||
|
||||
def __init__(self, opts, parent=None, gui_debug=None):
|
||||
global _gui
|
||||
|
Loading…
x
Reference in New Issue
Block a user