SidebarHeader.qml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. spacing: UM.Theme.getSize("default_margin").height
  14. signal showTooltip(Item item, point location, string text)
  15. signal hideTooltip()
  16. Item
  17. {
  18. id: extruderSelectionRow
  19. width: parent.width
  20. height: UM.Theme.getSize("sidebar_tabs").height
  21. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  22. Rectangle
  23. {
  24. id: extruderSeparator
  25. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  26. width: parent.width
  27. height: parent.height
  28. color: UM.Theme.getColor("sidebar_lining")
  29. anchors.top: extruderSelectionRow.top
  30. }
  31. ListView
  32. {
  33. id: extrudersList
  34. property var index: 0
  35. height: UM.Theme.getSize("sidebar_header_mode_tabs").height
  36. width: parent.width
  37. boundsBehavior: Flickable.StopAtBounds
  38. anchors
  39. {
  40. left: parent.left
  41. right: parent.right
  42. bottom: extruderSelectionRow.bottom
  43. }
  44. ExclusiveGroup { id: extruderMenuGroup; }
  45. orientation: ListView.Horizontal
  46. model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: false }
  47. Connections
  48. {
  49. target: Cura.MachineManager
  50. onGlobalContainerChanged:
  51. {
  52. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  53. var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
  54. ExtruderManager.setActiveExtruderIndex(extruder_index);
  55. }
  56. }
  57. delegate: Button
  58. {
  59. height: ListView.view.height
  60. width: ListView.view.width / extrudersModel.rowCount()
  61. text: model.name
  62. tooltip: model.name
  63. exclusiveGroup: extruderMenuGroup
  64. checked: base.currentExtruderIndex == index
  65. onClicked:
  66. {
  67. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  68. ExtruderManager.setActiveExtruderIndex(index);
  69. }
  70. style: ButtonStyle
  71. {
  72. background: Rectangle
  73. {
  74. border.width: UM.Theme.getSize("default_lining").width
  75. border.color: control.checked ? UM.Theme.getColor("tab_checked_border") :
  76. control.pressed ? UM.Theme.getColor("tab_active_border") :
  77. control.hovered ? UM.Theme.getColor("tab_hovered_border") : UM.Theme.getColor("tab_unchecked_border")
  78. color: control.checked ? UM.Theme.getColor("tab_checked") :
  79. control.pressed ? UM.Theme.getColor("tab_active") :
  80. control.hovered ? UM.Theme.getColor("tab_hovered") : UM.Theme.getColor("tab_unchecked")
  81. Behavior on color { ColorAnimation { duration: 50; } }
  82. Rectangle
  83. {
  84. id: highlight
  85. visible: control.checked
  86. anchors.left: parent.left
  87. anchors.right: parent.right
  88. anchors.top: parent.top
  89. height: UM.Theme.getSize("sidebar_header_highlight").height
  90. color: UM.Theme.getColor("sidebar_header_bar")
  91. }
  92. Rectangle
  93. {
  94. id: swatch
  95. visible: index > -1
  96. height: UM.Theme.getSize("setting_control").height / 2
  97. width: height
  98. anchors.left: parent.left
  99. anchors.leftMargin: (parent.height - height) / 2
  100. anchors.verticalCenter: parent.verticalCenter
  101. color: model.color
  102. border.width: UM.Theme.getSize("default_lining").width
  103. border.color: UM.Theme.getColor("setting_control_border")
  104. }
  105. Text
  106. {
  107. anchors.verticalCenter: parent.verticalCenter
  108. anchors.left: swatch.visible ? swatch.right : parent.left
  109. anchors.leftMargin: swatch.visible ? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("default_margin").width
  110. anchors.right: parent.right
  111. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  112. color: control.checked ? UM.Theme.getColor("tab_checked_text") :
  113. control.pressed ? UM.Theme.getColor("tab_active_text") :
  114. control.hovered ? UM.Theme.getColor("tab_hovered_text") : UM.Theme.getColor("tab_unchecked_text")
  115. font: UM.Theme.getFont("default")
  116. text: control.text
  117. elide: Text.ElideRight
  118. }
  119. }
  120. label: Item { }
  121. }
  122. }
  123. }
  124. }
  125. Item
  126. {
  127. id: variantRowSpacer
  128. height: UM.Theme.getSize("default_margin").height / 4
  129. width: height
  130. visible: !extruderSelectionRow.visible
  131. }
  132. Item
  133. {
  134. id: variantRow
  135. height: UM.Theme.getSize("sidebar_setup").height
  136. visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings
  137. anchors
  138. {
  139. left: parent.left
  140. leftMargin: UM.Theme.getSize("default_margin").width
  141. right: parent.right
  142. rightMargin: UM.Theme.getSize("default_margin").width
  143. }
  144. Text
  145. {
  146. id: variantLabel
  147. width: parent.width * 0.30
  148. anchors.verticalCenter: parent.verticalCenter
  149. anchors.left: variantRow.left
  150. font: UM.Theme.getFont("default");
  151. color: UM.Theme.getColor("text");
  152. text:
  153. {
  154. var label;
  155. if(Cura.MachineManager.hasVariants && Cura.MachineManager.hasMaterials)
  156. {
  157. label = "%1 & %2".arg(Cura.MachineManager.activeDefinitionVariantsName).arg(catalog.i18nc("@label","Material"));
  158. }
  159. else if(Cura.MachineManager.hasVariants)
  160. {
  161. label = Cura.MachineManager.activeDefinitionVariantsName;
  162. }
  163. else
  164. {
  165. label = catalog.i18nc("@label","Material");
  166. }
  167. return "%1:".arg(label);
  168. }
  169. }
  170. Button
  171. {
  172. id: materialInfoButton
  173. height: parent.height * 0.60
  174. width: height
  175. anchors.right: materialVariantContainer.left
  176. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  177. anchors.verticalCenter: parent.verticalCenter
  178. visible: extrudersList.visible
  179. text: "i"
  180. style: UM.Theme.styles.info_button
  181. onClicked:
  182. {
  183. // open the material URL with web browser
  184. var version = UM.Application.version;
  185. var machineName = Cura.MachineManager.activeMachine.definition.id;
  186. var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName;
  187. Qt.openUrlExternally(url);
  188. }
  189. onHoveredChanged:
  190. {
  191. if (hovered)
  192. {
  193. var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com.");
  194. base.showTooltip(
  195. extruderSelectionRow, Qt.point(0, extruderSelectionRow.height + variantRow.height / 2), catalog.i18nc("@tooltip", content)
  196. );
  197. }
  198. else
  199. {
  200. base.hideTooltip();
  201. }
  202. }
  203. }
  204. Item
  205. {
  206. id: materialVariantContainer
  207. anchors.verticalCenter: parent.verticalCenter
  208. anchors.right: parent.right
  209. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  210. height: UM.Theme.getSize("setting_control").height
  211. ToolButton {
  212. id: variantSelection
  213. text: Cura.MachineManager.activeVariantName
  214. tooltip: Cura.MachineManager.activeVariantName;
  215. visible: Cura.MachineManager.hasVariants
  216. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  217. height: UM.Theme.getSize("setting_control").height
  218. width: materialSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  219. anchors.left: parent.left
  220. style: UM.Theme.styles.sidebar_header_button
  221. activeFocusOnPress: true;
  222. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  223. }
  224. ToolButton {
  225. id: materialSelection
  226. text: Cura.MachineManager.activeMaterialName
  227. tooltip: Cura.MachineManager.activeMaterialName
  228. visible: Cura.MachineManager.hasMaterials
  229. property var valueError:
  230. {
  231. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  232. if(data == "False")
  233. {
  234. return true
  235. }
  236. else
  237. {
  238. return false
  239. }
  240. }
  241. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  242. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  243. height: UM.Theme.getSize("setting_control").height
  244. width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  245. anchors.right: parent.right
  246. style: UM.Theme.styles.sidebar_header_button
  247. activeFocusOnPress: true;
  248. menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
  249. }
  250. }
  251. }
  252. Row
  253. {
  254. id: globalProfileRow
  255. height: UM.Theme.getSize("sidebar_setup").height
  256. visible: !sidebar.monitoringPrint && !sidebar.hideSettings
  257. anchors
  258. {
  259. left: parent.left
  260. leftMargin: UM.Theme.getSize("default_margin").width
  261. right: parent.right
  262. rightMargin: UM.Theme.getSize("default_margin").width
  263. }
  264. Text
  265. {
  266. id: globalProfileLabel
  267. text: catalog.i18nc("@label","Profile:");
  268. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  269. font: UM.Theme.getFont("default");
  270. color: UM.Theme.getColor("text");
  271. }
  272. ToolButton
  273. {
  274. id: globalProfileSelection
  275. text: {
  276. var result = Cura.MachineManager.activeQualityName;
  277. if (Cura.MachineManager.activeQualityLayerHeight > 0) {
  278. result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">";
  279. result += " - ";
  280. result += Cura.MachineManager.activeQualityLayerHeight + "mm";
  281. result += "</font>";
  282. }
  283. return result;
  284. }
  285. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  286. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  287. height: UM.Theme.getSize("setting_control").height
  288. tooltip: Cura.MachineManager.activeQualityName
  289. style: UM.Theme.styles.sidebar_header_button
  290. activeFocusOnPress: true;
  291. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  292. menu: ProfileMenu { }
  293. UM.SimpleButton
  294. {
  295. id: customisedSettings
  296. visible: Cura.MachineManager.hasUserSettings
  297. height: parent.height * 0.6
  298. width: parent.height * 0.6
  299. anchors.verticalCenter: parent.verticalCenter
  300. anchors.right: parent.right
  301. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("default_margin").width
  302. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  303. iconSource: UM.Theme.getIcon("star");
  304. onClicked:
  305. {
  306. forceActiveFocus();
  307. Cura.Actions.manageProfiles.trigger()
  308. }
  309. onEntered:
  310. {
  311. 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.")
  312. base.showTooltip(globalProfileRow, Qt.point(0, globalProfileRow.height / 2), content)
  313. }
  314. onExited: base.hideTooltip()
  315. }
  316. }
  317. }
  318. UM.SettingPropertyProvider
  319. {
  320. id: machineExtruderCount
  321. containerStackId: Cura.MachineManager.activeMachineId
  322. key: "machine_extruder_count"
  323. watchedProperties: [ "value" ]
  324. storeIndex: 0
  325. }
  326. UM.I18nCatalog { id: catalog; name:"cura" }
  327. }