mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6540 (Requesting metadata download while one is already ongoing causes pop-up spam)
This commit is contained in:
parent
7692482955
commit
47fa5382b6
@ -16,6 +16,7 @@ from calibre.gui2.dialogs.metadata_bulk import MetadataBulkDialog
|
|||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.gui2.dialogs.progress import BlockingBusy
|
||||||
|
|
||||||
class EditMetadataAction(InterfaceAction):
|
class EditMetadataAction(InterfaceAction):
|
||||||
|
|
||||||
@ -95,18 +96,19 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
x = _('social metadata')
|
x = _('social metadata')
|
||||||
else:
|
else:
|
||||||
x = _('covers') if covers and not set_metadata else _('metadata')
|
x = _('covers') if covers and not set_metadata else _('metadata')
|
||||||
self.gui.progress_indicator.start(
|
|
||||||
_('Downloading %s for %d book(s)')%(x, len(ids)))
|
|
||||||
self._book_metadata_download_check = QTimer(self.gui)
|
self._book_metadata_download_check = QTimer(self.gui)
|
||||||
self._book_metadata_download_check.timeout.connect(self.book_metadata_download_check,
|
self._book_metadata_download_check.timeout.connect(self.book_metadata_download_check,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self._book_metadata_download_check.start(100)
|
self._book_metadata_download_check.start(100)
|
||||||
|
self._bb_dialog = BlockingBusy(_('Downloading %s for %d book(s)')%(x,
|
||||||
|
len(ids)), parent=self.gui)
|
||||||
|
self._bb_dialog.exec_()
|
||||||
|
|
||||||
def book_metadata_download_check(self):
|
def book_metadata_download_check(self):
|
||||||
if self._download_book_metadata.is_alive():
|
if self._download_book_metadata.is_alive():
|
||||||
return
|
return
|
||||||
self._book_metadata_download_check.stop()
|
self._book_metadata_download_check.stop()
|
||||||
self.gui.progress_indicator.stop()
|
self._bb_dialog.accept()
|
||||||
cr = self.gui.library_view.currentIndex().row()
|
cr = self.gui.library_view.currentIndex().row()
|
||||||
x = self._download_book_metadata
|
x = self._download_book_metadata
|
||||||
self._download_book_metadata = None
|
self._download_book_metadata = None
|
||||||
|
@ -5,9 +5,10 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
''''''
|
''''''
|
||||||
|
|
||||||
from PyQt4.Qt import QDialog, pyqtSignal, Qt
|
from PyQt4.Qt import QDialog, pyqtSignal, Qt, QVBoxLayout, QLabel, QFont
|
||||||
|
|
||||||
from calibre.gui2.dialogs.progress_ui import Ui_Dialog
|
from calibre.gui2.dialogs.progress_ui import Ui_Dialog
|
||||||
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
|
|
||||||
class ProgressDialog(QDialog, Ui_Dialog):
|
class ProgressDialog(QDialog, Ui_Dialog):
|
||||||
|
|
||||||
@ -69,3 +70,37 @@ class ProgressDialog(QDialog, Ui_Dialog):
|
|||||||
self._canceled()
|
self._canceled()
|
||||||
else:
|
else:
|
||||||
QDialog.keyPressEvent(self, ev)
|
QDialog.keyPressEvent(self, ev)
|
||||||
|
|
||||||
|
class BlockingBusy(QDialog):
|
||||||
|
|
||||||
|
def __init__(self, msg, parent=None, window_title=_('Working')):
|
||||||
|
QDialog.__init__(self, parent)
|
||||||
|
|
||||||
|
self._layout = QVBoxLayout()
|
||||||
|
self.setLayout(self._layout)
|
||||||
|
self.msg = QLabel(msg)
|
||||||
|
#self.msg.setWordWrap(True)
|
||||||
|
self.font = QFont()
|
||||||
|
self.font.setPointSize(self.font.pointSize() + 8)
|
||||||
|
self.msg.setFont(self.font)
|
||||||
|
self.pi = ProgressIndicator(self)
|
||||||
|
self.pi.setDisplaySize(100)
|
||||||
|
self._layout.addWidget(self.pi, 0, Qt.AlignHCenter)
|
||||||
|
self._layout.addSpacing(15)
|
||||||
|
self._layout.addWidget(self.msg, 0, Qt.AlignHCenter)
|
||||||
|
self.start()
|
||||||
|
self.setWindowTitle(window_title)
|
||||||
|
self.resize(self.sizeHint())
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.pi.startAnimation()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.pi.stopAnimation()
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
self.stop()
|
||||||
|
return QDialog.accept(self)
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
pass # Cannot cancel this dialog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user