diff --git a/UM/PluginObject.py b/UM/PluginObject.py index 8e9c12c65c..3f6c9c1c56 100644 --- a/UM/PluginObject.py +++ b/UM/PluginObject.py @@ -12,10 +12,17 @@ class PluginObject: def __init__(self) -> None: self._plugin_id = None # type: Optional[str] self._version = None # type: Optional[str] + self._metadata = {} def setPluginId(self, plugin_id: str) -> None: self._plugin_id = plugin_id + def setMetaData(self, metadata): + self._metadata = metadata + + def getMetaData(self): + return self._metadata + def getPluginId(self) -> str: if not self._plugin_id: raise ValueError("The plugin ID needs to be set before the plugin can be used") diff --git a/UM/PluginRegistry.py b/UM/PluginRegistry.py index 5a58130faf..04f466581f 100644 --- a/UM/PluginRegistry.py +++ b/UM/PluginRegistry.py @@ -382,11 +382,17 @@ def loadPlugin(self, plugin_id: str) -> None: return for plugin_type, plugin_object in to_register.items(): if type(plugin_object) == list: - for nested_plugin_object in plugin_object: + for metadata_index, nested_plugin_object in enumerate(plugin_object): nested_plugin_object.setVersion(self._metadata[plugin_id].get("plugin", {}).get("version")) + all_metadata = self._metadata[plugin_id].get(plugin_type, []) + try: + nested_plugin_object.setMetaData(all_metadata[metadata_index]) + except IndexError: + nested_plugin_object.setMetaData({}) self._addPluginObject(nested_plugin_object, plugin_id, plugin_type) else: plugin_object.setVersion(self._metadata[plugin_id].get("plugin", {}).get("version")) + plugin_object.setMetaData(self._metadata[plugin_id].get(plugin_type, {})) self._addPluginObject(plugin_object, plugin_id, plugin_type) self._plugins[plugin_id] = plugin diff --git a/UM/Qt/Bindings/ActiveToolProxy.py b/UM/Qt/Bindings/ActiveToolProxy.py index 0835e8d883..a45085ed19 100644 --- a/UM/Qt/Bindings/ActiveToolProxy.py +++ b/UM/Qt/Bindings/ActiveToolProxy.py @@ -33,9 +33,8 @@ def valid(self): def activeToolPanel(self): if not self._active_tool: return QUrl() - try: - panel_file = PluginRegistry.getInstance().getMetaData(self._active_tool.getPluginId())["tool"]["tool_panel"] + panel_file = self._active_tool.getMetaData()["tool_panel"] except KeyError: return QUrl() diff --git a/UM/Qt/Bindings/ToolModel.py b/UM/Qt/Bindings/ToolModel.py index 5bff7c4516..60ed13d897 100644 --- a/UM/Qt/Bindings/ToolModel.py +++ b/UM/Qt/Bindings/ToolModel.py @@ -43,8 +43,9 @@ def _onToolsChanged(self): tools = self._controller.getAllTools() for name in tools: - tool_meta_data = PluginRegistry.getInstance().getMetaData(name).get("tool", {}) - location = PluginRegistry.getInstance().getMetaData(name).get("location", "") + plugin_id = tools[name].getPluginId() + tool_meta_data = tools[name].getMetaData() + location = PluginRegistry.getInstance().getMetaData(plugin_id).get("location", "") # Skip tools that are marked as not visible if "visible" in tool_meta_data and not tool_meta_data["visible"]: