mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Confirm cancel on library restore dialog
Fixes #1823204 [Enhancement: avoid losing hours of work](https://bugs.launchpad.net/calibre/+bug/1823204)
This commit is contained in:
parent
6db83eab73
commit
50b55e4d3e
@ -35,7 +35,7 @@ class DBRestore(QDialog):
|
|||||||
self.msg.setWordWrap(True)
|
self.msg.setWordWrap(True)
|
||||||
self.bb = QDialogButtonBox(QDialogButtonBox.Cancel)
|
self.bb = QDialogButtonBox(QDialogButtonBox.Cancel)
|
||||||
self.l.addWidget(self.bb)
|
self.l.addWidget(self.bb)
|
||||||
self.bb.rejected.connect(self.reject)
|
self.bb.rejected.connect(self.confirm_cancel)
|
||||||
self.resize(self.sizeHint() + QSize(100, 50))
|
self.resize(self.sizeHint() + QSize(100, 50))
|
||||||
self.error = None
|
self.error = None
|
||||||
self.rejected = False
|
self.rejected = False
|
||||||
@ -58,6 +58,12 @@ class DBRestore(QDialog):
|
|||||||
self.restorer.progress_callback = lambda x, y: x
|
self.restorer.progress_callback = lambda x, y: x
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
|
||||||
|
def confirm_cancel(self):
|
||||||
|
if question_dialog(self, _('Are you sure?'), _(
|
||||||
|
'The restore has not completed, are you sure you want to cancel?'),
|
||||||
|
default_yes=False, override_icon='dialog_warning.png'):
|
||||||
|
self.reject()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.restorer.is_alive():
|
if self.restorer.is_alive():
|
||||||
QTimer.singleShot(10, self.update)
|
QTimer.singleShot(10, self.update)
|
||||||
@ -136,4 +142,8 @@ def repair_library_at(library_path, parent=None, wait_time=2):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from calibre.gui2 import Application
|
||||||
|
app = Application([])
|
||||||
|
repair_library_at('/t')
|
||||||
|
del app
|
||||||
|
Loading…
x
Reference in New Issue
Block a user