From 6be2cc69a8e8361ac24e143b4cc2d1350b7de239 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Mar 2023 09:42:56 +0530 Subject: [PATCH] Forgot that the ToC editor in the edit book tool uses a different code path. Copy over the macOS workaround. --- src/calibre/gui2/tweak_book/toc.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/tweak_book/toc.py b/src/calibre/gui2/tweak_book/toc.py index 6758f1f4fe..5f085f15dd 100644 --- a/src/calibre/gui2/tweak_book/toc.py +++ b/src/calibre/gui2/tweak_book/toc.py @@ -5,14 +5,15 @@ __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' from qt.core import ( - QAction, QApplication, QDialog, QDialogButtonBox, QGridLayout, QIcon, QMenu, - QSize, QStackedWidget, QStyledItemDelegate, Qt, QTimer, QTreeWidget, - QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal + QAction, QApplication, QDialog, QDialogButtonBox, QGridLayout, QIcon, QMenu, QSize, + QStackedWidget, QStyledItemDelegate, Qt, QTimer, QTreeWidget, QTreeWidgetItem, + QVBoxLayout, QWidget, pyqtSignal, ) from time import monotonic +from calibre.constants import ismacos from calibre.ebooks.oeb.polish.toc import commit_toc, get_toc -from calibre.gui2 import error_dialog, make_view_use_window_background +from calibre.gui2 import error_dialog, info_dialog, make_view_use_window_background from calibre.gui2.toc.main import ItemEdit, TOCView from calibre.gui2.tweak_book import TOP, actions, current_container, tprefs from calibre_extensions.progress_indicator import set_no_activate_on_click @@ -61,6 +62,15 @@ class TOCEditor(QDialog): def add_new_item(self, item, where): self.item_edit(item, where) self.stacks.setCurrentIndex(1) + if ismacos: + QTimer.singleShot(0, self.workaround_macos_mouse_with_webview_bug) + + def workaround_macos_mouse_with_webview_bug(self): + # macOS is weird: https://bugs.launchpad.net/calibre/+bug/2004639 + # needed as of Qt 6.4.2 + d = info_dialog(self, _('Loading...'), _('Loading view, please wait...'), show_copy_button=False) + QTimer.singleShot(0, d.reject) + d.exec() def accept(self): if monotonic() - self.last_accept_at < 1: