Merge pull request #1391 from sobjornstad/change_note_type_hook

Add hook for selecting a new note type in the add window
This commit is contained in:
Damien Elmes 2021-09-27 18:38:40 +10:00 committed by GitHub
commit 0f48aa4a49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -148,6 +148,7 @@ class AddCards(QDialog):
self.editor.loadNote( self.editor.loadNote(
focusTo=min(self.editor.last_field_index or 0, len(new.fields) - 1) 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: def _load_new_note(self, sticky_fields_from: Optional[Note] = None) -> None:
note = self._new_note() note = self._new_note()

View file

@ -781,6 +781,12 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
return_type="str", return_type="str",
doc="""Allows changing the history line in the add-card window.""", 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 # Editing
################### ###################
Hook( Hook(