Use list model to display show hide buttons

CURA-9514
This commit is contained in:
c.lamboo 2022-08-31 07:58:05 +02:00
parent ac732e9604
commit 60b12b9247
3 changed files with 156 additions and 107 deletions

View file

@ -19,53 +19,35 @@ ListView
id: scrollBar
}
section.delegate: Item
section.delegate: UM.Label
{
text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Other printers")
height: UM.Theme.getSize("action_button").height
width: parent.width - scrollBar.width
height: childrenRect.height
UM.Label
{
visible: section == "true"
text: catalog.i18nc("@label", "Connected printers")
height: UM.Theme.getSize("action_button").height
leftPadding: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
}
Column
{
visible: section != "true"
height: childrenRect.height
Cura.TertiaryButton
{
text: listView.model.showCloudPrinters ? catalog.i18nc("@label", "Hide all connected printers") : catalog.i18nc("@label", "Show all connected printers")
onClicked: listView.model.setShowCloudPrinters(!listView.model.showCloudPrinters)
iconSource: listView.model.showCloudPrinters ? UM.Theme.getIcon("ChevronSingleUp") : UM.Theme.getIcon("ChevronSingleDown")
}
UM.Label
{
text: catalog.i18nc("@label", "Other printers")
height: UM.Theme.getSize("action_button").height
leftPadding: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
}
}
leftPadding: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
}
delegate: MachineListButton
{
text: model.name ? model.name : ""
width: listView.width - scrollBar.width
onClicked:
onClicked: function()
{
toggleContent()
Cura.MachineManager.setActiveMachine(model.id)
switch (model.listType) {
case "HIDE_BUTTON":
listView.model.setShowCloudPrinters(false);
break;
case "SHOW_BUTTON":
listView.model.setShowCloudPrinters(true);
break;
case "MACHINE":
toggleContent()
Cura.MachineManager.setActiveMachine(model.id)
break;
default:
}
}
}
}