Gather and show required information.

Also add 'Downalod' icon. Still very much WIP and nonfunctional.

part of CURA-8561
This commit is contained in:
Remco Burema 2021-11-05 18:44:31 +01:00
parent e93ecd3699
commit bb51dc7d14
No known key found for this signature in database
GPG key ID: 215C49431D43F98C
3 changed files with 361 additions and 9 deletions

View file

@ -4,10 +4,12 @@
from PyQt5.QtCore import pyqtProperty, QObject
from typing import Any, Dict, Optional
from UM.i18n import i18nCatalog # To translate placeholder names if data is not present.
from UM.Util import parseBool
from UM.i18n import i18nCatalog # To translate placeholder names if data is not present.
catalog = i18nCatalog("cura")
class PackageModel(QObject):
"""
Represents a package, containing all the relevant information to be displayed about a package.
@ -25,17 +27,65 @@ class PackageModel(QObject):
"""
super().__init__(parent)
self._package_id = package_data.get("package_id", "UnknownPackageId")
self._icon_url = package_data.get("icon_url", "")
self._display_name = package_data.get("display_name", catalog.i18nc("@label:property", "Unknown Package"))
self._is_verified = "verified" in package_data.get("tags", [])
self._package_version = package_data.get("package_version", "") # Display purpose, no need for 'UM.Version'.
self._package_info_url = package_data.get("website", "") # Not to be confused with 'download_url'.
self._download_count = package_data.get("download_count", 0)
self._description = package_data.get("description", "")
self._download_url = package_data.get("download_url", "") # Not used yet, will be.
self._release_notes = package_data.get("release_notes", "") # Not used yet, propose to add to description?
author_data = package_data.get("author", {})
self._author_name = author_data.get("display_name", catalog.i18nc("@label:property", "Unknown Author"))
self._author_info_url = author_data.get("website", "")
self._section_title = section_title
# Note that there's a lot more info in the package_data than just these specified here.
@pyqtProperty(str, constant = True)
def packageId(self) -> str:
return self._package_id
@pyqtProperty(str, constant=True)
def iconUrl(self):
return self._icon_url
@pyqtProperty(str, constant = True)
def displayName(self) -> str:
return self._display_name
@pyqtProperty(bool, constant=True)
def isVerified(self):
return self._is_verified
@pyqtProperty(str, constant=True)
def packageVersion(self):
return self._package_version
@pyqtProperty(str, constant=True)
def packageInfoUrl(self):
return self._package_info_url
@pyqtProperty(int, constant=True)
def downloadCount(self):
return self._download_count
@pyqtProperty(str, constant=True)
def description(self):
return self._description
@pyqtProperty(str, constant=True)
def authorName(self):
return self._author_name
@pyqtProperty(str, constant=True)
def authorInfoUrl(self):
return self._author_info_url
@pyqtProperty(str, constant = True)
def sectionTitle(self) -> Optional[str]:
return self._section_title