Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender Class Reference
Inheritance diagram for UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender:
UM.PluginObject.PluginObject

Public Member Functions

None __init__ (self, i18nCatalog catalog=None)
 
str getAppenderType (self)
 
Dict[str, Dict[str, Any]] getAdditionalSettingDefinitions (self)
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
str getId (self)
 
None setPluginId (self, str plugin_id)
 
None setMetaData (self, Dict[str, Any] metadata)
 
Dict[str, Any] getMetaData (self)
 
str getPluginId (self)
 
None setVersion (self, str version)
 
str getVersion (self)
 

Public Attributes

 appender_type
 

Protected Member Functions

Dict[str, Any] _prependIdToSettings (self, Dict[str, Any] settings)
 

Protected Attributes

 _catalog
 
- Protected Attributes inherited from UM.PluginObject.PluginObject
 _plugin_id
 
 _version
 
 _metadata
 
 _name
 

Detailed Description

This class is a way for plugins to append additional settings, not defined by/for the main program itself.

Each plugin needs to register as either a 'setting_definitions_appender' or 'backend_plugin'.

Any implementation also needs to fill 'self.definition_file_paths' with a list of files with setting definitions.
Each file should be a json list of setting categories, either matching existing names, or be a new category.
Each category and setting has the same json structure as the main settings otherwise.

It's also possible to set the 'self.appender_type', if there are many kinds of plugins to implement this,
in order to prevent name-clashes.

Lastly, if setting-definitions are to be made on the fly by the plugin, override 'getAdditionalSettingDefinitions',
instead of providing the files. This should then return a dict, as if parsed by json.

Constructor & Destructor Documentation

◆ __init__()

None UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender.__init__ ( self,
i18nCatalog catalog = None )

Reimplemented from UM.PluginObject.PluginObject.

Member Function Documentation

◆ _prependIdToSettings()

Dict[str, Any] UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender._prependIdToSettings ( self,
Dict[str, Any] settings )
protected
 This takes the whole (extra) settings-map as defined by the provider, and returns a tag-renamed version.

Note that this function also translates the (label and description of the) settings, if a catalog is present.

Additional (appended) settings will need to be prepended with (an) extra identifier(s)/namespaces to not collide.
This is done for when there are multiple additional settings appenders that might not know about each other.
This includes any formulas, which will also be included in the renaming process.

Appended settings may not be the same as 'baseline' (so any 'non-appended' settings) settings.
(But may of course clash between different providers and versions, that's the whole point of this function...)
Furthermore, it's assumed that formulas within the appended settings will only use settings either;
 - as defined within the baseline, or;
 - any other settings defined _by the provider itself_.

For each key that is renamed, this results in a mapping <key> -> _<provider_type>__<id*>__<version>__<key>
 where '<id*>' is the version of the provider, but converted from using points to using underscores.
Example: 'tapdance_factor' might become '_plugin__dancingprinter__1_2_99__tapdance_factor'
Also note that all the tag_... parameters will be forced to lower-case.

:param tag_type: Type of the additional settings appender, for example; "PLUGIN".
:param tag_id: ID of the provider. Should be unique.
:param tag_version: Version of the provider. Points will be replaced by underscores.
:param settings: The settings as originally provided.

:returns: Remapped settings, where each settings-name is properly tagged/'namespaced'.

◆ getAdditionalSettingDefinitions()

Dict[str, Dict[str, Any]] UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender.getAdditionalSettingDefinitions ( self)
Return the settings added by this plugin in json format.
Put values in self.definition_file_paths if you wish to load from files, or override this function otherwise.

The settings should be divided by category (either existing or new ones).
Settings in existing categories will be appended, new categories will be created.

Setting names (not labels) will be post-processed ('mangled') internally to prevent name-clashes.
NOTE: The 'mangled' names are also the ones send out to any backend!
(See the _prependIdToSettings function below for a more precise explanation.)

:return: Dictionary of settings-categories, containing settings-definitions (with post-processed names).

◆ getAppenderType()

str UM.Settings.AdditionalSettingDefinitionsAppender.AdditionalSettingDefinitionsAppender.getAppenderType ( self)
Return an extra identifier prepended to the setting internal id, to prevent name-clashes with other plugins.

The documentation for this class was generated from the following file: