SidebarHeader.qml 16 KB

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