diff --git a/plugins/Toolbox/resources/qml/dialogs/CompatibilityDialog.qml b/plugins/Toolbox/resources/qml/dialogs/CompatibilityDialog.qml index f5a20986d1..7bd85db544 100644 --- a/plugins/Toolbox/resources/qml/dialogs/CompatibilityDialog.qml +++ b/plugins/Toolbox/resources/qml/dialogs/CompatibilityDialog.qml @@ -48,6 +48,7 @@ UM.Dialog{ { font: UM.Theme.getFont("default") text: catalog.i18nc("@label", "The following packages will be added:") + visible: toolbox.has_compatible_packages color: UM.Theme.getColor("text") height: contentHeight + UM.Theme.getSize("default_margin").height } @@ -59,8 +60,8 @@ UM.Dialog{ Item { width: parent.width - property var lineHeight: 60 - visible: model.is_compatible == "True" ? true : false + property int lineHeight: 60 + visible: model.is_compatible === "True" ? true : false height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the compatible packages here Image { @@ -90,6 +91,7 @@ UM.Dialog{ { font: UM.Theme.getFont("default") text: catalog.i18nc("@label", "The following packages can not be installed because of incompatible Cura version:") + visible: toolbox.has_incompatible_packages color: UM.Theme.getColor("text") height: contentHeight + UM.Theme.getSize("default_margin").height } @@ -101,8 +103,8 @@ UM.Dialog{ Item { width: parent.width - property var lineHeight: 60 - visible: model.is_compatible == "True" ? false : true + property int lineHeight: 60 + visible: model.is_compatible === "True" ? false : true height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the incompatible packages here Image { diff --git a/plugins/Toolbox/src/SubscribedPackagesModel.py b/plugins/Toolbox/src/SubscribedPackagesModel.py index f8340ab7a0..bac8b33712 100644 --- a/plugins/Toolbox/src/SubscribedPackagesModel.py +++ b/plugins/Toolbox/src/SubscribedPackagesModel.py @@ -10,6 +10,7 @@ class SubscribedPackagesModel(ListModel): def __init__(self, parent = None): super().__init__(parent) + self._items = [] self._metadata = None self._discrepancies = None self._sdk_version = ApplicationMetadata.CuraSDKVersion @@ -27,7 +28,7 @@ class SubscribedPackagesModel(ListModel): self._discrepancies = discrepancy def update(self): - items = [] + self._items.clear() for item in self._metadata: if item["package_id"] not in self._discrepancies: @@ -42,5 +43,20 @@ class SubscribedPackagesModel(ListModel): except KeyError: # There is no 'icon_url" in the response payload for this package package.update({"icon_url": ""}) - items.append(package) - self.setItems(items) \ No newline at end of file + self._items.append(package) + self.setItems(self._items) + print(self._items) + + def has_compatible_packages(self): + has_compatible_items = False + for item in self._items: + if item['is_compatible'] == 'True': + has_compatible_items = True + return has_compatible_items + + def has_incompatible_packages(self): + has_incompatible_items = False + for item in self._items: + if item['is_compatible'] == 'False': + has_incompatible_items = True + return has_incompatible_items \ No newline at end of file diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 075774d996..86d03925d0 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -792,6 +792,14 @@ class Toolbox(QObject, Extension): def subscribedPackagesModel(self) -> SubscribedPackagesModel: return cast(SubscribedPackagesModel, self._models["subscribed_packages"]) + @pyqtProperty(bool, constant=True) + def has_compatible_packages(self) -> str: + return self._models["subscribed_packages"].has_compatible_packages() + + @pyqtProperty(bool, constant=True) + def has_incompatible_packages(self) -> str: + return self._models["subscribed_packages"].has_incompatible_packages() + @pyqtProperty(QObject, constant = True) def packagesModel(self) -> PackagesModel: return cast(PackagesModel, self._models["packages"])