mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Pass AddCards instance to notetype change hook (#2594)
Allows add-ons that modify AddCards to more easily react to notetype changes without needing to keep AddCards instances as state.
This commit is contained in:
parent
51a322c77e
commit
0a418e0612
2 changed files with 15 additions and 2 deletions
|
@ -188,8 +188,8 @@ class AddCards(QMainWindow):
|
|||
self.editor.loadNote(
|
||||
focusTo=min(self.editor.last_field_index or 0, len(new_note.fields) - 1)
|
||||
)
|
||||
gui_hooks.add_cards_did_change_note_type(
|
||||
old_note.note_type(), new_note.note_type()
|
||||
gui_hooks.addcards_did_change_note_type(
|
||||
self, old_note.note_type(), new_note.note_type()
|
||||
)
|
||||
|
||||
def _load_new_note(self, sticky_fields_from: Optional[Note] = None) -> None:
|
||||
|
|
|
@ -1013,6 +1013,19 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
|
|||
Hook(
|
||||
name="add_cards_did_change_note_type",
|
||||
args=["old: anki.models.NoteType", "new: anki.models.NoteType"],
|
||||
doc="""Deprecated. Use addcards_did_change_note_type instead.
|
||||
Executed after the user selects a new note type when adding
|
||||
cards.""",
|
||||
),
|
||||
Hook(
|
||||
name="addcards_did_change_note_type",
|
||||
args=[
|
||||
"addcards: aqt.addcards.AddCards",
|
||||
"old: anki.models.NoteType",
|
||||
"new: anki.models.NoteType",
|
||||
],
|
||||
replaces="add_cards_did_change_note_type",
|
||||
replaced_hook_args=["old: anki.models.NoteType", "new: anki.models.NoteType"],
|
||||
doc="""Executed after the user selects a new note type when adding
|
||||
cards.""",
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue