Clean up section property logic

CURA-9424
This commit is contained in:
c.lamboo 2022-11-09 17:11:31 +01:00
parent 79a7b1e064
commit 06a2886139
2 changed files with 33 additions and 20 deletions

View file

@ -130,16 +130,20 @@ class MachineListModel(ListModel):
if len(abstract_machine_stacks) > 0: if len(abstract_machine_stacks) > 0:
if self._show_cloud_printers: if self._show_cloud_printers:
self.appendItem({"componentType": "HIDE_BUTTON", self.appendItem({
"componentType": "HIDE_BUTTON",
"isOnline": True, "isOnline": True,
"isAbstractMachine": False, "isAbstractMachine": False,
"machineCount": 0 "machineCount": 0,
"catergory": "connected",
}) })
else: else:
self.appendItem({"componentType": "SHOW_BUTTON", self.appendItem({
"componentType": "SHOW_BUTTON",
"isOnline": True, "isOnline": True,
"isAbstractMachine": False, "isAbstractMachine": False,
"machineCount": 0 "machineCount": 0,
"catergory": "connected",
}) })
for stack in other_machine_stacks: for stack in other_machine_stacks:
@ -157,4 +161,5 @@ class MachineListModel(ListModel):
"isOnline": is_online, "isOnline": is_online,
"isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)), "isAbstractMachine": parseBool(container_stack.getMetaDataEntry("is_abstract_machine", False)),
"machineCount": machine_count, "machineCount": machine_count,
"catergory": "connected" if is_online else "other",
}) })

View file

@ -10,7 +10,7 @@ import Cura 1.0 as Cura
ListView ListView
{ {
id: listView id: listView
section.property: "isOnline" section.property: "category"
property real contentHeight: childrenRect.height property real contentHeight: childrenRect.height
property var onSelectPrinter property var onSelectPrinter
@ -21,7 +21,15 @@ ListView
section.delegate: UM.Label section.delegate: UM.Label
{ {
text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Other printers") text: {
switch (section)
{
case "connected":
return catalog.i18nc("@label", "Connected printers");
case "other":
return catalog.i18nc("@label", "Other printers");
}
}
height: UM.Theme.getSize("action_button").height height: UM.Theme.getSize("action_button").height
width: parent.width - scrollBar.width width: parent.width - scrollBar.width
leftPadding: UM.Theme.getSize("default_margin").width leftPadding: UM.Theme.getSize("default_margin").width