CustomPrintSetup.qml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. //Copyright (c) 2022 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.5 as UM
  7. import Cura 1.6 as Cura
  8. import ".."
  9. Item
  10. {
  11. id: customPrintSetup
  12. property real padding: UM.Theme.getSize("default_margin").width
  13. property bool multipleExtruders: extrudersModel.count > 1
  14. property var extrudersModel: CuraApplication.getExtrudersModel()
  15. Item
  16. {
  17. id: intent
  18. height: childrenRect.height
  19. anchors
  20. {
  21. top: parent.top
  22. topMargin: UM.Theme.getSize("default_margin").height
  23. left: parent.left
  24. leftMargin: parent.padding
  25. right: parent.right
  26. rightMargin: parent.padding
  27. }
  28. UM.Label
  29. {
  30. id: profileLabel
  31. anchors
  32. {
  33. top: parent.top
  34. bottom: parent.bottom
  35. left: parent.left
  36. right: intentSelection.left
  37. }
  38. text: catalog.i18nc("@label", "Profile")
  39. font: UM.Theme.getFont("medium")
  40. }
  41. NoIntentIcon
  42. {
  43. affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
  44. intent_type: Cura.MachineManager.activeIntentCategory
  45. anchors.right: intentSelection.left
  46. anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
  47. width: Math.round(profileLabel.height * 0.5)
  48. anchors.verticalCenter: parent.verticalCenter
  49. height: width
  50. visible: affected_extruders.length
  51. }
  52. Button
  53. {
  54. id: intentSelection
  55. onClicked: menu.opened ? menu.close() : menu.open()
  56. anchors.right: parent.right
  57. width: UM.Theme.getSize("print_setup_big_item").width
  58. height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height
  59. hoverEnabled: true
  60. contentItem: RowLayout
  61. {
  62. spacing: 0
  63. anchors.left: parent.left
  64. anchors.right: customisedSettings.left
  65. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  66. UM.Label
  67. {
  68. id: textLabel
  69. text: Cura.MachineManager.activeQualityDisplayNameMap["main"]
  70. Layout.margins: 0
  71. Layout.maximumWidth: Math.floor(parent.width * 0.7) // Always leave >= 30% for the rest of the row.
  72. height: contentHeight
  73. elide: Text.ElideRight
  74. wrapMode: Text.NoWrap
  75. }
  76. UM.Label
  77. {
  78. text: activeQualityDetailText()
  79. color: UM.Theme.getColor("text_detail")
  80. Layout.margins: 0
  81. Layout.fillWidth: true
  82. height: contentHeight
  83. elide: Text.ElideRight
  84. wrapMode: Text.NoWrap
  85. function activeQualityDetailText()
  86. {
  87. var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
  88. var resultSuffix = resultMap["suffix"]
  89. var result = ""
  90. if (Cura.MachineManager.isActiveQualityExperimental)
  91. {
  92. resultSuffix += " (Experimental)"
  93. }
  94. if (Cura.MachineManager.isActiveQualitySupported)
  95. {
  96. if (Cura.MachineManager.activeQualityLayerHeight > 0)
  97. {
  98. if (resultSuffix)
  99. {
  100. result += " - " + resultSuffix
  101. }
  102. result += " - "
  103. result += Cura.MachineManager.activeQualityLayerHeight + "mm"
  104. }
  105. }
  106. return result
  107. }
  108. }
  109. }
  110. background: UM.UnderlineBackground
  111. {
  112. id: backgroundItem
  113. borderColor: intentSelection.hovered ? UM.Theme.getColor("text_field_border_hovered") : "transparent"
  114. liningColor: intentSelection.hovered ? UM.Theme.getColor("text_field_border_hovered") : UM.Theme.getColor("border_field_light")
  115. }
  116. UM.SimpleButton
  117. {
  118. id: customisedSettings
  119. visible: Cura.MachineManager.hasUserSettings
  120. width: UM.Theme.getSize("print_setup_icon").width
  121. height: UM.Theme.getSize("print_setup_icon").height
  122. anchors.verticalCenter: parent.verticalCenter
  123. anchors.right: downArrow.left
  124. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  125. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  126. iconSource: UM.Theme.getIcon("StarFilled")
  127. onClicked:
  128. {
  129. forceActiveFocus();
  130. Cura.Actions.manageProfiles.trigger()
  131. }
  132. onEntered:
  133. {
  134. var content = catalog.i18nc("@tooltip", "Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.")
  135. base.showTooltip(intent, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content)
  136. }
  137. onExited: base.hideTooltip()
  138. }
  139. UM.ColorImage
  140. {
  141. id: downArrow
  142. source: UM.Theme.getIcon("ChevronSingleDown")
  143. width: UM.Theme.getSize("standard_arrow").width
  144. height: UM.Theme.getSize("standard_arrow").height
  145. anchors
  146. {
  147. right: parent.right
  148. verticalCenter: parent.verticalCenter
  149. rightMargin: UM.Theme.getSize("default_margin").width
  150. }
  151. color: UM.Theme.getColor("setting_control_button")
  152. }
  153. }
  154. QualitiesWithIntentMenu
  155. {
  156. id: menu
  157. y: intentSelection.y + intentSelection.height
  158. x: intentSelection.x
  159. width: intentSelection.width
  160. }
  161. }
  162. UM.TabRow
  163. {
  164. id: tabBar
  165. visible: multipleExtruders // The tab row is only visible when there are more than 1 extruder
  166. anchors
  167. {
  168. top: intent.bottom
  169. topMargin: UM.Theme.getSize("default_margin").height
  170. left: parent.left
  171. leftMargin: parent.padding
  172. right: parent.right
  173. rightMargin: parent.padding
  174. }
  175. Repeater
  176. {
  177. id: repeater
  178. model: extrudersModel
  179. delegate: UM.TabRowButton
  180. {
  181. checked: model.index == 0
  182. contentItem: Item
  183. {
  184. Cura.ExtruderIcon
  185. {
  186. anchors.centerIn: parent
  187. materialColor: model.color
  188. extruderEnabled: model.enabled
  189. iconVariant: "default"
  190. }
  191. }
  192. onClicked:
  193. {
  194. Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex)
  195. }
  196. }
  197. }
  198. //When active extruder changes for some other reason, switch tabs.
  199. //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex!
  200. //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead.
  201. Connections
  202. {
  203. target: Cura.ExtruderManager
  204. function onActiveExtruderChanged()
  205. {
  206. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex);
  207. }
  208. }
  209. //When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
  210. //This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
  211. //Therefore we need to change it back to what it was: The active extruder index.
  212. Connections
  213. {
  214. target: repeater.model
  215. function onModelChanged()
  216. {
  217. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex)
  218. }
  219. }
  220. }
  221. Rectangle
  222. {
  223. anchors
  224. {
  225. top: tabBar.visible ? tabBar.bottom : intent.bottom
  226. topMargin: -UM.Theme.getSize("default_lining").width
  227. left: parent.left
  228. leftMargin: parent.padding
  229. right: parent.right
  230. rightMargin: parent.padding
  231. bottom: parent.bottom
  232. }
  233. z: tabBar.z - 1
  234. // Don't show the border when only one extruder
  235. border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent"
  236. border.width: UM.Theme.getSize("default_lining").width
  237. color: UM.Theme.getColor("main_background")
  238. Cura.SettingView
  239. {
  240. anchors
  241. {
  242. fill: parent
  243. topMargin: UM.Theme.getSize("default_margin").height
  244. leftMargin: UM.Theme.getSize("default_margin").width
  245. // Small space for the scrollbar
  246. rightMargin: UM.Theme.getSize("narrow_margin").width
  247. // Compensate for the negative margin in the parent
  248. bottomMargin: UM.Theme.getSize("default_lining").width
  249. }
  250. }
  251. }
  252. }