TestContent.qml 2.7 KB

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