MachineSelectorList.qml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. section.property: "category"
  11. property real contentHeight: childrenRect.height
  12. property var onSelectPrinter
  13. ScrollBar.vertical: UM.ScrollBar
  14. {
  15. id: scrollBar
  16. }
  17. section.delegate: UM.Label
  18. {
  19. text: {
  20. switch (section)
  21. {
  22. case "connected":
  23. return catalog.i18nc("@label", "Connected printers");
  24. case "other":
  25. return catalog.i18nc("@label", "Other printers");
  26. default:
  27. return catalog.i18nc("@label", "Other printers");
  28. }
  29. }
  30. height: UM.Theme.getSize("action_button").height
  31. width: parent.width - scrollBar.width
  32. leftPadding: UM.Theme.getSize("default_margin").width
  33. font: UM.Theme.getFont("medium")
  34. color: UM.Theme.getColor("text_medium")
  35. }
  36. delegate: MachineListButton
  37. {
  38. width: listView.width - scrollBar.width
  39. onClicked: function()
  40. {
  41. switch (model.componentType) {
  42. case "HIDE_BUTTON":
  43. listView.model.setShowCloudPrinters(false);
  44. break;
  45. case "SHOW_BUTTON":
  46. listView.model.setShowCloudPrinters(true);
  47. break;
  48. case "MACHINE":
  49. if (typeof onSelectPrinter === "function") onSelectPrinter(model);
  50. break;
  51. default:
  52. }
  53. }
  54. }
  55. }