mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Merge remote-tracking branch 'origin/3.4'
This commit is contained in:
commit
4598b7a831
4 changed files with 335 additions and 4 deletions
|
@ -64,14 +64,17 @@ class Toolbox(QObject, Extension):
|
|||
]
|
||||
self._request_urls = {}
|
||||
self._to_update = [] # Package_ids that are waiting to be updated
|
||||
self._old_plugin_ids = []
|
||||
|
||||
# Data:
|
||||
self._metadata = {
|
||||
"authors": [],
|
||||
"packages": [],
|
||||
"plugins_showcase": [],
|
||||
"plugins_available": [],
|
||||
"plugins_installed": [],
|
||||
"materials_showcase": [],
|
||||
"materials_available": [],
|
||||
"materials_installed": []
|
||||
}
|
||||
|
||||
|
@ -166,7 +169,9 @@ class Toolbox(QObject, Extension):
|
|||
"authors": QUrl("{base_url}/authors".format(base_url=self._api_url)),
|
||||
"packages": QUrl("{base_url}/packages".format(base_url=self._api_url)),
|
||||
"plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
||||
"materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url))
|
||||
"plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url=self._api_url)),
|
||||
"materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
||||
"materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url))
|
||||
}
|
||||
|
||||
# Get the API root for the packages API depending on Cura version settings.
|
||||
|
@ -233,15 +238,52 @@ class Toolbox(QObject, Extension):
|
|||
dialog = Application.getInstance().createQmlComponent(path, {"toolbox": self})
|
||||
return dialog
|
||||
|
||||
|
||||
def _convertPluginMetadata(self, plugin: dict) -> dict:
|
||||
formatted = {
|
||||
"package_id": plugin["id"],
|
||||
"package_type": "plugin",
|
||||
"display_name": plugin["plugin"]["name"],
|
||||
"package_version": plugin["plugin"]["version"],
|
||||
"sdk_version": plugin["plugin"]["api"],
|
||||
"author": {
|
||||
"author_id": plugin["plugin"]["author"],
|
||||
"display_name": plugin["plugin"]["author"]
|
||||
},
|
||||
"is_installed": True,
|
||||
"description": plugin["plugin"]["description"]
|
||||
}
|
||||
return formatted
|
||||
|
||||
@pyqtSlot()
|
||||
def _updateInstalledModels(self) -> None:
|
||||
|
||||
# This is moved here to avoid code duplication and so that after installing plugins they get removed from the
|
||||
# list of old plugins
|
||||
old_plugin_ids = self._plugin_registry.getInstalledPlugins()
|
||||
installed_package_ids = self._package_manager.getAllInstalledPackageIDs()
|
||||
|
||||
self._old_plugin_ids = []
|
||||
self._old_plugin_metadata = []
|
||||
|
||||
for plugin_id in old_plugin_ids:
|
||||
if plugin_id not in installed_package_ids:
|
||||
Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id)
|
||||
|
||||
old_metadata = self._plugin_registry.getMetaData(plugin_id)
|
||||
new_metadata = self._convertPluginMetadata(old_metadata)
|
||||
|
||||
self._old_plugin_ids.append(plugin_id)
|
||||
self._old_plugin_metadata.append(new_metadata)
|
||||
|
||||
all_packages = self._package_manager.getAllInstalledPackagesInfo()
|
||||
if "plugin" in all_packages:
|
||||
self._metadata["plugins_installed"] = all_packages["plugin"]
|
||||
self._metadata["plugins_installed"] = all_packages["plugin"] + self._old_plugin_metadata
|
||||
self._models["plugins_installed"].setMetadata(self._metadata["plugins_installed"])
|
||||
self.metadataChanged.emit()
|
||||
if "material" in all_packages:
|
||||
self._metadata["materials_installed"] = all_packages["material"]
|
||||
# TODO: ADD MATERIALS HERE ONCE MATERIALS PORTION OF TOOLBOX IS LIVE
|
||||
self._models["materials_installed"].setMetadata(self._metadata["materials_installed"])
|
||||
self.metadataChanged.emit()
|
||||
|
||||
|
@ -325,6 +367,9 @@ class Toolbox(QObject, Extension):
|
|||
# --------------------------------------------------------------------------
|
||||
@pyqtSlot(str, result = bool)
|
||||
def canUpdate(self, package_id: str) -> bool:
|
||||
if self.isOldPlugin(package_id):
|
||||
return True
|
||||
|
||||
local_package = self._package_manager.getInstalledPackageInfo(package_id)
|
||||
if local_package is None:
|
||||
return False
|
||||
|
@ -363,6 +408,13 @@ class Toolbox(QObject, Extension):
|
|||
return True
|
||||
return False
|
||||
|
||||
# Check for plugins that were installed with the old plugin browser
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isOldPlugin(self, plugin_id: str) -> bool:
|
||||
if plugin_id in self._old_plugin_ids:
|
||||
return True
|
||||
return False
|
||||
|
||||
def loadingComplete(self) -> bool:
|
||||
populated = 0
|
||||
for list in self._metadata.items():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue