Check the server if a package can be updated

The server is queried using the local packages_id and version to
determine if they can be updated. The Manage button state is set
accordingly. This is done in an async way to keep the UI responsive

A.t.m I'm not sure if I might need to move this logic out, since
we also need to make this query when check periodically for updates.
when the list is not shown. But that would also entail creating
the installed packages list before the Manage Packages tab is ever
created in the Marketplace.

Contributes to: CURA-8587
This commit is contained in:
Jelle Spijker 2021-11-30 15:40:18 +01:00
parent eb156f114c
commit 6514fdf9f2
No known key found for this signature in database
GPG key ID: 6662DC033BE6B99A
4 changed files with 42 additions and 8 deletions

View file

@ -6,6 +6,11 @@ from typing import Optional, TYPE_CHECKING
from UM.i18n import i18nCatalog
from UM.Qt.ListModel import ListModel
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope # To request JSON responses from the API.
from UM.TaskManagement.HttpRequestManager import HttpRequestData # To request the package list from the API.
from cura.CuraApplication import CuraApplication
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization.
if TYPE_CHECKING:
from PyQt5.QtCore import QObject
@ -27,6 +32,9 @@ class PackageList(ListModel):
self._has_more = False
self._has_footer = True
self._ongoing_request: Optional[HttpRequestData] = None
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
@pyqtSlot()
def updatePackages(self) -> None:
""" A Qt slot which will update the List from a source. Actual implementation should be done in the child class"""