Extend add-on API with setConfigUpdatedAction
Allows add-on authors to define an action to be performed upon manual editing of the add-on configuration through the ConfigEditor
This commit is contained in:
parent
8325f5b396
commit
8935b99188
@ -204,6 +204,7 @@ When loading '%(name)s':
|
|||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
_configButtonActions = {}
|
_configButtonActions = {}
|
||||||
|
_configUpdatedActions = {}
|
||||||
|
|
||||||
def addonConfigDefaults(self, dir):
|
def addonConfigDefaults(self, dir):
|
||||||
path = os.path.join(self.addonsFolder(dir), "config.json")
|
path = os.path.join(self.addonsFolder(dir), "config.json")
|
||||||
@ -227,6 +228,9 @@ When loading '%(name)s':
|
|||||||
def configAction(self, addon):
|
def configAction(self, addon):
|
||||||
return self._configButtonActions.get(addon)
|
return self._configButtonActions.get(addon)
|
||||||
|
|
||||||
|
def configUpdatedAction(self, addon):
|
||||||
|
return self._configUpdatedActions.get(addon)
|
||||||
|
|
||||||
# Add-on Config API
|
# Add-on Config API
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
@ -246,6 +250,10 @@ When loading '%(name)s':
|
|||||||
addon = self.addonFromModule(module)
|
addon = self.addonFromModule(module)
|
||||||
self._configButtonActions[addon] = fn
|
self._configButtonActions[addon] = fn
|
||||||
|
|
||||||
|
def setConfigUpdatedAction(self, module, fn):
|
||||||
|
addon = self.addonFromModule(module)
|
||||||
|
self._configUpdatedActions[addon] = fn
|
||||||
|
|
||||||
def writeConfig(self, module, conf):
|
def writeConfig(self, module, conf):
|
||||||
addon = self.addonFromModule(module)
|
addon = self.addonFromModule(module)
|
||||||
meta = self.addonMeta(addon)
|
meta = self.addonMeta(addon)
|
||||||
@ -484,4 +492,9 @@ class ConfigEditor(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.mgr.writeConfig(self.addon, self.conf)
|
self.mgr.writeConfig(self.addon, self.conf)
|
||||||
|
|
||||||
|
act = self.mgr.configUpdatedAction(self.addon)
|
||||||
|
if act:
|
||||||
|
act()
|
||||||
|
|
||||||
super().accept()
|
super().accept()
|
||||||
|
Loading…
Reference in New Issue
Block a user