CustomPrintSetup.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.0
  5. import UM 1.3 as UM
  6. import Cura 1.0 as Cura
  7. Item
  8. {
  9. id: customPrintSetup
  10. // TODO: Hardcoded now but UX has to decide about the height of this item
  11. height: 480
  12. property real padding: UM.Theme.getSize("default_margin").width
  13. property bool multipleExtruders: extrudersModel.count > 1
  14. Cura.ExtrudersModel
  15. {
  16. id: extrudersModel
  17. }
  18. // Profile selector row
  19. GlobalProfileSelector
  20. {
  21. id: globalProfileRow
  22. anchors
  23. {
  24. top: parent.top
  25. topMargin: parent.padding
  26. left: parent.left
  27. leftMargin: parent.padding
  28. right: parent.right
  29. rightMargin: parent.padding
  30. }
  31. }
  32. UM.TabRow
  33. {
  34. id: tabBar
  35. visible: multipleExtruders // The tab row is only visible when there are more than 1 extruder
  36. anchors
  37. {
  38. top: globalProfileRow.bottom
  39. topMargin: UM.Theme.getSize("default_margin").height
  40. left: parent.left
  41. leftMargin: parent.padding
  42. right: parent.right
  43. rightMargin: parent.padding
  44. }
  45. currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0)
  46. Repeater
  47. {
  48. id: repeater
  49. model: extrudersModel
  50. delegate: UM.TabRowButton
  51. {
  52. contentItem: Item
  53. {
  54. Cura.ExtruderIcon
  55. {
  56. anchors.horizontalCenter: parent.horizontalCenter
  57. materialColor: model.color
  58. extruderEnabled: model.enabled
  59. }
  60. }
  61. onClicked:
  62. {
  63. Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex)
  64. }
  65. }
  66. }
  67. // When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
  68. // This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
  69. // Therefore we need to change it back to what it was: The active extruder index.
  70. Connections
  71. {
  72. target: repeater.model
  73. onModelChanged:
  74. {
  75. tabBar.currentIndex = Math.max(Cura.ExtruderManager.activeExtruderIndex, 0)
  76. }
  77. }
  78. }
  79. Rectangle
  80. {
  81. anchors
  82. {
  83. top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom
  84. left: parent.left
  85. leftMargin: parent.padding
  86. right: parent.right
  87. rightMargin: parent.padding
  88. bottom: parent.bottom
  89. topMargin: -UM.Theme.getSize("default_lining").width
  90. bottomMargin: -UM.Theme.getSize("default_lining").width
  91. }
  92. z: tabBar.z - 1
  93. // Don't show the border when only one extruder
  94. border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent"
  95. border.width: UM.Theme.getSize("default_lining").width
  96. Cura.SettingView
  97. {
  98. anchors
  99. {
  100. fill: parent
  101. topMargin: UM.Theme.getSize("default_margin").height
  102. leftMargin: UM.Theme.getSize("default_margin").width
  103. // Small space for the scrollbar
  104. rightMargin: UM.Theme.getSize("narrow_margin").width
  105. // Compensate for the negative margin in the parent
  106. bottomMargin: UM.Theme.getSize("default_lining").width
  107. }
  108. }
  109. }
  110. }