diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 1201565548..c7a97c5c40 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -624,10 +624,10 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=False, # Set skip_dialog_msg to a message displayed to the user skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'), skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True, - # Override icon (QIcon to be used as the icon for this dialog or string for I()) + # Override icon (QIcon to be used as the icon for this dialog or string for QIcon.ic()) override_icon=None, # Change the text/icons of the yes and no buttons. - # The icons must be QIcon objects or strings for I() + # The icons must be QIcon objects or strings for QIcon.ic() yes_text=None, no_text=None, yes_icon=None, no_icon=None, # Add an Abort button which if clicked will cause this function to raise # the Aborted exception diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py index 6890459fc1..180fc0ddf7 100644 --- a/src/calibre/gui2/actions/copy_to_library.py +++ b/src/calibre/gui2/actions/copy_to_library.py @@ -460,7 +460,9 @@ class CopyToLibraryAction(InterfaceAction): aname = _('Moving to') if delete_after else _('Copying to') dtitle = '%s %s'%(aname, os.path.basename(loc)) self.pd = ProgressDialog(dtitle, min=0, max=len(ids)-1, - parent=self.gui, cancelable=True, icon='lt.png') + parent=self.gui, cancelable=True, icon='lt.png', cancel_confirm_msg=_( + 'Aborting this operation means that only some books will be copied' + ' and resuming a partial copy is not supported. Are you sure you want to abort?')) def progress(idx, title): self.pd.set_msg(title) diff --git a/src/calibre/gui2/dialogs/progress.py b/src/calibre/gui2/dialogs/progress.py index 199e95675e..03c998b2ba 100644 --- a/src/calibre/gui2/dialogs/progress.py +++ b/src/calibre/gui2/dialogs/progress.py @@ -9,7 +9,7 @@ from qt.core import ( QDialog, pyqtSignal, Qt, QVBoxLayout, QLabel, QFont, QProgressBar, QSize, QDialogButtonBox, QApplication, QFontMetrics, QHBoxLayout, QIcon) -from calibre.gui2 import elided_text +from calibre.gui2 import elided_text, question_dialog from calibre.gui2.progress_indicator import ProgressIndicator @@ -17,8 +17,9 @@ class ProgressDialog(QDialog): canceled_signal = pyqtSignal() - def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None): + def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None, cancel_confirm_msg=''): QDialog.__init__(self, parent) + self.cancel_confirm_msg = cancel_confirm_msg if icon is None: self.l = l = QVBoxLayout(self) else: @@ -113,6 +114,12 @@ class ProgressDialog(QDialog): self.message.setText(elided_text(val, self.font(), self.message.minimumWidth()-10)) def _canceled(self, *args): + if self.cancel_confirm_msg: + if not question_dialog( + self, _('Are you sure?'), self.cancel_confirm_msg, override_icon='dialog_warning.png', + yes_text=_('Yes, abort'), no_text=_('No, keep copying') + ): + return self.canceled = True self.button_box.setDisabled(True) self.title = _('Aborting...')