Skip to content
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

Merged
merged 6 commits into from
Jun 15, 2021
Merged

Conversation

ThoreBor
Copy link
Contributor

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.

Copy link
Member

@dae dae left a 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.

@@ -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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name="addons_dialog_will_delete_addon",
name="addons_dialog_will_delete_addons",

@@ -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]"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gui_hooks.addons_dialog_will_delete_addon(self, selected)
gui_hooks.addons_dialog_will_delete_addons(self, selected)

Copy link
Member

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.

@ThoreBor
Copy link
Contributor Author

Okay, you're right. It makes more sense like this. Thanks!
Sorry, I had some issues resolving local conflicts, but I think it should be fine now.

@dae dae merged commit 066a2e8 into ankitects:main Jun 15, 2021
@dae
Copy link
Member

dae commented Jun 15, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants