Add simplified legacy exporter hooks

Allows add-ons to be notified of exports when legacy handlers are enabled, without the need for monkey-patches.
This commit is contained in:
Glutanimate 2022-07-18 17:34:21 +02:00
parent 475f9814ca
commit 423a87ab7c
2 changed files with 14 additions and 0 deletions

View file

@ -196,6 +196,7 @@ class ExportDialog(QDialog):
else:
self.on_export_finished()
gui_hooks.legacy_exporter_will_export(self.exporter.ext)
if self.isVerbatim:
gui_hooks.collection_will_temporarily_close(self.mw.col)
self.mw.progress.start()
@ -213,6 +214,7 @@ class ExportDialog(QDialog):
msg = tr.exporting_note_exported(count=self.exporter.count)
else:
msg = tr.exporting_card_exported(count=self.exporter.count)
gui_hooks.legacy_exporter_did_export(self.exporter.ext)
tooltip(msg, period=3000)
QDialog.reject(self)

View file

@ -816,6 +816,8 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
`output` provides access to the unused/missing file lists and the text output that will be shown in the Check Media screen.""",
),
# Importing/exporting data
###################
Hook(
name="exporter_will_export",
args=[
@ -844,6 +846,16 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
],
doc="""Called after collection and deck exports.""",
),
Hook(
name="legacy_exporter_will_export",
args=["file_extension: str"],
doc="""Called before collection and deck exports performed by legacy exporters.""",
),
Hook(
name="legacy_exporter_did_export",
args=["file_extension: str"],
doc="""Called after collection and deck exports performed by legacy exporters.""",
),
# Dialog Manager
###################
Hook(