diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 3ede8f4b61..255abe3999 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -538,14 +538,20 @@ class CoversModel(QAbstractListModel): # {{{ current_cover = QPixmap(I('default_cover.png')) 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 = {} for i, plugin in enumerate(metadata_plugins(['cover'])): self.covers.append((plugin.name+'\n'+_('Searching...'), QVariant(self.blank), None, True)) self.plugin_map[plugin] = i+1 + if do_reset: + self.reset() + def get_item(self, src, pmap, waiting=False): sz = '%dx%d'%(pmap.width(), pmap.height()) text = QVariant(src + '\n' + sz) @@ -654,6 +660,9 @@ class CoversView(QListView): # {{{ self.select(0) self.delegate.start_animation() + def reset_covers(self): + self.m.reset_covers() + def clear_failed(self): plugin = self.m.plugin_for_index(self.currentIndex()) self.m.clear_failed() @@ -683,12 +692,18 @@ class CoversWidget(QWidget): # {{{ l.addWidget(self.covers_view, 1, 0) self.continue_processing = True + def reset_covers(self): + self.covers_view.reset_covers() + def start(self, book, current_cover, title, authors): + self.continue_processing = True + self.abort.clear() self.book, self.current_cover = book, current_cover self.title, self.authors = title, authors self.log('Starting cover download for:', book.title) self.log('Query:', title, authors, self.book.identifiers) - self.msg.setText('
'+_('Downloading covers for %s, please wait...')%book.title) + self.msg.setText('
'+ + _('Downloading covers for %s, please wait...')%book.title) self.covers_view.start() self.worker = CoverWorker(self.log, self.abort, self.title, @@ -726,8 +741,9 @@ class CoversWidget(QWidget): # {{{ if num < 2: txt = _('Could not find any covers for %s')%self.book.title else: - txt = _('Found %(num)d covers of %(title)s. Pick the one you like' - ' best.')%dict(num=num-1, title=self.title) + txt = _('Found %(num)d covers of %(title)s. ' + 'Pick the one you like best.')%dict(num=num-1, + title=self.title) self.msg.setText(txt) self.finished.emit() @@ -832,10 +848,14 @@ class FullFetch(QDialog): # {{{ self.next_button.clicked.connect(self.next_clicked) self.ok_button = self.bb.button(self.bb.Ok) 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.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.ok_button.setVisible(False) + self.prev_button.setVisible(False) self.identify_widget = IdentifyWidget(self.log, self) self.identify_widget.rejected.connect(self.reject) @@ -857,12 +877,21 @@ class FullFetch(QDialog): # {{{ def book_selected(self, book): self.next_button.setVisible(False) self.ok_button.setVisible(True) + self.prev_button.setVisible(True) self.book = book self.stack.setCurrentIndex(1) self.log('\n\n') self.covers_widget.start(book, self.current_cover, 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): # Prevent the usual dialog accept mechanisms from working pass