MachineSettingsAction.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. 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. UM.TabRow
  77. {
  78. id: tabBar
  79. width: parent.width
  80. Repeater
  81. {
  82. model: tabNameModel
  83. delegate: UM.TabRowButton
  84. {
  85. text: model.name
  86. }
  87. }
  88. }
  89. }