From 32ef53092fc0f03cea4db02125bc866dfc57b643 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Sat, 21 Dec 2019 16:48:05 +0100 Subject: [PATCH] Allow handing config editing back to Anki after calling add-on action Allows add-ons to partially manage their own configuration while still delegating the actual UI to Anki. --- aqt/addons.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aqt/addons.py b/aqt/addons.py index 4af79fee1..273b4d589 100644 --- a/aqt/addons.py +++ b/aqt/addons.py @@ -6,7 +6,7 @@ import json import re import zipfile from collections import defaultdict -from typing import Any, Callable, Dict +from typing import Any, Callable, Dict, Optional from zipfile import ZipFile import jsonschema @@ -358,7 +358,7 @@ and have been disabled: %(found)s") % dict(name=self.addonName(dir), found=addon # Add-on Config ###################################################################### - _configButtonActions: Dict[str, Callable[[], None]] = {} + _configButtonActions: Dict[str, Callable[[], Optional[bool]]] = {} _configUpdatedActions: Dict[str, Callable[[Any], None]] = {} def addonConfigDefaults(self, dir): @@ -640,8 +640,9 @@ class AddonsDialog(QDialog): # does add-on manage its own config? act = self.mgr.configAction(addon) if act: - act() - return + ret = act() + if ret is not False: + return conf = self.mgr.getConfig(addon) if conf is None: