mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
WIP: Make CuraPackageManager aggregate PluginRegistry data
CURA-4644
This commit is contained in:
parent
f510603cb5
commit
0f966115e6
5 changed files with 83 additions and 53 deletions
|
@ -4,10 +4,12 @@
|
|||
import re
|
||||
from typing import Dict
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtProperty, pyqtSignal
|
||||
from PyQt5.QtCore import Qt, pyqtProperty
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Qt.ListModel import ListModel
|
||||
|
||||
|
||||
## Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
|
||||
class PackagesModel(ListModel):
|
||||
IdRole = Qt.UserRole + 1
|
||||
|
@ -40,7 +42,7 @@ class PackagesModel(ListModel):
|
|||
self.addRoleName(PackagesModel.LastUpdatedRole, "last_updated")
|
||||
|
||||
# List of filters for queries. The result is the union of the each list of results.
|
||||
self._filter = {} # type: Dict[str,str]
|
||||
self._filter = {} # type: Dict[str, str]
|
||||
|
||||
def setMetadata(self, data):
|
||||
self._metadata = data
|
||||
|
|
|
@ -218,13 +218,13 @@ class Toolbox(QObject, Extension):
|
|||
|
||||
@pyqtSlot(str)
|
||||
def enablePlugin(self, plugin_id):
|
||||
self._plugin_registry.enablePlugin(plugin_id)
|
||||
self._plugin_registry.setPluginEnabled(plugin_id, True)
|
||||
self.metadataChanged.emit()
|
||||
Logger.log("i", "%s was set as 'active'.", plugin_id)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def disablePlugin(self, plugin_id):
|
||||
self._plugin_registry.disablePlugin(plugin_id)
|
||||
self._plugin_registry.setPluginEnabled(plugin_id, False)
|
||||
self.metadataChanged.emit()
|
||||
Logger.log("i", "%s was set as 'deactive'.", plugin_id)
|
||||
|
||||
|
@ -371,7 +371,7 @@ class Toolbox(QObject, Extension):
|
|||
print(json_data)
|
||||
# Create packages model with all packages:
|
||||
if not self._models["packages"]:
|
||||
self._models["packages"] = PackagesModel()
|
||||
self._models["packages"] = PackagesModel(self)
|
||||
self._metadata["packages"] = json_data["data"]
|
||||
self._models["packages"].setMetadata(self._metadata["packages"])
|
||||
self.metadataChanged.emit()
|
||||
|
@ -388,7 +388,7 @@ class Toolbox(QObject, Extension):
|
|||
self.metadataChanged.emit()
|
||||
|
||||
if not self._models["materials_showcase"]:
|
||||
self._models["materials_showcase"] = AuthorsModel()
|
||||
self._models["materials_showcase"] = AuthorsModel(self)
|
||||
# TODO: Replace this with a proper API call:
|
||||
self._models["materials_showcase"].setMetadata(self._metadata["materials_showcase"])
|
||||
self.metadataChanged.emit()
|
||||
|
@ -400,8 +400,7 @@ class Toolbox(QObject, Extension):
|
|||
Logger.log("w", "Toolbox: Received invalid JSON for package list.")
|
||||
return
|
||||
|
||||
|
||||
if reply.url() == self._request_urls["plugins_showcase"]:
|
||||
if reply.url() == self._request_urls["plugins_showcase"]:
|
||||
try:
|
||||
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||
# Create packages model with all packages:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue