diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index ebd4c006f8..4366db041c 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Item { - property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1 + property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfMaterialPackagesByAuthor(model.id) : 1 property int installedPackages: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0) height: childrenRect.height Layout.alignment: Qt.AlignTop | Qt.AlignLeft diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml index 15d1ae302c..845bbe8f91 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Rectangle { - property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1 + property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfMaterialPackagesByAuthor(model.id) : 1 property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0) id: tileBase width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 52b00f5069..615fc06ebc 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -514,10 +514,11 @@ class Toolbox(QObject, Extension): count += 1 return count + # This slot is only used to get the number of material packages by author, not any other type of packages. @pyqtSlot(str, result = int) - def getTotalNumberOfPackagesByAuthor(self, author_id: str) -> int: + def getTotalNumberOfMaterialPackagesByAuthor(self, author_id: str) -> int: count = 0 - for package in self._metadata["packages"]: + for package in self._metadata["materials_available"]: if package["author"]["author_id"] == author_id: count += 1 return count @@ -606,8 +607,21 @@ class Toolbox(QObject, Extension): self.resetDownload() return + # HACK: These request are not handled independently at this moment, but together from the "packages" call + do_not_handle = [ + "materials_available", + "materials_showcase", + "plugins_available", + "plugins_showcase", + ] + if reply.operation() == QNetworkAccessManager.GetOperation: for type, url in self._request_urls.items(): + + # HACK: Do nothing because we'll handle these from the "packages" call + if type in do_not_handle: + return + if reply.url() == url: if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200: try: @@ -623,18 +637,6 @@ class Toolbox(QObject, Extension): if not self._models[type]: Logger.log("e", "Could not find the %s model.", type) break - - # HACK - do_not_handle = [ - "materials_available", - "materials_showcase", - "plugins_available", - "plugins_showcase", - ] - - # Do nothing because we'll handle these from the "packages" call - if type in do_not_handle: - return self._metadata[type] = json_data["data"] self._models[type].setMetadata(self._metadata[type])