-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hook to onDelete in AddonsDialog #1232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! Some comments below.
qt/tools/genhooks_gui.py
Outdated
@@ -876,6 +876,11 @@ def on_top_toolbar_did_init_links(links, toolbar): | |||
args=["dialog: aqt.addons.AddonsDialog", "add_on: aqt.addons.AddonMeta"], | |||
doc="""Allows doing an action when a single add-on is selected.""", | |||
), | |||
Hook( | |||
name="addons_dialog_will_delete_addon", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name="addons_dialog_will_delete_addon", | |
name="addons_dialog_will_delete_addons", |
qt/tools/genhooks_gui.py
Outdated
@@ -876,6 +876,11 @@ def on_top_toolbar_did_init_links(links, toolbar): | |||
args=["dialog: aqt.addons.AddonsDialog", "add_on: aqt.addons.AddonMeta"], | |||
doc="""Allows doing an action when a single add-on is selected.""", | |||
), | |||
Hook( | |||
name="addons_dialog_will_delete_addon", | |||
args=["dialog: aqt.addons.AddonsDialog", "selected: List[str]"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args=["dialog: aqt.addons.AddonsDialog", "selected: List[str]"], | |
args=["dialog: aqt.addons.AddonsDialog", "ids: List[str]"], |
qt/aqt/addons.py
Outdated
@@ -842,6 +842,7 @@ def onViewFiles(self) -> None: | |||
|
|||
def onDelete(self) -> None: | |||
selected = self.selectedAddons() | |||
gui_hooks.addons_dialog_will_delete_addon(self, selected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gui_hooks.addons_dialog_will_delete_addon(self, selected) | |
gui_hooks.addons_dialog_will_delete_addons(self, selected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hook should probably be run after the 'not selected' and 'askUser' lines, not before it.
d845239
to
2f943b6
Compare
Okay, you're right. It makes more sense like this. Thanks! |
Thanks! |
This would be useful for showing a message before deleting an add-on. I would use it for either informing the user that deleting the add-on will only delete the local files, not the data on my server, or for automatically deleting the data before deleting the add-on.
I'm not sure if
"selected: List[str]"
is correct, so please let me know if I should change it.