From f076fa28afa459a3526c363b1a847adbd9cb681d Mon Sep 17 00:00:00 2001 From: 3ter <3ter@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:10:12 +0200 Subject: [PATCH] Add did-add-field-hook analogous to did-delete-field (#2574) * Add add field hook analogous to delete field * Add myself to contributors --- CONTRIBUTORS | 1 + qt/aqt/fields.py | 2 ++ qt/tools/genhooks_gui.py | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bacefc3cb..08a58695c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -127,6 +127,7 @@ Christopher Woggon Kavel Rao Ben Yip mmjang <752515918@qq.com> +3ter ******************** diff --git a/qt/aqt/fields.py b/qt/aqt/fields.py index 141300500..57d5aa843 100644 --- a/qt/aqt/fields.py +++ b/qt/aqt/fields.py @@ -186,6 +186,8 @@ class FieldDialog(QDialog): self.saveField() f = self.mm.new_field(name) self.mm.add_field(self.model, f) + gui_hooks.fields_did_add_field(self, f) + self.fillFields() self.form.fieldList.setCurrentRow(len(self.model["flds"]) - 1) diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index 7e049ee50..8cbdb586a 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -1244,6 +1244,10 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest) ), # Fields ################### + Hook( + name="fields_did_add_field", + args=["dialog: aqt.fields.FieldDialog", "field: anki.models.FieldDict"], + ), Hook( name="fields_did_rename_field", args=[