CustomPrintSetup.qml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 1.4 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. baselineOffset: null // If we don't do this, there is a binding loop. WHich is a bit weird, since we override the contentItem anyway...
  65. contentItem: RowLayout
  66. {
  67. spacing: 0
  68. anchors.left: parent.left
  69. anchors.right: customisedSettings.left
  70. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  71. Label
  72. {
  73. id: textLabel
  74. text: Cura.MachineManager.activeQualityDisplayNameMap["main"]
  75. font: UM.Theme.getFont("default")
  76. color: UM.Theme.getColor("text")
  77. Layout.margins: 0
  78. Layout.maximumWidth: Math.floor(parent.width * 0.7) // Always leave >= 30% for the rest of the row.
  79. height: contentHeight
  80. verticalAlignment: Text.AlignVCenter
  81. renderType: Text.NativeRendering
  82. elide: Text.ElideRight
  83. }
  84. Label
  85. {
  86. text: activeQualityDetailText()
  87. font: UM.Theme.getFont("default")
  88. color: UM.Theme.getColor("text_detail")
  89. Layout.margins: 0
  90. Layout.fillWidth: true
  91. height: contentHeight
  92. verticalAlignment: Text.AlignVCenter
  93. renderType: Text.NativeRendering
  94. elide: Text.ElideRight
  95. function activeQualityDetailText()
  96. {
  97. var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
  98. var resultSuffix = resultMap["suffix"]
  99. var result = ""
  100. if (Cura.MachineManager.isActiveQualityExperimental)
  101. {
  102. resultSuffix += " (Experimental)"
  103. }
  104. if (Cura.MachineManager.isActiveQualitySupported)
  105. {
  106. if (Cura.MachineManager.activeQualityLayerHeight > 0)
  107. {
  108. if (resultSuffix)
  109. {
  110. result += " - " + resultSuffix
  111. }
  112. result += " - "
  113. result += Cura.MachineManager.activeQualityLayerHeight + "mm"
  114. }
  115. }
  116. return result
  117. }
  118. }
  119. }
  120. background: Rectangle
  121. {
  122. id: backgroundItem
  123. border.color: intentSelection.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
  124. border.width: UM.Theme.getSize("default_lining").width
  125. radius: UM.Theme.getSize("default_radius").width
  126. color: UM.Theme.getColor("main_background")
  127. }
  128. UM.SimpleButton
  129. {
  130. id: customisedSettings
  131. visible: Cura.MachineManager.hasUserSettings
  132. width: UM.Theme.getSize("print_setup_icon").width
  133. height: UM.Theme.getSize("print_setup_icon").height
  134. anchors.verticalCenter: parent.verticalCenter
  135. anchors.right: downArrow.left
  136. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  137. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  138. iconSource: UM.Theme.getIcon("star")
  139. onClicked:
  140. {
  141. forceActiveFocus();
  142. Cura.Actions.manageProfiles.trigger()
  143. }
  144. onEntered:
  145. {
  146. 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.")
  147. base.showTooltip(intent, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content)
  148. }
  149. onExited: base.hideTooltip()
  150. }
  151. UM.RecolorImage
  152. {
  153. id: downArrow
  154. source: UM.Theme.getIcon("arrow_bottom")
  155. width: UM.Theme.getSize("standard_arrow").width
  156. height: UM.Theme.getSize("standard_arrow").height
  157. anchors
  158. {
  159. right: parent.right
  160. verticalCenter: parent.verticalCenter
  161. rightMargin: UM.Theme.getSize("default_margin").width
  162. }
  163. color: UM.Theme.getColor("setting_control_button")
  164. }
  165. }
  166. QualitiesWithIntentMenu
  167. {
  168. id: menu
  169. y: intentSelection.y + intentSelection.height
  170. x: intentSelection.x
  171. width: intentSelection.width
  172. }
  173. }
  174. UM.TabRow
  175. {
  176. id: tabBar
  177. visible: multipleExtruders // The tab row is only visible when there are more than 1 extruder
  178. anchors
  179. {
  180. top: intent.bottom
  181. topMargin: UM.Theme.getSize("default_margin").height
  182. left: parent.left
  183. leftMargin: parent.padding
  184. right: parent.right
  185. rightMargin: parent.padding
  186. }
  187. Repeater
  188. {
  189. id: repeater
  190. model: extrudersModel
  191. delegate: UM.TabRowButton
  192. {
  193. contentItem: Item
  194. {
  195. Cura.ExtruderIcon
  196. {
  197. anchors.horizontalCenter: parent.horizontalCenter
  198. materialColor: model.color
  199. extruderEnabled: model.enabled
  200. }
  201. }
  202. onClicked:
  203. {
  204. Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex)
  205. }
  206. }
  207. }
  208. //When active extruder changes for some other reason, switch tabs.
  209. //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex!
  210. //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead.
  211. Connections
  212. {
  213. target: Cura.ExtruderManager
  214. onActiveExtruderChanged:
  215. {
  216. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex);
  217. }
  218. }
  219. //When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
  220. //This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
  221. //Therefore we need to change it back to what it was: The active extruder index.
  222. Connections
  223. {
  224. target: repeater.model
  225. onModelChanged:
  226. {
  227. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex)
  228. }
  229. }
  230. }
  231. Rectangle
  232. {
  233. anchors
  234. {
  235. top: tabBar.visible ? tabBar.bottom : intent.bottom
  236. topMargin: -UM.Theme.getSize("default_lining").width
  237. left: parent.left
  238. leftMargin: parent.padding
  239. right: parent.right
  240. rightMargin: parent.padding
  241. bottom: parent.bottom
  242. }
  243. z: tabBar.z - 1
  244. // Don't show the border when only one extruder
  245. border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent"
  246. border.width: UM.Theme.getSize("default_lining").width
  247. color: UM.Theme.getColor("main_background")
  248. Cura.SettingView
  249. {
  250. anchors
  251. {
  252. fill: parent
  253. topMargin: UM.Theme.getSize("default_margin").height
  254. leftMargin: UM.Theme.getSize("default_margin").width
  255. // Small space for the scrollbar
  256. rightMargin: UM.Theme.getSize("narrow_margin").width
  257. // Compensate for the negative margin in the parent
  258. bottomMargin: UM.Theme.getSize("default_lining").width
  259. }
  260. }
  261. }
  262. }