mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2035215 ['abort' copy is too abrupt](https://bugs.launchpad.net/calibre/+bug/2035215)
This commit is contained in:
parent
12d419ff41
commit
71662297a1
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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...')
|
||||
|
Loading…
x
Reference in New Issue
Block a user