mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure the proceed notification dialog is deleted immediately after it is hidden and the callback is called
This commit is contained in:
parent
597374d0a3
commit
c00cc7e8d3
@ -117,11 +117,11 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
|
|
||||||
payload = (id_map, failed_ids, failed_covers)
|
payload = (id_map, failed_ids, failed_covers)
|
||||||
from calibre.gui2.dialogs.message_box import ProceedNotification
|
from calibre.gui2.dialogs.message_box import ProceedNotification
|
||||||
p = ProceedNotification(payload, job.html_details,
|
p = ProceedNotification(self.apply_downloaded_metadata,
|
||||||
|
payload, job.html_details,
|
||||||
_('Download log'), _('Download complete'), msg,
|
_('Download log'), _('Download complete'), msg,
|
||||||
det_msg=det_msg, show_copy_button=show_copy_button,
|
det_msg=det_msg, show_copy_button=show_copy_button,
|
||||||
parent=self.gui)
|
parent=self.gui)
|
||||||
p.proceed.connect(self.apply_downloaded_metadata)
|
|
||||||
p.show()
|
p.show()
|
||||||
|
|
||||||
def apply_downloaded_metadata(self, payload):
|
def apply_downloaded_metadata(self, payload):
|
||||||
|
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
|
|
||||||
from PyQt4.Qt import (QDialog, QIcon, QApplication, QSize, QKeySequence,
|
from PyQt4.Qt import (QDialog, QIcon, QApplication, QSize, QKeySequence,
|
||||||
QAction, Qt, pyqtSignal, QTextBrowser, QDialogButtonBox, QVBoxLayout)
|
QAction, Qt, QTextBrowser, QDialogButtonBox, QVBoxLayout)
|
||||||
|
|
||||||
from calibre.constants import __version__
|
from calibre.constants import __version__
|
||||||
from calibre.gui2.dialogs.message_box_ui import Ui_Dialog
|
from calibre.gui2.dialogs.message_box_ui import Ui_Dialog
|
||||||
@ -145,15 +145,15 @@ class ViewLog(QDialog): # {{{
|
|||||||
|
|
||||||
class ProceedNotification(MessageBox): # {{{
|
class ProceedNotification(MessageBox): # {{{
|
||||||
|
|
||||||
proceed = pyqtSignal(object)
|
def __init__(self, callback, payload, html_log, log_viewer_title, title, msg,
|
||||||
|
det_msg='', show_copy_button=False, parent=None):
|
||||||
def __init__(self, payload, html_log, log_viewer_title, title, msg, det_msg='', show_copy_button=False, parent=None):
|
|
||||||
'''
|
'''
|
||||||
A non modal popup that notifies the user that a background task has
|
A non modal popup that notifies the user that a background task has
|
||||||
been completed. If they user clicks yes, the proceed signal is emitted
|
been completed.
|
||||||
with payload as its argument.
|
|
||||||
|
|
||||||
:param payload: Arbitrary object, emitted in the proceed signal
|
:param callback: A callable that is called with payload if the user
|
||||||
|
asks to proceed. Note that this is always called in the GUI thread
|
||||||
|
:param payload: Arbitrary object, passed to callback
|
||||||
:param html_log: An HTML or plain text log
|
:param html_log: An HTML or plain text log
|
||||||
:param log_viewer_title: The title for the log viewer window
|
:param log_viewer_title: The title for the log viewer window
|
||||||
:param title: The title fo rthis popup
|
:param title: The title fo rthis popup
|
||||||
@ -166,25 +166,29 @@ class ProceedNotification(MessageBox): # {{{
|
|||||||
self.payload = payload
|
self.payload = payload
|
||||||
self.html_log = html_log
|
self.html_log = html_log
|
||||||
self.log_viewer_title = log_viewer_title
|
self.log_viewer_title = log_viewer_title
|
||||||
self.finished.connect(self.do_proceed)
|
self.finished.connect(self.do_proceed, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
self.vlb = self.bb.addButton(_('View log'), self.bb.ActionRole)
|
self.vlb = self.bb.addButton(_('View log'), self.bb.ActionRole)
|
||||||
self.vlb.setIcon(QIcon(I('debug.png')))
|
self.vlb.setIcon(QIcon(I('debug.png')))
|
||||||
self.vlb.clicked.connect(self.show_log)
|
self.vlb.clicked.connect(self.show_log)
|
||||||
self.det_msg_toggle.setVisible(bool(det_msg))
|
self.det_msg_toggle.setVisible(bool(det_msg))
|
||||||
self.setModal(False)
|
self.setModal(False)
|
||||||
|
self.callback = callback
|
||||||
|
|
||||||
def show_log(self):
|
def show_log(self):
|
||||||
self.log_viewer = ViewLog(self.log_viewer_title, self.html_log,
|
self.log_viewer = ViewLog(self.log_viewer_title, self.html_log,
|
||||||
parent=self)
|
parent=self)
|
||||||
|
|
||||||
def do_proceed(self, result):
|
def do_proceed(self, result):
|
||||||
if result == self.Accepted:
|
|
||||||
self.proceed.emit(self.payload)
|
|
||||||
try:
|
try:
|
||||||
self.proceed.disconnect()
|
if result == self.Accepted:
|
||||||
except:
|
self.callback(self.payload)
|
||||||
pass
|
finally:
|
||||||
|
# Ensure this notification is garbage collected
|
||||||
|
self.callback = None
|
||||||
|
self.setParent(None)
|
||||||
|
self.finished.disconnect()
|
||||||
|
self.vlb.clicked.disconnect()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -145,10 +145,10 @@ def download(ids, db, do_identify, covers,
|
|||||||
ans = {}
|
ans = {}
|
||||||
count = 0
|
count = 0
|
||||||
all_failed = True
|
all_failed = True
|
||||||
'''
|
#'''
|
||||||
# Test apply dialog
|
# Test apply dialog
|
||||||
all_failed = do_identify = covers = False
|
all_failed = do_identify = covers = False
|
||||||
'''
|
#'''
|
||||||
for i, mi in izip(ids, metadata):
|
for i, mi in izip(ids, metadata):
|
||||||
if abort.is_set():
|
if abort.is_set():
|
||||||
log.error('Aborting...')
|
log.error('Aborting...')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user