SidebarHeader.qml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. import "Menus"
  9. Column
  10. {
  11. id: base;
  12. property int currentExtruderIndex: ExtruderManager.activeExtruderIndex;
  13. property bool currentExtruderVisible: extrudersList.visible;
  14. spacing: UM.Theme.getSize("default_margin").height
  15. signal showTooltip(Item item, point location, string text)
  16. signal hideTooltip()
  17. Item
  18. {
  19. height: UM.Theme.getSize("default_margin").height / 4
  20. width: height
  21. visible: extruderSelectionRow.visible
  22. }
  23. Label
  24. {
  25. id: extruderSelectionLabel
  26. anchors
  27. {
  28. left: parent.left
  29. leftMargin: UM.Theme.getSize("default_margin").width
  30. right: parent.right
  31. rightMargin: UM.Theme.getSize("default_margin").width
  32. }
  33. height: UM.Theme.getSize("sidebar_tabs").height / 3
  34. text: catalog.i18nc("@label", "Extruder configuration")
  35. font: UM.Theme.getFont("default_bold")
  36. color: UM.Theme.getColor("text")
  37. visible: extruderSelectionRow.visible
  38. }
  39. Item
  40. {
  41. id: extruderSelectionRow
  42. width: parent.width
  43. height: UM.Theme.getSize("sidebar_tabs").height
  44. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  45. anchors
  46. {
  47. left: parent.left
  48. leftMargin: UM.Theme.getSize("default_margin").width
  49. right: parent.right
  50. rightMargin: UM.Theme.getSize("default_margin").width
  51. }
  52. ListView
  53. {
  54. id: extrudersList
  55. property var index: 0
  56. height: UM.Theme.getSize("sidebar_header_mode_tabs").height
  57. width: parent.width
  58. boundsBehavior: Flickable.StopAtBounds
  59. anchors
  60. {
  61. left: parent.left
  62. leftMargin: UM.Theme.getSize("default_margin").width / 2
  63. right: parent.right
  64. rightMargin: UM.Theme.getSize("default_margin").width / 2
  65. verticalCenter: parent.verticalCenter
  66. }
  67. ExclusiveGroup { id: extruderMenuGroup; }
  68. orientation: ListView.Horizontal
  69. model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: false }
  70. Connections
  71. {
  72. target: Cura.MachineManager
  73. onGlobalContainerChanged:
  74. {
  75. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  76. var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
  77. ExtruderManager.setActiveExtruderIndex(extruder_index);
  78. }
  79. }
  80. delegate: Button
  81. {
  82. height: ListView.view.height
  83. width: ListView.view.width / extrudersModel.rowCount()
  84. text: model.name
  85. tooltip: model.name
  86. exclusiveGroup: extruderMenuGroup
  87. checked: base.currentExtruderIndex == index
  88. onClicked:
  89. {
  90. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  91. ExtruderManager.setActiveExtruderIndex(index);
  92. }
  93. style: ButtonStyle
  94. {
  95. background: Item
  96. {
  97. Rectangle
  98. {
  99. anchors.fill: parent
  100. border.width: UM.Theme.getSize("default_lining").width
  101. border.color: control.checked ? UM.Theme.getColor("toggle_checked_border") :
  102. control.pressed ? UM.Theme.getColor("toggle_active_border") :
  103. control.hovered ? UM.Theme.getColor("toggle_hovered_border") : UM.Theme.getColor("toggle_unchecked_border")
  104. color: control.checked ? UM.Theme.getColor("toggle_checked") :
  105. control.pressed ? UM.Theme.getColor("toggle_active") :
  106. control.hovered ? UM.Theme.getColor("toggle_hovered") : UM.Theme.getColor("toggle_unchecked")
  107. Behavior on color { ColorAnimation { duration: 50; } }
  108. }
  109. Item
  110. {
  111. id: extruderButtonFace
  112. anchors.centerIn: parent
  113. width: {
  114. var extruderTextWidth = extruderStaticText.visible ? extruderStaticText.width : 0;
  115. var iconWidth = extruderIconItem.width;
  116. return extruderTextWidth + iconWidth + UM.Theme.getSize("default_margin").width / 4;
  117. }
  118. // Static text "Extruder"
  119. Text
  120. {
  121. id: extruderStaticText
  122. anchors.verticalCenter: parent.verticalCenter
  123. anchors.left: parent.left
  124. color: control.checked ? UM.Theme.getColor("toggle_checked_text") :
  125. control.pressed ? UM.Theme.getColor("toggle_active_text") :
  126. control.hovered ? UM.Theme.getColor("toggle_hovered_text") : UM.Theme.getColor("toggle_unchecked_text")
  127. font: UM.Theme.getFont("default")
  128. text: catalog.i18nc("@label", "Extruder")
  129. visible: width < (control.width - extruderIconItem.width - UM.Theme.getSize("default_margin").width)
  130. elide: Text.ElideRight
  131. }
  132. // Everthing for the extruder icon
  133. Item
  134. {
  135. id: extruderIconItem
  136. anchors.verticalCenter: parent.verticalCenter
  137. anchors.right: parent.right
  138. property var sizeToUse:
  139. {
  140. var minimumWidth = control.width < UM.Theme.getSize("button").width ? control.width : UM.Theme.getSize("button").width;
  141. var minimumHeight = control.height < UM.Theme.getSize("button").height ? control.height : UM.Theme.getSize("button").height;
  142. var minimumSize = minimumWidth < minimumHeight ? minimumWidth : minimumHeight;
  143. minimumSize -= UM.Theme.getSize("default_margin").width;
  144. return minimumSize;
  145. }
  146. width: sizeToUse
  147. height: sizeToUse
  148. UM.RecolorImage {
  149. id: mainCircle
  150. anchors.fill: parent
  151. sourceSize.width: parent.width
  152. sourceSize.height: parent.width
  153. source: UM.Theme.getIcon("extruder_button")
  154. color: extruderNumberText.color
  155. }
  156. Text
  157. {
  158. id: extruderNumberText
  159. anchors.centerIn: parent
  160. text: index + 1;
  161. color: control.checked ? UM.Theme.getColor("toggle_checked_text") :
  162. control.pressed ? UM.Theme.getColor("toggle_active_text") :
  163. control.hovered ? UM.Theme.getColor("toggle_hovered_text") : UM.Theme.getColor("toggle_unchecked_text")
  164. font: UM.Theme.getFont("default_bold")
  165. }
  166. // Material colour circle
  167. // Only draw the filling colour of the material inside the SVG border.
  168. Rectangle
  169. {
  170. anchors
  171. {
  172. right: parent.right
  173. top: parent.top
  174. rightMargin: parent.sizeToUse * 0.04
  175. topMargin: parent.sizeToUse * 0.04
  176. }
  177. color: model.color
  178. width: parent.width * 0.27
  179. height: parent.height * 0.27
  180. radius: width / 2
  181. border.width: 0
  182. border.color: "transparent"
  183. opacity: !control.checked ? 0.6 : 1.0
  184. }
  185. }
  186. }
  187. }
  188. label: Item {}
  189. }
  190. }
  191. }
  192. }
  193. Item
  194. {
  195. id: variantRowSpacer
  196. height: UM.Theme.getSize("default_margin").height / 4
  197. width: height
  198. visible: !extruderSelectionRow.visible
  199. }
  200. // Material Row
  201. Item
  202. {
  203. id: materialRow
  204. height: UM.Theme.getSize("sidebar_setup").height
  205. visible: Cura.MachineManager.hasMaterials && !sidebar.monitoringPrint && !sidebar.hideSettings
  206. anchors
  207. {
  208. left: parent.left
  209. leftMargin: UM.Theme.getSize("default_margin").width
  210. right: parent.right
  211. rightMargin: UM.Theme.getSize("default_margin").width
  212. }
  213. Text
  214. {
  215. id: materialLabel
  216. text: catalog.i18nc("@label","Material");
  217. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  218. font: UM.Theme.getFont("default");
  219. color: UM.Theme.getColor("text");
  220. }
  221. ToolButton {
  222. id: materialSelection
  223. text: Cura.MachineManager.activeMaterialName
  224. tooltip: Cura.MachineManager.activeMaterialName
  225. visible: Cura.MachineManager.hasMaterials
  226. property var valueError:
  227. {
  228. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  229. if(data == "False")
  230. {
  231. return true
  232. }
  233. else
  234. {
  235. return false
  236. }
  237. }
  238. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  239. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  240. height: UM.Theme.getSize("setting_control").height
  241. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  242. anchors.right: parent.right
  243. style: UM.Theme.styles.sidebar_header_button
  244. activeFocusOnPress: true;
  245. menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
  246. }
  247. }
  248. // Print core row
  249. Item
  250. {
  251. id: printCoreRow
  252. height: UM.Theme.getSize("sidebar_setup").height
  253. visible: Cura.MachineManager.hasVariants && !sidebar.monitoringPrint && !sidebar.hideSettings
  254. anchors
  255. {
  256. left: parent.left
  257. leftMargin: UM.Theme.getSize("default_margin").width
  258. right: parent.right
  259. rightMargin: UM.Theme.getSize("default_margin").width
  260. }
  261. Text
  262. {
  263. id: printCoreLabel
  264. text: Cura.MachineManager.activeDefinitionVariantsName;
  265. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  266. font: UM.Theme.getFont("default");
  267. color: UM.Theme.getColor("text");
  268. }
  269. ToolButton {
  270. id: printCoreSelection
  271. text: Cura.MachineManager.activeVariantName
  272. tooltip: Cura.MachineManager.activeVariantName;
  273. visible: Cura.MachineManager.hasVariants
  274. height: UM.Theme.getSize("setting_control").height
  275. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  276. anchors.right: parent.right
  277. style: UM.Theme.styles.sidebar_header_button
  278. activeFocusOnPress: true;
  279. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  280. }
  281. }
  282. // Material info row
  283. Item
  284. {
  285. id: materialInfoRow
  286. height: UM.Theme.getSize("sidebar_setup").height
  287. visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings
  288. anchors
  289. {
  290. left: parent.left
  291. leftMargin: UM.Theme.getSize("default_margin").width
  292. right: parent.right
  293. rightMargin: UM.Theme.getSize("default_margin").width
  294. }
  295. Item
  296. {
  297. height: UM.Theme.getSize("sidebar_setup").height
  298. anchors.right: parent.right
  299. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  300. Text
  301. {
  302. id: materialInfoLabel
  303. wrapMode: Text.WordWrap
  304. text: catalog.i18nc("@label","Check material compability");
  305. font: UM.Theme.getFont("default");
  306. verticalAlignment: Text.AlignVCenter
  307. anchors.top: parent.top
  308. anchors.bottom: parent.bottom
  309. color:
  310. {
  311. if (!Cura.MachineManager.isActiveQualitySupported)
  312. {
  313. UM.Theme.getColor("setting_validation_error");
  314. }
  315. else
  316. {
  317. UM.Theme.getColor("text");
  318. }
  319. }
  320. MouseArea
  321. {
  322. anchors.fill: parent
  323. hoverEnabled: true
  324. onClicked:
  325. {
  326. // open the material URL with web browser
  327. var version = UM.Application.version;
  328. var machineName = Cura.MachineManager.activeMachine.definition.id;
  329. var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName;
  330. Qt.openUrlExternally(url);
  331. }
  332. onEntered:
  333. {
  334. var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com.");
  335. base.showTooltip(
  336. materialInfoRow,
  337. Qt.point(-UM.Theme.getSize("default_margin").width, 0),
  338. catalog.i18nc("@tooltip", content)
  339. );
  340. }
  341. onExited: base.hideTooltip();
  342. }
  343. }
  344. UM.RecolorImage
  345. {
  346. id: warningImage
  347. anchors.right: parent.right
  348. anchors.verticalCenter: parent.Bottom
  349. source: UM.Theme.getIcon("warning")
  350. width: UM.Theme.getSize("section_icon").width
  351. height: UM.Theme.getSize("section_icon").height
  352. //sourceSize.width: width + 5
  353. //sourceSize.height: width + 5
  354. color: UM.Theme.getColor("setting_control_text")
  355. visible: !Cura.MachineManager.isActiveQualitySupported
  356. }
  357. }
  358. }
  359. UM.SettingPropertyProvider
  360. {
  361. id: machineExtruderCount
  362. containerStackId: Cura.MachineManager.activeMachineId
  363. key: "machine_extruder_count"
  364. watchedProperties: [ "value" ]
  365. storeIndex: 0
  366. }
  367. UM.I18nCatalog { id: catalog; name:"cura" }
  368. }