CustomPrintSetup.qml 10 KB

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