mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Make the warning dialog that pops up when you try to quit while the editor is saving changes in the background a little more clear. Fixes #1347171 [Background save dialog confusion with "save changes"](https://bugs.launchpad.net/calibre/+bug/1347171)
This commit is contained in:
parent
8a40261757
commit
a6c1e806c2
@ -323,7 +323,11 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
|
|||||||
skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'),
|
skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'),
|
||||||
skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True,
|
skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True,
|
||||||
# Override icon (QIcon to be used as the icon for this dialog)
|
# Override icon (QIcon to be used as the icon for this dialog)
|
||||||
override_icon=None):
|
override_icon=None,
|
||||||
|
# Change the text/icons of the yes and no buttons.
|
||||||
|
# The icons must be QIcon objects or strings for I()
|
||||||
|
yes_text=None, no_text=None, yes_icon=None, no_icon=None,
|
||||||
|
):
|
||||||
from calibre.gui2.dialogs.message_box import MessageBox
|
from calibre.gui2.dialogs.message_box import MessageBox
|
||||||
|
|
||||||
auto_skip = set(gprefs.get('questions_to_auto_skip', []))
|
auto_skip = set(gprefs.get('questions_to_auto_skip', []))
|
||||||
@ -332,7 +336,8 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
|
|||||||
|
|
||||||
d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
|
d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
|
||||||
show_copy_button=show_copy_button, default_yes=default_yes,
|
show_copy_button=show_copy_button, default_yes=default_yes,
|
||||||
q_icon=override_icon)
|
q_icon=override_icon, yes_text=yes_text, no_text=no_text,
|
||||||
|
yes_icon=yes_icon, no_icon=no_icon)
|
||||||
|
|
||||||
if skip_dialog_name is not None and skip_dialog_msg:
|
if skip_dialog_name is not None and skip_dialog_msg:
|
||||||
tc = d.toggle_checkbox
|
tc = d.toggle_checkbox
|
||||||
|
@ -25,7 +25,8 @@ class MessageBox(QDialog, Ui_Dialog): # {{{
|
|||||||
det_msg='',
|
det_msg='',
|
||||||
q_icon=None,
|
q_icon=None,
|
||||||
show_copy_button=True,
|
show_copy_button=True,
|
||||||
parent=None, default_yes=True):
|
parent=None, default_yes=True,
|
||||||
|
yes_text=None, no_text=None, yes_icon=None, no_icon=None):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
if q_icon is None:
|
if q_icon is None:
|
||||||
icon = {
|
icon = {
|
||||||
@ -71,6 +72,14 @@ class MessageBox(QDialog, Ui_Dialog): # {{{
|
|||||||
self.bb.button(self.bb.Yes if default_yes else self.bb.No
|
self.bb.button(self.bb.Yes if default_yes else self.bb.No
|
||||||
).setDefault(True)
|
).setDefault(True)
|
||||||
self.default_yes = default_yes
|
self.default_yes = default_yes
|
||||||
|
if yes_text is not None:
|
||||||
|
self.bb.button(self.bb.Yes).setText(yes_text)
|
||||||
|
if no_text is not None:
|
||||||
|
self.bb.button(self.bb.No).setText(no_text)
|
||||||
|
if yes_icon is not None:
|
||||||
|
self.bb.button(self.bb.Yes).setIcon(yes_icon if isinstance(yes_icon, QIcon) else QIcon(I(yes_icon)))
|
||||||
|
if no_icon is not None:
|
||||||
|
self.bb.button(self.bb.No).setIcon(yes_icon if isinstance(no_icon, QIcon) else QIcon(I(no_icon)))
|
||||||
else:
|
else:
|
||||||
self.bb.button(self.bb.Ok).setDefault(True)
|
self.bb.button(self.bb.Ok).setDefault(True)
|
||||||
|
|
||||||
|
@ -1281,23 +1281,27 @@ class Boss(QObject):
|
|||||||
self.gui.insert_char.show()
|
self.gui.insert_char.show()
|
||||||
|
|
||||||
# Shutdown {{{
|
# Shutdown {{{
|
||||||
def quit(self):
|
|
||||||
if not self.confirm_quit():
|
|
||||||
return
|
|
||||||
self.save_state()
|
|
||||||
self.shutdown()
|
|
||||||
QApplication.instance().quit()
|
|
||||||
|
|
||||||
def confirm_quit(self):
|
def quit(self):
|
||||||
if self.doing_terminal_save:
|
if self.doing_terminal_save:
|
||||||
return False
|
return False
|
||||||
if self.save_manager.has_tasks:
|
if self.save_manager.has_tasks:
|
||||||
if not question_dialog(
|
if question_dialog(
|
||||||
self.gui, _('Are you sure?'), _(
|
self.gui, _('Are you sure?'), _(
|
||||||
'The current book is being saved in the background, quitting will abort'
|
'The current book is being saved in the background. Quitting now will'
|
||||||
' the save process, are you sure?'), default_yes=False):
|
' <b>abort the save process</b>! Finish saving first?'),
|
||||||
|
yes_text=_('Finish &saving first'), no_text=_('&Quit immediately')):
|
||||||
|
self.start_terminal_save_indicator()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not self.confirm_quit():
|
||||||
|
return False
|
||||||
|
self.save_state()
|
||||||
|
self.shutdown()
|
||||||
|
QApplication.instance().quit()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def confirm_quit(self):
|
||||||
if self.gui.action_save.isEnabled():
|
if self.gui.action_save.isEnabled():
|
||||||
d = QDialog(self.gui)
|
d = QDialog(self.gui)
|
||||||
d.l = QGridLayout(d)
|
d.l = QGridLayout(d)
|
||||||
@ -1329,13 +1333,17 @@ class Boss(QObject):
|
|||||||
return False
|
return False
|
||||||
if d.do_save:
|
if d.do_save:
|
||||||
self.gui.action_save.trigger()
|
self.gui.action_save.trigger()
|
||||||
|
self.start_terminal_save_indicator()
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def start_terminal_save_indicator(self):
|
||||||
|
self.save_state()
|
||||||
self.gui.blocking_job.set_msg(_('Saving, please wait...'))
|
self.gui.blocking_job.set_msg(_('Saving, please wait...'))
|
||||||
self.gui.blocking_job.start()
|
self.gui.blocking_job.start()
|
||||||
self.doing_terminal_save = True
|
self.doing_terminal_save = True
|
||||||
QTimer.singleShot(50, self.check_terminal_save)
|
QTimer.singleShot(50, self.check_terminal_save)
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def check_terminal_save(self):
|
def check_terminal_save(self):
|
||||||
if self.save_manager.has_tasks:
|
if self.save_manager.has_tasks:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user