SidebarHeader.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. // Copyright (c) 2015 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. Label
  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. Row
  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. Label
  145. {
  146. id: variantLabel
  147. text:
  148. {
  149. var label;
  150. if(Cura.MachineManager.hasVariants && Cura.MachineManager.hasMaterials)
  151. {
  152. label = "%1 & %2".arg(Cura.MachineManager.activeDefinitionVariantsName).arg(catalog.i18nc("@label","Material"));
  153. }
  154. else if(Cura.MachineManager.hasVariants)
  155. {
  156. label = Cura.MachineManager.activeDefinitionVariantsName;
  157. }
  158. else
  159. {
  160. label = catalog.i18nc("@label","Material");
  161. }
  162. return "%1:".arg(label);
  163. }
  164. anchors.verticalCenter: parent.verticalCenter
  165. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  166. font: UM.Theme.getFont("default");
  167. color: UM.Theme.getColor("text");
  168. }
  169. Item
  170. {
  171. anchors.verticalCenter: parent.verticalCenter
  172. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  173. height: UM.Theme.getSize("setting_control").height
  174. ToolButton {
  175. id: variantSelection
  176. text: Cura.MachineManager.activeVariantName
  177. tooltip: Cura.MachineManager.activeVariantName;
  178. visible: Cura.MachineManager.hasVariants
  179. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  180. height: UM.Theme.getSize("setting_control").height
  181. width: materialSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  182. anchors.left: parent.left
  183. style: UM.Theme.styles.sidebar_header_button
  184. activeFocusOnPress: true;
  185. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  186. }
  187. ToolButton {
  188. id: materialSelection
  189. text: Cura.MachineManager.activeMaterialName
  190. tooltip: Cura.MachineManager.activeMaterialName
  191. visible: Cura.MachineManager.hasMaterials
  192. property var valueError:
  193. {
  194. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  195. if(data == "False")
  196. {
  197. return true
  198. }
  199. else
  200. {
  201. return false
  202. }
  203. }
  204. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  205. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  206. height: UM.Theme.getSize("setting_control").height
  207. width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  208. anchors.right: parent.right
  209. style: UM.Theme.styles.sidebar_header_button
  210. activeFocusOnPress: true;
  211. menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
  212. }
  213. }
  214. }
  215. Row
  216. {
  217. id: globalProfileRow
  218. height: UM.Theme.getSize("sidebar_setup").height
  219. visible: !sidebar.monitoringPrint && !sidebar.hideSettings
  220. anchors
  221. {
  222. left: parent.left
  223. leftMargin: UM.Theme.getSize("default_margin").width
  224. right: parent.right
  225. rightMargin: UM.Theme.getSize("default_margin").width
  226. }
  227. Label
  228. {
  229. id: globalProfileLabel
  230. text: catalog.i18nc("@label","Profile:");
  231. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  232. font: UM.Theme.getFont("default");
  233. color: UM.Theme.getColor("text");
  234. }
  235. ToolButton
  236. {
  237. id: globalProfileSelection
  238. text: {
  239. var result = Cura.MachineManager.activeQualityName;
  240. if (Cura.MachineManager.activeQualityLayerHeight > 0) {
  241. result += " <font color=\"" + UM.Theme.getColor("text_detail") + "\">";
  242. result += " - ";
  243. result += Cura.MachineManager.activeQualityLayerHeight + "mm";
  244. result += "</font>";
  245. }
  246. return result;
  247. }
  248. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  249. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  250. height: UM.Theme.getSize("setting_control").height
  251. tooltip: Cura.MachineManager.activeQualityName
  252. style: UM.Theme.styles.sidebar_header_button
  253. activeFocusOnPress: true;
  254. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  255. menu: ProfileMenu { }
  256. UM.SimpleButton
  257. {
  258. id: customisedSettings
  259. visible: Cura.MachineManager.hasUserSettings
  260. height: parent.height * 0.6
  261. width: parent.height * 0.6
  262. anchors.verticalCenter: parent.verticalCenter
  263. anchors.right: parent.right
  264. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("default_margin").width
  265. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  266. iconSource: UM.Theme.getIcon("star");
  267. onClicked:
  268. {
  269. forceActiveFocus();
  270. Cura.Actions.manageProfiles.trigger()
  271. }
  272. onEntered:
  273. {
  274. 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.")
  275. base.showTooltip(globalProfileRow, Qt.point(0, globalProfileRow.height / 2), content)
  276. }
  277. onExited: base.hideTooltip()
  278. }
  279. }
  280. }
  281. UM.SettingPropertyProvider
  282. {
  283. id: machineExtruderCount
  284. containerStackId: Cura.MachineManager.activeMachineId
  285. key: "machine_extruder_count"
  286. watchedProperties: [ "value" ]
  287. storeIndex: 0
  288. }
  289. UM.I18nCatalog { id: catalog; name:"cura" }
  290. }