From fe41b4a136df14116ccf92cc713efdc304934a9d Mon Sep 17 00:00:00 2001 From: Aristotelis <5459332+glutanimate@users.noreply.github.com> Date: Sat, 28 Oct 2023 22:50:15 +0200 Subject: [PATCH] Move IO webview internals to editor (#2784) --- qt/aqt/addcards.py | 4 ++-- qt/aqt/editor.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index 13b9e9cc5..930033b89 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -373,9 +373,9 @@ class AddCards(QMainWindow): self.ifCanClose(doClose) def add_io_note(self) -> None: - self.editor.web.eval("updateOcclusionsField();") + self.editor.update_occlusions_field() self.add_current_note() - self.editor.web.eval("resetIOImageLoaded()") + self.editor.reset_image_occlusion() # legacy aliases diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py index 6711a822f..a2a955bef 100644 --- a/qt/aqt/editor.py +++ b/qt/aqt/editor.py @@ -1124,6 +1124,12 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too self.web.eval(f"setImageField({json.dumps(image_field_html)})") self._setup_mask_editor(io_options) + def reset_image_occlusion(self) -> None: + self.web.eval("resetIOImageLoaded()") + + def update_occlusions_field(self) -> None: + self.web.eval("updateOcclusionsField()") + def _setup_mask_editor(self, io_options: dict): self.web.eval( 'require("anki/ui").loaded.then(() =>'