MachineSelectorList.qml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.MachineListModel {}
  11. section.property: "isOnline"
  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", "Other printers")
  20. height: UM.Theme.getSize("action_button").height
  21. width: parent.width - scrollBar.width
  22. leftPadding: UM.Theme.getSize("default_margin").width
  23. font: UM.Theme.getFont("medium")
  24. color: UM.Theme.getColor("text_medium")
  25. }
  26. delegate: MachineListButton
  27. {
  28. width: listView.width - scrollBar.width
  29. onClicked: function()
  30. {
  31. switch (model.componentType) {
  32. case "HIDE_BUTTON":
  33. listView.model.setShowCloudPrinters(false);
  34. break;
  35. case "SHOW_BUTTON":
  36. listView.model.setShowCloudPrinters(true);
  37. break;
  38. case "MACHINE":
  39. toggleContent()
  40. Cura.MachineManager.setActiveMachine(model.id)
  41. break;
  42. default:
  43. }
  44. }
  45. }
  46. }