mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 05:03:42 +02:00
ToC Editor: Ignore in succession clicks on the OK and Cancel buttons to avoid accidentally closing the window when finishing creating a new entry
This commit is contained in:
parent
016a62b95e
commit
fad59ba7c7
2 changed files with 16 additions and 0 deletions
|
|
@ -16,6 +16,7 @@
|
|||
QWidget, pyqtSignal
|
||||
)
|
||||
from threading import Thread
|
||||
from time import monotonic
|
||||
|
||||
from calibre.constants import TOC_DIALOG_APP_UID, islinux, iswindows
|
||||
from calibre.ebooks.oeb.polish.container import AZW3Container, get_container
|
||||
|
|
@ -988,6 +989,7 @@ class TOCEditor(QDialog): # {{{
|
|||
|
||||
def __init__(self, pathtobook, title=None, parent=None, prefs=None, write_result_to=None):
|
||||
QDialog.__init__(self, parent)
|
||||
self.last_reject_at = self.last_accept_at = -1000
|
||||
self.write_result_to = write_result_to
|
||||
self.prefs = prefs or te_prefs
|
||||
self.pathtobook = pathtobook
|
||||
|
|
@ -1052,6 +1054,9 @@ def add_new_item(self, item, where):
|
|||
self.stacks.setCurrentIndex(2)
|
||||
|
||||
def accept(self):
|
||||
if monotonic() - self.last_accept_at < 1:
|
||||
return
|
||||
self.last_accept_at = monotonic()
|
||||
if self.stacks.currentIndex() == 2:
|
||||
self.toc_view.update_item(*self.item_edit.result)
|
||||
self.prefs['toc_edit_splitter_state'] = bytearray(self.item_edit.splitter.saveState())
|
||||
|
|
@ -1079,6 +1084,9 @@ def really_accept(self, tb):
|
|||
def reject(self):
|
||||
if not self.bb.isEnabled():
|
||||
return
|
||||
if monotonic() - self.last_reject_at < 1:
|
||||
return
|
||||
self.last_reject_at = monotonic()
|
||||
if self.stacks.currentIndex() == 2:
|
||||
self.prefs['toc_edit_splitter_state'] = bytearray(self.item_edit.splitter.saveState())
|
||||
self.stacks.setCurrentIndex(1)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
QSize, QStackedWidget, QStyledItemDelegate, Qt, QTimer, QTreeWidget,
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
||||
)
|
||||
from time import monotonic
|
||||
|
||||
from calibre.ebooks.oeb.polish.toc import commit_toc, get_toc
|
||||
from calibre.gui2 import error_dialog, make_view_use_window_background
|
||||
|
|
@ -26,6 +27,7 @@ class TOCEditor(QDialog):
|
|||
|
||||
def __init__(self, title=None, parent=None):
|
||||
QDialog.__init__(self, parent)
|
||||
self.last_reject_at = self.last_accept_at = -1000
|
||||
|
||||
t = title or current_container().mi.title
|
||||
self.book_title = t
|
||||
|
|
@ -64,6 +66,9 @@ def add_new_item(self, item, where):
|
|||
self.stacks.setCurrentIndex(1)
|
||||
|
||||
def accept(self):
|
||||
if monotonic() - self.last_accept_at < 1:
|
||||
return
|
||||
self.last_accept_at = monotonic()
|
||||
if self.stacks.currentIndex() == 1:
|
||||
self.toc_view.update_item(*self.item_edit.result)
|
||||
tprefs['toc_edit_splitter_state'] = bytearray(self.item_edit.splitter.saveState())
|
||||
|
|
@ -87,6 +92,9 @@ def really_accept(self, tb):
|
|||
def reject(self):
|
||||
if not self.bb.isEnabled():
|
||||
return
|
||||
if monotonic() - self.last_reject_at < 1:
|
||||
return
|
||||
self.last_reject_at = monotonic()
|
||||
if self.stacks.currentIndex() == 1:
|
||||
tprefs['toc_edit_splitter_state'] = bytearray(self.item_edit.splitter.saveState())
|
||||
self.stacks.setCurrentIndex(0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue