mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Regex-function mode: Show a confirmation popup when closing the function editor when there are unsaved changes
This commit is contained in:
parent
9319cd722a
commit
6514dde205
@ -14,7 +14,8 @@ from qt.core import QApplication, QDialogButtonBox, QFontMetrics, QHBoxLayout, Q
|
||||
from calibre.ebooks.oeb.polish.utils import apply_func_to_html_text, apply_func_to_match_groups
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
from calibre.gui2.tweak_book import dictionaries
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.tweak_book import dictionaries, tprefs
|
||||
from calibre.gui2.tweak_book.editor.text import TextEdit
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.utils.config import JSONConfig
|
||||
@ -253,6 +254,7 @@ class FunctionEditor(Dialog):
|
||||
l.addWidget(la)
|
||||
|
||||
l.addWidget(self.bb)
|
||||
self.initial_source = self.source
|
||||
|
||||
def sizeHint(self):
|
||||
fm = QFontMetrics(self.font())
|
||||
@ -285,6 +287,13 @@ class FunctionEditor(Dialog):
|
||||
|
||||
Dialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
if self.source != self.initial_source:
|
||||
if not confirm(_('All unsaved changes will be lost. Are you sure?'), 'function-replace-close-confirm',
|
||||
parent=self, config_set=tprefs):
|
||||
return
|
||||
return super().reject()
|
||||
|
||||
# Builtin functions ##########################################################
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user