mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Don't show download count for bundled plug-ins
I considered rewriting the section title property to be QML-only and translate it from the QML, but this is a bit simpler in the end, even though there is data duplication now. Contributes to issue CURA-8565.
This commit is contained in:
parent
7eca005659
commit
7529483cb0
4 changed files with 12 additions and 3 deletions
|
@ -90,4 +90,4 @@ class LocalPackageList(PackageList):
|
||||||
bundled_or_installed = "installed" if self._manager.isUserInstalledPackage(package_info["package_id"]) else "bundled"
|
bundled_or_installed = "installed" if self._manager.isUserInstalledPackage(package_info["package_id"]) else "bundled"
|
||||||
package_type = package_info["package_type"]
|
package_type = package_info["package_type"]
|
||||||
section_title = self.PACKAGE_SECTION_HEADER[bundled_or_installed][package_type]
|
section_title = self.PACKAGE_SECTION_HEADER[bundled_or_installed][package_type]
|
||||||
return PackageModel(package_info, section_title = section_title, parent = self)
|
return PackageModel(package_info, installation_status = bundled_or_installed, section_title = section_title, parent = self)
|
||||||
|
|
|
@ -17,10 +17,11 @@ class PackageModel(QObject):
|
||||||
QML. The model can also be constructed directly from a response received by the API.
|
QML. The model can also be constructed directly from a response received by the API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, package_data: Dict[str, Any], section_title: Optional[str] = None, parent: Optional[QObject] = None) -> None:
|
def __init__(self, package_data: Dict[str, Any], installation_status: str, section_title: Optional[str] = None, parent: Optional[QObject] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Constructs a new model for a single package.
|
Constructs a new model for a single package.
|
||||||
:param package_data: The data received from the Marketplace API about the package to create.
|
:param package_data: The data received from the Marketplace API about the package to create.
|
||||||
|
:param installation_status: Whether the package is `not_installed`, `installed` or `bundled`.
|
||||||
:param section_title: If the packages are to be categorized per section provide the section_title
|
:param section_title: If the packages are to be categorized per section provide the section_title
|
||||||
:param parent: The parent QML object that controls the lifetime of this model (normally a PackageList).
|
:param parent: The parent QML object that controls the lifetime of this model (normally a PackageList).
|
||||||
"""
|
"""
|
||||||
|
@ -46,6 +47,7 @@ class PackageModel(QObject):
|
||||||
if not self._icon_url or self._icon_url == "":
|
if not self._icon_url or self._icon_url == "":
|
||||||
self._icon_url = author_data.get("icon_url", "")
|
self._icon_url = author_data.get("icon_url", "")
|
||||||
|
|
||||||
|
self._installation_status = installation_status
|
||||||
self._section_title = section_title
|
self._section_title = section_title
|
||||||
# Note that there's a lot more info in the package_data than just these specified here.
|
# Note that there's a lot more info in the package_data than just these specified here.
|
||||||
|
|
||||||
|
@ -108,6 +110,10 @@ class PackageModel(QObject):
|
||||||
def authorInfoUrl(self):
|
def authorInfoUrl(self):
|
||||||
return self._author_info_url
|
return self._author_info_url
|
||||||
|
|
||||||
|
@pyqtProperty(str, constant = True)
|
||||||
|
def installationStatus(self) -> str:
|
||||||
|
return self._installation_status
|
||||||
|
|
||||||
@pyqtProperty(str, constant = True)
|
@pyqtProperty(str, constant = True)
|
||||||
def sectionTitle(self) -> Optional[str]:
|
def sectionTitle(self) -> Optional[str]:
|
||||||
return self._section_title
|
return self._section_title
|
||||||
|
|
|
@ -134,8 +134,9 @@ class RemotePackageList(PackageList):
|
||||||
return
|
return
|
||||||
|
|
||||||
for package_data in response_data["data"]:
|
for package_data in response_data["data"]:
|
||||||
|
installation_status = "installed" if CuraApplication.getInstance().getPackageManager().isUserInstalledPackage(package_data["package_id"]) else "not_installed"
|
||||||
try:
|
try:
|
||||||
package = PackageModel(package_data, parent = self)
|
package = PackageModel(package_data, installation_status, parent = self)
|
||||||
self.appendItem({"package": package}) # Add it to this list model.
|
self.appendItem({"package": package}) # Add it to this list model.
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
# Setting the ownership of this object to not qml can still result in a RuntimeError. Which can occur when quickly toggling
|
# Setting the ownership of this object to not qml can still result in a RuntimeError. Which can occur when quickly toggling
|
||||||
|
|
|
@ -303,6 +303,7 @@ Rectangle
|
||||||
width: UM.Theme.getSize("card_tiny_icon").width
|
width: UM.Theme.getSize("card_tiny_icon").width
|
||||||
height: UM.Theme.getSize("card_tiny_icon").height
|
height: UM.Theme.getSize("card_tiny_icon").height
|
||||||
|
|
||||||
|
visible: packageData.installationStatus !== "bundled" //Don't show download count for packages that are bundled. It'll usually be 0.
|
||||||
source: UM.Theme.getIcon("Download")
|
source: UM.Theme.getIcon("Download")
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
}
|
}
|
||||||
|
@ -311,6 +312,7 @@ Rectangle
|
||||||
{
|
{
|
||||||
anchors.verticalCenter: downloadsIcon.verticalCenter
|
anchors.verticalCenter: downloadsIcon.verticalCenter
|
||||||
|
|
||||||
|
visible: packageData.installationStatus !== "bundled" //Don't show download count for packages that are bundled. It'll usually be 0.
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
text: packageData.downloadCount
|
text: packageData.downloadCount
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue