mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Merge branch 'CURA-7038_remove_labels_if_no_packages' of github.com:Ultimaker/Cura
This commit is contained in:
commit
f15e0c5477
3 changed files with 34 additions and 9 deletions
|
@ -48,6 +48,7 @@ UM.Dialog{
|
||||||
{
|
{
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
text: catalog.i18nc("@label", "The following packages will be added:")
|
text: catalog.i18nc("@label", "The following packages will be added:")
|
||||||
|
visible: toolbox.has_compatible_packages
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
height: contentHeight + UM.Theme.getSize("default_margin").height
|
height: contentHeight + UM.Theme.getSize("default_margin").height
|
||||||
}
|
}
|
||||||
|
@ -59,8 +60,8 @@ UM.Dialog{
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
property var lineHeight: 60
|
property int lineHeight: 60
|
||||||
visible: model.is_compatible == "True" ? true : false
|
visible: model.is_compatible
|
||||||
height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the compatible packages here
|
height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the compatible packages here
|
||||||
Image
|
Image
|
||||||
{
|
{
|
||||||
|
@ -90,6 +91,7 @@ UM.Dialog{
|
||||||
{
|
{
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
text: catalog.i18nc("@label", "The following packages can not be installed because of incompatible Cura version:")
|
text: catalog.i18nc("@label", "The following packages can not be installed because of incompatible Cura version:")
|
||||||
|
visible: toolbox.has_incompatible_packages
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
height: contentHeight + UM.Theme.getSize("default_margin").height
|
height: contentHeight + UM.Theme.getSize("default_margin").height
|
||||||
}
|
}
|
||||||
|
@ -101,8 +103,8 @@ UM.Dialog{
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
property var lineHeight: 60
|
property int lineHeight: 60
|
||||||
visible: model.is_compatible == "True" ? false : true
|
visible: !model.is_compatible
|
||||||
height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the incompatible packages here
|
height: visible ? (lineHeight + UM.Theme.getSize("default_margin").height) : 0 // We only show the incompatible packages here
|
||||||
Image
|
Image
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@ class SubscribedPackagesModel(ListModel):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self._items = []
|
||||||
self._metadata = None
|
self._metadata = None
|
||||||
self._discrepancies = None
|
self._discrepancies = None
|
||||||
self._sdk_version = ApplicationMetadata.CuraSDKVersion
|
self._sdk_version = ApplicationMetadata.CuraSDKVersion
|
||||||
|
@ -27,20 +28,34 @@ class SubscribedPackagesModel(ListModel):
|
||||||
self._discrepancies = discrepancy
|
self._discrepancies = discrepancy
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
items = []
|
self._items.clear()
|
||||||
|
|
||||||
for item in self._metadata:
|
for item in self._metadata:
|
||||||
if item["package_id"] not in self._discrepancies:
|
if item["package_id"] not in self._discrepancies:
|
||||||
continue
|
continue
|
||||||
package = {"name": item["display_name"], "sdk_versions": item["sdk_versions"]}
|
package = {"name": item["display_name"], "sdk_versions": item["sdk_versions"]}
|
||||||
if self._sdk_version not in item["sdk_versions"]:
|
if self._sdk_version not in item["sdk_versions"]:
|
||||||
package.update({"is_compatible": "False"})
|
package.update({"is_compatible": False})
|
||||||
else:
|
else:
|
||||||
package.update({"is_compatible": "True"})
|
package.update({"is_compatible": True})
|
||||||
try:
|
try:
|
||||||
package.update({"icon_url": item["icon_url"]})
|
package.update({"icon_url": item["icon_url"]})
|
||||||
except KeyError: # There is no 'icon_url" in the response payload for this package
|
except KeyError: # There is no 'icon_url" in the response payload for this package
|
||||||
package.update({"icon_url": ""})
|
package.update({"icon_url": ""})
|
||||||
|
|
||||||
items.append(package)
|
self._items.append(package)
|
||||||
self.setItems(items)
|
self.setItems(self._items)
|
||||||
|
|
||||||
|
def hasCompatiblePackages(self):
|
||||||
|
has_compatible_items = False
|
||||||
|
for item in self._items:
|
||||||
|
if item['is_compatible'] == True:
|
||||||
|
has_compatible_items = True
|
||||||
|
return has_compatible_items
|
||||||
|
|
||||||
|
def hasIncompatiblePackages(self):
|
||||||
|
has_incompatible_items = False
|
||||||
|
for item in self._items:
|
||||||
|
if item['is_compatible'] == False:
|
||||||
|
has_incompatible_items = True
|
||||||
|
return has_incompatible_items
|
|
@ -796,6 +796,14 @@ class Toolbox(QObject, Extension):
|
||||||
def subscribedPackagesModel(self) -> SubscribedPackagesModel:
|
def subscribedPackagesModel(self) -> SubscribedPackagesModel:
|
||||||
return cast(SubscribedPackagesModel, self._models["subscribed_packages"])
|
return cast(SubscribedPackagesModel, self._models["subscribed_packages"])
|
||||||
|
|
||||||
|
@pyqtProperty(bool, constant=True)
|
||||||
|
def has_compatible_packages(self) -> str:
|
||||||
|
return self._models["subscribed_packages"].hasCompatiblePackages()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, constant=True)
|
||||||
|
def has_incompatible_packages(self) -> str:
|
||||||
|
return self._models["subscribed_packages"].hasIncompatiblePackages()
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(QObject, constant = True)
|
||||||
def packagesModel(self) -> PackagesModel:
|
def packagesModel(self) -> PackagesModel:
|
||||||
return cast(PackagesModel, self._models["packages"])
|
return cast(PackagesModel, self._models["packages"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue