Add hook after selecting a new note type in the add window

This commit is contained in:
Soren Bjornstad 2021-09-24 21:22:42 -05:00 committed by Soren Bjornstad
parent 94c4f99343
commit 67f9fc519e
2 changed files with 7 additions and 0 deletions

View file

@ -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()

View file

@ -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(