MachineSettingsAction.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. anchors.margins: UM.Theme.getSize("default_margin").width
  16. property var extrudersModel: Cura.ExtrudersModel {}
  17. // If we create a TabButton for "Printer" and use Repeater for extruders, for some reason, once the component
  18. // finishes it will automatically change "currentIndex = 1", and it is VERY difficult to change "currentIndex = 0"
  19. // after that. Using a model and a Repeater to create both "Printer" and extruder TabButtons seem to solve this
  20. // problem.
  21. Connections
  22. {
  23. target: extrudersModel
  24. onItemsChanged: tabNameModel.update()
  25. }
  26. ListModel
  27. {
  28. id: tabNameModel
  29. Component.onCompleted: update()
  30. function update()
  31. {
  32. clear()
  33. append({ name: catalog.i18nc("@title:tab", "Printer") })
  34. for (var i = 0; i < extrudersModel.count; i++)
  35. {
  36. const m = extrudersModel.getItem(i)
  37. append({ name: m.name })
  38. }
  39. }
  40. }
  41. Rectangle
  42. {
  43. anchors.fill: parent
  44. border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent"
  45. border.width: UM.Theme.getSize("default_lining").width
  46. radius: UM.Theme.getSize("default_radius").width
  47. UM.TabRow
  48. {
  49. id: tabBar
  50. width: parent.width
  51. Repeater
  52. {
  53. model: tabNameModel
  54. delegate: Cura.TabButton
  55. {
  56. text: model.name
  57. }
  58. }
  59. }
  60. StackLayout
  61. {
  62. id: tabStack
  63. anchors.top: tabBar.bottom
  64. anchors.left: parent.left
  65. anchors.right: parent.right
  66. anchors.bottom: parent.bottom
  67. width: parent.width
  68. currentIndex: tabBar.currentIndex
  69. MachineSettingsPrinterTab
  70. {
  71. id: printerTab
  72. }
  73. Repeater
  74. {
  75. model: extrudersModel
  76. delegate: MachineSettingsExtruderTab
  77. {
  78. id: discoverTab
  79. extruderPosition: model.index
  80. extruderStackId: model.id
  81. }
  82. }
  83. }
  84. }
  85. }