diff --git a/plugins/Marketplace/LocalPackageList.py b/plugins/Marketplace/LocalPackageList.py index 32e60b2518..72199bd0e4 100644 --- a/plugins/Marketplace/LocalPackageList.py +++ b/plugins/Marketplace/LocalPackageList.py @@ -51,7 +51,7 @@ class LocalPackageList(PackageList): # Obtain and sort the local packages self.setItems([{"package": p} for p in [self._makePackageModel(p) for p in self._manager.local_packages]]) - self.sort(attrgetter("sectionTitle", "can_update", "displayName"), key = "package", reverse = True) + self.sort(attrgetter("sectionTitle", "_can_update", "displayName"), key = "package", reverse = True) self.checkForUpdates(self._manager.local_packages) self.setIsLoading(False) @@ -97,9 +97,9 @@ class LocalPackageList(PackageList): for package_data in response_data["data"]: package = self.getPackageModel(package_data["package_id"]) package.download_url = package_data.get("download_url", "") - package.can_update = True + package.setCanUpdate(True) - self.sort(attrgetter("sectionTitle", "can_update", "displayName"), key = "package", reverse = True) + self.sort(attrgetter("sectionTitle", "_can_update", "displayName"), key = "package", reverse = True) self._ongoing_requests["check_updates"] = None except RuntimeError: # Setting the ownership of this object to not qml can still result in a RuntimeError. Which can occur when quickly toggling diff --git a/plugins/Marketplace/PackageModel.py b/plugins/Marketplace/PackageModel.py index 6d20cd7f91..f4afaf0a68 100644 --- a/plugins/Marketplace/PackageModel.py +++ b/plugins/Marketplace/PackageModel.py @@ -368,13 +368,12 @@ class PackageModel(QObject): def isRecentlyUpdated(self): return self._package_id in self._package_manager.getPackagesToInstall() and self._package_id in self._package_manager.getPackagesToRemove() - @property - def can_update(self) -> bool: - """Flag indicating if the package can be updated""" - return self._can_update - - @can_update.setter - def can_update(self, value: bool) -> None: + def setCanUpdate(self, value: bool) -> None: if value != self._can_update: self._can_update = value self.stateManageButtonChanged.emit() + + @pyqtProperty(bool, fset = setCanUpdate, notify = stateManageButtonChanged) + def canUpdate(self) -> bool: + """Flag indicating if the package can be updated""" + return self._can_update diff --git a/plugins/Marketplace/resources/qml/PackageCardHeader.qml b/plugins/Marketplace/resources/qml/PackageCardHeader.qml index ee7745235f..59a4408ce7 100644 --- a/plugins/Marketplace/resources/qml/PackageCardHeader.qml +++ b/plugins/Marketplace/resources/qml/PackageCardHeader.qml @@ -250,7 +250,7 @@ Item ManageButton { id: updateManageButton - visible: (showManageButtons && confirmed) && !installManageButton.confirmed + visible: (showManageButtons || confirmed) && packageData.canUpdate && !installManageButton.confirmed enabled: !installManageButton.busy busy: packageData.isUpdating