MachineSelectorList.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.3
  5. import UM 1.5 as UM
  6. import Cura 1.0 as Cura
  7. ListView
  8. {
  9. id: listView
  10. model: Cura.GlobalStacksModel {}
  11. section.property: "hasRemoteConnection"
  12. property real contentHeight: childrenRect.height
  13. ScrollBar.vertical: UM.ScrollBar
  14. {
  15. id: scrollBar
  16. }
  17. section.delegate: UM.Label
  18. {
  19. text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Preset printers")
  20. width: parent.width - scrollBar.width
  21. height: UM.Theme.getSize("action_button").height
  22. leftPadding: UM.Theme.getSize("default_margin").width
  23. font: UM.Theme.getFont("medium")
  24. color: UM.Theme.getColor("text_medium")
  25. }
  26. delegate: MachineSelectorButton
  27. {
  28. text: model.name ? model.name : ""
  29. width: listView.width - scrollBar.width
  30. outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
  31. checked: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.id == model.id : false
  32. onClicked:
  33. {
  34. toggleContent()
  35. Cura.MachineManager.setActiveMachine(model.id)
  36. }
  37. }
  38. }