mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #855055 ("Back" button on download metadata dialog box)
This commit is contained in:
parent
cebaee7f23
commit
1e9a8643eb
@ -538,14 +538,20 @@ class CoversModel(QAbstractListModel): # {{{
|
|||||||
current_cover = QPixmap(I('default_cover.png'))
|
current_cover = QPixmap(I('default_cover.png'))
|
||||||
|
|
||||||
self.blank = QPixmap(I('blank.png')).scaled(150, 200)
|
self.blank = QPixmap(I('blank.png')).scaled(150, 200)
|
||||||
|
self.cc = current_cover
|
||||||
|
self.reset_covers(do_reset=False)
|
||||||
|
|
||||||
self.covers = [self.get_item(_('Current cover'), current_cover)]
|
def reset_covers(self, do_reset=True):
|
||||||
|
self.covers = [self.get_item(_('Current cover'), self.cc)]
|
||||||
self.plugin_map = {}
|
self.plugin_map = {}
|
||||||
for i, plugin in enumerate(metadata_plugins(['cover'])):
|
for i, plugin in enumerate(metadata_plugins(['cover'])):
|
||||||
self.covers.append((plugin.name+'\n'+_('Searching...'),
|
self.covers.append((plugin.name+'\n'+_('Searching...'),
|
||||||
QVariant(self.blank), None, True))
|
QVariant(self.blank), None, True))
|
||||||
self.plugin_map[plugin] = i+1
|
self.plugin_map[plugin] = i+1
|
||||||
|
|
||||||
|
if do_reset:
|
||||||
|
self.reset()
|
||||||
|
|
||||||
def get_item(self, src, pmap, waiting=False):
|
def get_item(self, src, pmap, waiting=False):
|
||||||
sz = '%dx%d'%(pmap.width(), pmap.height())
|
sz = '%dx%d'%(pmap.width(), pmap.height())
|
||||||
text = QVariant(src + '\n' + sz)
|
text = QVariant(src + '\n' + sz)
|
||||||
@ -654,6 +660,9 @@ class CoversView(QListView): # {{{
|
|||||||
self.select(0)
|
self.select(0)
|
||||||
self.delegate.start_animation()
|
self.delegate.start_animation()
|
||||||
|
|
||||||
|
def reset_covers(self):
|
||||||
|
self.m.reset_covers()
|
||||||
|
|
||||||
def clear_failed(self):
|
def clear_failed(self):
|
||||||
plugin = self.m.plugin_for_index(self.currentIndex())
|
plugin = self.m.plugin_for_index(self.currentIndex())
|
||||||
self.m.clear_failed()
|
self.m.clear_failed()
|
||||||
@ -683,12 +692,18 @@ class CoversWidget(QWidget): # {{{
|
|||||||
l.addWidget(self.covers_view, 1, 0)
|
l.addWidget(self.covers_view, 1, 0)
|
||||||
self.continue_processing = True
|
self.continue_processing = True
|
||||||
|
|
||||||
|
def reset_covers(self):
|
||||||
|
self.covers_view.reset_covers()
|
||||||
|
|
||||||
def start(self, book, current_cover, title, authors):
|
def start(self, book, current_cover, title, authors):
|
||||||
|
self.continue_processing = True
|
||||||
|
self.abort.clear()
|
||||||
self.book, self.current_cover = book, current_cover
|
self.book, self.current_cover = book, current_cover
|
||||||
self.title, self.authors = title, authors
|
self.title, self.authors = title, authors
|
||||||
self.log('Starting cover download for:', book.title)
|
self.log('Starting cover download for:', book.title)
|
||||||
self.log('Query:', title, authors, self.book.identifiers)
|
self.log('Query:', title, authors, self.book.identifiers)
|
||||||
self.msg.setText('<p>'+_('Downloading covers for <b>%s</b>, please wait...')%book.title)
|
self.msg.setText('<p>'+
|
||||||
|
_('Downloading covers for <b>%s</b>, please wait...')%book.title)
|
||||||
self.covers_view.start()
|
self.covers_view.start()
|
||||||
|
|
||||||
self.worker = CoverWorker(self.log, self.abort, self.title,
|
self.worker = CoverWorker(self.log, self.abort, self.title,
|
||||||
@ -726,8 +741,9 @@ class CoversWidget(QWidget): # {{{
|
|||||||
if num < 2:
|
if num < 2:
|
||||||
txt = _('Could not find any covers for <b>%s</b>')%self.book.title
|
txt = _('Could not find any covers for <b>%s</b>')%self.book.title
|
||||||
else:
|
else:
|
||||||
txt = _('Found <b>%(num)d</b> covers of %(title)s. Pick the one you like'
|
txt = _('Found <b>%(num)d</b> covers of %(title)s. '
|
||||||
' best.')%dict(num=num-1, title=self.title)
|
'Pick the one you like best.')%dict(num=num-1,
|
||||||
|
title=self.title)
|
||||||
self.msg.setText(txt)
|
self.msg.setText(txt)
|
||||||
|
|
||||||
self.finished.emit()
|
self.finished.emit()
|
||||||
@ -832,10 +848,14 @@ class FullFetch(QDialog): # {{{
|
|||||||
self.next_button.clicked.connect(self.next_clicked)
|
self.next_button.clicked.connect(self.next_clicked)
|
||||||
self.ok_button = self.bb.button(self.bb.Ok)
|
self.ok_button = self.bb.button(self.bb.Ok)
|
||||||
self.ok_button.clicked.connect(self.ok_clicked)
|
self.ok_button.clicked.connect(self.ok_clicked)
|
||||||
|
self.prev_button = self.bb.addButton(_('Back'), self.bb.ActionRole)
|
||||||
|
self.prev_button.setIcon(QIcon(I('back.png')))
|
||||||
|
self.prev_button.clicked.connect(self.back_clicked)
|
||||||
self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole)
|
self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole)
|
||||||
self.log_button.clicked.connect(self.view_log)
|
self.log_button.clicked.connect(self.view_log)
|
||||||
self.log_button.setIcon(QIcon(I('debug.png')))
|
self.log_button.setIcon(QIcon(I('debug.png')))
|
||||||
self.ok_button.setVisible(False)
|
self.ok_button.setVisible(False)
|
||||||
|
self.prev_button.setVisible(False)
|
||||||
|
|
||||||
self.identify_widget = IdentifyWidget(self.log, self)
|
self.identify_widget = IdentifyWidget(self.log, self)
|
||||||
self.identify_widget.rejected.connect(self.reject)
|
self.identify_widget.rejected.connect(self.reject)
|
||||||
@ -857,12 +877,21 @@ class FullFetch(QDialog): # {{{
|
|||||||
def book_selected(self, book):
|
def book_selected(self, book):
|
||||||
self.next_button.setVisible(False)
|
self.next_button.setVisible(False)
|
||||||
self.ok_button.setVisible(True)
|
self.ok_button.setVisible(True)
|
||||||
|
self.prev_button.setVisible(True)
|
||||||
self.book = book
|
self.book = book
|
||||||
self.stack.setCurrentIndex(1)
|
self.stack.setCurrentIndex(1)
|
||||||
self.log('\n\n')
|
self.log('\n\n')
|
||||||
self.covers_widget.start(book, self.current_cover,
|
self.covers_widget.start(book, self.current_cover,
|
||||||
self.title, self.authors)
|
self.title, self.authors)
|
||||||
|
|
||||||
|
def back_clicked(self):
|
||||||
|
self.next_button.setVisible(True)
|
||||||
|
self.ok_button.setVisible(False)
|
||||||
|
self.prev_button.setVisible(False)
|
||||||
|
self.stack.setCurrentIndex(0)
|
||||||
|
self.covers_widget.cancel()
|
||||||
|
self.covers_widget.reset_covers()
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
# Prevent the usual dialog accept mechanisms from working
|
# Prevent the usual dialog accept mechanisms from working
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user