Cura/resources/qml/PrinterSelector/MachineSelectorList.qml
c.lamboo dd4e1c66b7 Make MachineSelector more generic by detaching logic from view
By detaching the logic from the view custom handlers can be added to selecting printers. This was needed as the MachineSelector in the `WorkspaceDialog` needed to do something different from the `PreparMenu`.

CURA-9424
2022-11-09 14:16:33 +01:00

53 lines
1.4 KiB
QML

// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.3
import UM 1.5 as UM
import Cura 1.0 as Cura
ListView
{
id: listView
section.property: "isOnline"
property real contentHeight: childrenRect.height
property var onSelectPrinter
ScrollBar.vertical: UM.ScrollBar
{
id: scrollBar
}
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
leftPadding: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("text_medium")
}
delegate: MachineListButton
{
width: listView.width - scrollBar.width
onClicked: function()
{
switch (model.componentType) {
case "HIDE_BUTTON":
listView.model.setShowCloudPrinters(false);
break;
case "SHOW_BUTTON":
listView.model.setShowCloudPrinters(true);
break;
case "MACHINE":
if (typeof onSelectPrinter === "function") onSelectPrinter(model);
break;
default:
}
}
}
}