CustomConfiguration.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.6
  4. import QtQuick.Controls 2.0
  5. import QtQuick.Controls 1.1 as OldControls
  6. import Cura 1.0 as Cura
  7. import UM 1.3 as UM
  8. Item
  9. {
  10. UM.I18nCatalog
  11. {
  12. id: catalog
  13. name: "cura"
  14. }
  15. width: parent.width
  16. height: childrenRect.height
  17. Label
  18. {
  19. id: header
  20. text: catalog.i18nc("@header", "Custom")
  21. font: UM.Theme.getFont("medium")
  22. color: UM.Theme.getColor("small_button_text")
  23. height: contentHeight
  24. renderType: Text.NativeRendering
  25. anchors
  26. {
  27. top: parent.top
  28. left: parent.left
  29. right: parent.right
  30. }
  31. }
  32. //Printer type selector.
  33. Item
  34. {
  35. id: printerTypeSelectorRow
  36. visible:
  37. {
  38. return Cura.MachineManager.printerOutputDevices.length >= 1 //If connected...
  39. && Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount != null //...and we have configuration information...
  40. && Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1; //...and there is more than one type of printer in the configuration list.
  41. }
  42. height: visible ? childrenRect.height : 0
  43. anchors
  44. {
  45. left: parent.left
  46. right: parent.right
  47. top: header.bottom
  48. topMargin: visible ? UM.Theme.getSize("default_margin").height : 0
  49. }
  50. Label
  51. {
  52. text: catalog.i18nc("@label", "Printer")
  53. width: Math.round(parent.width * 0.3) - UM.Theme.getSize("default_margin").width
  54. height: contentHeight
  55. font: UM.Theme.getFont("default")
  56. color: UM.Theme.getColor("text")
  57. anchors.verticalCenter: printerTypeSelector.verticalCenter
  58. anchors.left: parent.left
  59. }
  60. OldControls.ToolButton
  61. {
  62. id: printerTypeSelector
  63. text: Cura.MachineManager.activeMachineDefinitionName
  64. tooltip: Cura.MachineManager.activeMachineDefinitionName
  65. height: UM.Theme.getSize("print_setup_big_item").height
  66. width: Math.round(parent.width * 0.7) + UM.Theme.getSize("default_margin").width
  67. anchors.right: parent.right
  68. style: UM.Theme.styles.print_setup_header_button
  69. menu: Cura.PrinterTypeMenu { }
  70. }
  71. }
  72. UM.TabRow
  73. {
  74. id: tabBar
  75. anchors.top: printerTypeSelectorRow.bottom
  76. anchors.topMargin: UM.Theme.getSize("default_margin").height
  77. visible: extrudersModel.count > 1
  78. Repeater
  79. {
  80. id: repeater
  81. model: extrudersModel
  82. delegate: UM.TabRowButton
  83. {
  84. contentItem: Item
  85. {
  86. Cura.ExtruderIcon
  87. {
  88. anchors.horizontalCenter: parent.horizontalCenter
  89. materialColor: model.color
  90. extruderEnabled: model.enabled
  91. width: parent.height
  92. height: parent.height
  93. }
  94. }
  95. onClicked:
  96. {
  97. Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex)
  98. }
  99. }
  100. }
  101. //When active extruder changes for some other reason, switch tabs.
  102. //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex!
  103. //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead.
  104. Connections
  105. {
  106. target: Cura.ExtruderManager
  107. onActiveExtruderChanged:
  108. {
  109. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex);
  110. }
  111. }
  112. //When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
  113. //This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
  114. //Therefore we need to change it back to what it was: The active extruder index.
  115. Connections
  116. {
  117. target: repeater.model
  118. onModelChanged:
  119. {
  120. tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex)
  121. }
  122. }
  123. }
  124. Rectangle
  125. {
  126. width: parent.width
  127. height: childrenRect.height
  128. anchors.top: tabBar.bottom
  129. radius: tabBar.visible ? UM.Theme.getSize("default_radius").width : 0
  130. border.width: tabBar.visible ? UM.Theme.getSize("default_lining").width : 0
  131. border.color: UM.Theme.getColor("lining")
  132. color: UM.Theme.getColor("main_background")
  133. //Remove rounding and lining at the top.
  134. Rectangle
  135. {
  136. width: parent.width
  137. height: parent.radius
  138. anchors.top: parent.top
  139. color: UM.Theme.getColor("lining")
  140. visible: tabBar.visible
  141. Rectangle
  142. {
  143. anchors
  144. {
  145. left: parent.left
  146. leftMargin: parent.parent.border.width
  147. right: parent.right
  148. rightMargin: parent.parent.border.width
  149. top: parent.top
  150. }
  151. height: parent.parent.radius
  152. color: parent.parent.color
  153. }
  154. }
  155. Column
  156. {
  157. id: selectors
  158. padding: UM.Theme.getSize("default_margin").width
  159. spacing: UM.Theme.getSize("default_margin").height
  160. property var model: extrudersModel.items[tabBar.currentIndex]
  161. readonly property real paddedWidth: parent.width - padding * 2
  162. property real textWidth: Math.round(paddedWidth * 0.3)
  163. property real controlWidth: paddedWidth - textWidth
  164. Row
  165. {
  166. height: UM.Theme.getSize("print_setup_item").height
  167. visible: extrudersModel.count > 1 // If there is only one extruder, there is no point to enable/disable that.
  168. Label
  169. {
  170. text: catalog.i18nc("@label", "Enabled")
  171. verticalAlignment: Text.AlignVCenter
  172. font: UM.Theme.getFont("default")
  173. color: UM.Theme.getColor("text")
  174. height: parent.height
  175. width: selectors.textWidth
  176. renderType: Text.NativeRendering
  177. }
  178. OldControls.CheckBox
  179. {
  180. checked: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.isEnabled : false
  181. enabled: !checked || Cura.MachineManager.numberExtrudersEnabled > 1 //Disable if it's the last enabled extruder.
  182. height: UM.Theme.getSize("setting_control").height
  183. style: UM.Theme.styles.checkbox
  184. /* Use a MouseArea to process the click on this checkbox.
  185. This is necessary because actually clicking the checkbox
  186. causes the "checked" property to be overwritten. After
  187. it's been overwritten, the original link that made it
  188. depend on the active extruder stack is broken. */
  189. MouseArea
  190. {
  191. anchors.fill: parent
  192. onClicked: Cura.MachineManager.setExtruderEnabled(Cura.ExtruderManager.activeExtruderIndex, !parent.checked)
  193. enabled: parent.enabled
  194. }
  195. }
  196. }
  197. Row
  198. {
  199. height: UM.Theme.getSize("print_setup_big_item").height
  200. visible: Cura.MachineManager.hasMaterials
  201. Label
  202. {
  203. text: catalog.i18nc("@label", "Material")
  204. verticalAlignment: Text.AlignVCenter
  205. font: UM.Theme.getFont("default")
  206. color: UM.Theme.getColor("text")
  207. height: parent.height
  208. width: selectors.textWidth
  209. renderType: Text.NativeRendering
  210. }
  211. OldControls.ToolButton
  212. {
  213. id: materialSelection
  214. property bool valueError: Cura.MachineManager.activeStack != null ? Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeStack.material.id, "compatible", "") != "True" : true
  215. property bool valueWarning: !Cura.MachineManager.isActiveQualitySupported
  216. text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.material.name : ""
  217. tooltip: text
  218. height: UM.Theme.getSize("print_setup_big_item").height
  219. width: selectors.controlWidth
  220. style: UM.Theme.styles.print_setup_header_button
  221. activeFocusOnPress: true
  222. menu: Cura.MaterialMenu
  223. {
  224. extruderIndex: Cura.ExtruderManager.activeExtruderIndex
  225. }
  226. }
  227. }
  228. Row
  229. {
  230. height: UM.Theme.getSize("print_setup_big_item").height
  231. visible: Cura.MachineManager.hasVariants
  232. Label
  233. {
  234. text: Cura.MachineManager.activeDefinitionVariantsName
  235. verticalAlignment: Text.AlignVCenter
  236. font: UM.Theme.getFont("default")
  237. color: UM.Theme.getColor("text")
  238. height: parent.height
  239. width: selectors.textWidth
  240. renderType: Text.NativeRendering
  241. }
  242. OldControls.ToolButton
  243. {
  244. id: variantSelection
  245. text: Cura.MachineManager.activeVariantName
  246. tooltip: Cura.MachineManager.activeVariantName
  247. height: UM.Theme.getSize("print_setup_big_item").height
  248. width: selectors.controlWidth
  249. style: UM.Theme.styles.print_setup_header_button
  250. activeFocusOnPress: true;
  251. menu: Cura.NozzleMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex }
  252. }
  253. }
  254. Row
  255. {
  256. id: warnings
  257. height: UM.Theme.getSize("print_setup_big_item").height
  258. visible: buildplateCompatibilityError || buildplateCompatibilityWarning
  259. property bool buildplateCompatibilityError: !Cura.MachineManager.variantBuildplateCompatible && !Cura.MachineManager.variantBuildplateUsable
  260. property bool buildplateCompatibilityWarning: Cura.MachineManager.variantBuildplateUsable
  261. // This is a space holder aligning the warning messages.
  262. Label
  263. {
  264. text: ""
  265. width: selectors.textWidth
  266. renderType: Text.NativeRendering
  267. }
  268. Item
  269. {
  270. width: selectors.controlWidth
  271. height: parent.height
  272. UM.RecolorImage
  273. {
  274. id: warningImage
  275. anchors.left: parent.left
  276. source: UM.Theme.getIcon("warning")
  277. width: UM.Theme.getSize("section_icon").width
  278. height: UM.Theme.getSize("section_icon").height
  279. sourceSize.width: width
  280. sourceSize.height: height
  281. color: UM.Theme.getColor("material_compatibility_warning")
  282. visible: !Cura.MachineManager.isCurrentSetupSupported || warnings.buildplateCompatibilityError || warnings.buildplateCompatibilityWarning
  283. }
  284. Label
  285. {
  286. id: materialCompatibilityLabel
  287. anchors.left: warningImage.right
  288. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  289. verticalAlignment: Text.AlignVCenter
  290. width: selectors.controlWidth - warningImage.width - UM.Theme.getSize("default_margin").width
  291. text: catalog.i18nc("@label", "Use glue for better adhesion with this material combination.")
  292. font: UM.Theme.getFont("very_small")
  293. color: UM.Theme.getColor("text")
  294. visible: CuraSDKVersion == "dev" ? false : warnings.buildplateCompatibilityError || warnings.buildplateCompatibilityWarning
  295. wrapMode: Text.WordWrap
  296. renderType: Text.NativeRendering
  297. }
  298. }
  299. }
  300. }
  301. }
  302. }