MachineSettingsAction.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import QtQuick.Layouts 1.3
  6. import UM 1.3 as UM
  7. import Cura 1.1 as Cura
  8. //
  9. // This component contains the content for the "Welcome" page of the welcome on-boarding process.
  10. //
  11. Cura.MachineAction
  12. {
  13. UM.I18nCatalog { id: catalog; name: "cura" }
  14. anchors.fill: parent
  15. property var extrudersModel: Cura.ExtrudersModel {}
  16. // If we create a TabButton for "Printer" and use Repeater for extruders, for some reason, once the component
  17. // finishes it will automatically change "currentIndex = 1", and it is VERY difficult to change "currentIndex = 0"
  18. // after that. Using a model and a Repeater to create both "Printer" and extruder TabButtons seem to solve this
  19. // problem.
  20. Connections
  21. {
  22. target: extrudersModel
  23. function onItemsChanged() { tabNameModel.update() }
  24. }
  25. ListModel
  26. {
  27. id: tabNameModel
  28. Component.onCompleted: update()
  29. function update()
  30. {
  31. clear()
  32. append({ name: catalog.i18nc("@title:tab", "Printer") })
  33. for (var i = 0; i < extrudersModel.count; i++)
  34. {
  35. const m = extrudersModel.getItem(i)
  36. append({ name: m.name })
  37. }
  38. }
  39. }
  40. Cura.RoundedRectangle
  41. {
  42. anchors
  43. {
  44. top: tabBar.bottom
  45. topMargin: -UM.Theme.getSize("default_lining").height
  46. bottom: parent.bottom
  47. left: parent.left
  48. right: parent.right
  49. }
  50. cornerSide: Cura.RoundedRectangle.Direction.Down
  51. border.color: UM.Theme.getColor("lining")
  52. border.width: UM.Theme.getSize("default_lining").width
  53. radius: UM.Theme.getSize("default_radius").width
  54. color: UM.Theme.getColor("main_background")
  55. StackLayout
  56. {
  57. id: tabStack
  58. anchors.fill: parent
  59. currentIndex: tabBar.currentIndex
  60. MachineSettingsPrinterTab
  61. {
  62. id: printerTab
  63. }
  64. Repeater
  65. {
  66. model: extrudersModel
  67. delegate: MachineSettingsExtruderTab
  68. {
  69. id: discoverTab
  70. extruderPosition: model.index
  71. extruderStackId: model.id
  72. }
  73. }
  74. }
  75. }
  76. Label
  77. {
  78. id: machineNameLabel
  79. anchors.top: parent.top
  80. anchors.left: parent.left
  81. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  82. text: Cura.MachineManager.activeMachine.name
  83. horizontalAlignment: Text.AlignHCenter
  84. font: UM.Theme.getFont("large_bold")
  85. renderType: Text.NativeRendering
  86. }
  87. UM.TabRow
  88. {
  89. id: tabBar
  90. anchors.top: machineNameLabel.bottom
  91. anchors.topMargin: UM.Theme.getSize("default_margin").height
  92. width: parent.width
  93. Repeater
  94. {
  95. model: tabNameModel
  96. delegate: UM.TabRowButton
  97. {
  98. text: model.name
  99. }
  100. }
  101. }
  102. }