From 67f9fc519ed6212b4796ed606860e12a243a14f7 Mon Sep 17 00:00:00 2001 From: Soren Bjornstad Date: Fri, 24 Sep 2021 21:22:42 -0500 Subject: [PATCH] Add hook after selecting a new note type in the add window --- qt/aqt/addcards.py | 1 + qt/tools/genhooks_gui.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index ba8f5a82c..56bcc28a2 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -148,6 +148,7 @@ class AddCards(QDialog): self.editor.loadNote( focusTo=min(self.editor.last_field_index or 0, len(new.fields) - 1) ) + gui_hooks.add_cards_did_change_note_type(old.note_type(), new.note_type()) def _load_new_note(self, sticky_fields_from: Optional[Note] = None) -> None: note = self._new_note() diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index f7ad21e2b..fb3a26ef3 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -781,6 +781,12 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest) return_type="str", doc="""Allows changing the history line in the add-card window.""", ), + Hook( + name="add_cards_did_change_note_type", + args=["old: anki.models.NoteType", "new: anki.models.NoteType"], + doc="""Executed after the user selects a new note type when adding + cards.""", + ), # Editing ################### Hook(