Fixed update buttons

Contributes to: CURA-8587
This commit is contained in:
Jelle Spijker 2021-12-09 10:24:26 +01:00
parent 8dc88e52c2
commit 0299bb1694
No known key found for this signature in database
GPG key ID: 6662DC033BE6B99A
3 changed files with 10 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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