SidebarHeader.qml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. Row
  17. {
  18. id: machineSelectionRow
  19. height: UM.Theme.getSize("sidebar_setup").height
  20. anchors
  21. {
  22. left: parent.left
  23. leftMargin: UM.Theme.getSize("default_margin").width
  24. right: parent.right
  25. rightMargin: UM.Theme.getSize("default_margin").width
  26. }
  27. Label
  28. {
  29. id: machineSelectionLabel
  30. text: catalog.i18nc("@label:listbox", "Printer:");
  31. anchors.verticalCenter: parent.verticalCenter
  32. font: UM.Theme.getFont("default");
  33. color: UM.Theme.getColor("text");
  34. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  35. }
  36. ToolButton
  37. {
  38. id: machineSelection
  39. text: Cura.MachineManager.activeMachineName;
  40. height: UM.Theme.getSize("setting_control").height
  41. tooltip: Cura.MachineManager.activeMachineName
  42. anchors.verticalCenter: parent.verticalCenter
  43. style: UM.Theme.styles.sidebar_header_button
  44. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  45. menu: PrinterMenu { }
  46. }
  47. }
  48. ListView
  49. {
  50. id: extrudersList
  51. property var index: 0
  52. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  53. height: UM.Theme.getSize("sidebar_header_mode_toggle").height
  54. boundsBehavior: Flickable.StopAtBounds
  55. anchors
  56. {
  57. left: parent.left
  58. leftMargin: UM.Theme.getSize("default_margin").width
  59. right: parent.right
  60. rightMargin: UM.Theme.getSize("default_margin").width
  61. }
  62. ExclusiveGroup { id: extruderMenuGroup; }
  63. orientation: ListView.Horizontal
  64. model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: false }
  65. Connections
  66. {
  67. target: Cura.MachineManager
  68. onGlobalContainerChanged:
  69. {
  70. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  71. var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
  72. ExtruderManager.setActiveExtruderIndex(extruder_index);
  73. }
  74. }
  75. delegate: Button
  76. {
  77. height: ListView.view.height
  78. width: ListView.view.width / extrudersModel.rowCount()
  79. text: model.name
  80. tooltip: model.name
  81. exclusiveGroup: extruderMenuGroup
  82. checked: base.currentExtruderIndex == index
  83. onClicked:
  84. {
  85. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  86. ExtruderManager.setActiveExtruderIndex(index);
  87. }
  88. style: ButtonStyle
  89. {
  90. background: Rectangle
  91. {
  92. border.width: UM.Theme.getSize("default_lining").width
  93. border.color: control.checked ? UM.Theme.getColor("toggle_checked_border") :
  94. control.pressed ? UM.Theme.getColor("toggle_active_border") :
  95. control.hovered ? UM.Theme.getColor("toggle_hovered_border") : UM.Theme.getColor("toggle_unchecked_border")
  96. color: control.checked ? UM.Theme.getColor("toggle_checked") :
  97. control.pressed ? UM.Theme.getColor("toggle_active") :
  98. control.hovered ? UM.Theme.getColor("toggle_hovered") : UM.Theme.getColor("toggle_unchecked")
  99. Behavior on color { ColorAnimation { duration: 50; } }
  100. Rectangle
  101. {
  102. id: swatch
  103. visible: index > -1
  104. height: UM.Theme.getSize("setting_control").height / 2
  105. width: height
  106. anchors.left: parent.left
  107. anchors.leftMargin: (parent.height - height) / 2
  108. anchors.verticalCenter: parent.verticalCenter
  109. color: model.color
  110. border.width: UM.Theme.getSize("default_lining").width
  111. border.color: UM.Theme.getColor("toggle_checked")
  112. }
  113. Label
  114. {
  115. anchors.verticalCenter: parent.verticalCenter
  116. anchors.left: swatch.visible ? swatch.right : parent.left
  117. anchors.leftMargin: swatch.visible ? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("default_margin").width
  118. anchors.right: parent.right
  119. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  120. color: control.checked ? UM.Theme.getColor("toggle_checked_text") :
  121. control.pressed ? UM.Theme.getColor("toggle_active_text") :
  122. control.hovered ? UM.Theme.getColor("toggle_hovered_text") : UM.Theme.getColor("toggle_unchecked_text")
  123. font: UM.Theme.getFont("default")
  124. text: control.text
  125. elide: Text.ElideRight
  126. }
  127. }
  128. label: Item { }
  129. }
  130. }
  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
  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. Rectangle
  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. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  185. }
  186. ToolButton {
  187. id: materialSelection
  188. text: Cura.MachineManager.activeMaterialName
  189. tooltip: Cura.MachineManager.activeMaterialName
  190. visible: Cura.MachineManager.hasMaterials
  191. property var valueError:
  192. {
  193. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  194. if(data == "False")
  195. {
  196. return true
  197. }
  198. else
  199. {
  200. return false
  201. }
  202. }
  203. property var valueWarning: Cura.MachineManager.activeQualityContainerId == "empty_quality"
  204. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  205. height: UM.Theme.getSize("setting_control").height
  206. width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  207. anchors.right: parent.right
  208. style: UM.Theme.styles.sidebar_header_button
  209. menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
  210. }
  211. }
  212. }
  213. Row
  214. {
  215. id: globalProfileRow
  216. height: UM.Theme.getSize("sidebar_setup").height
  217. visible: !sidebar.monitoringPrint
  218. anchors
  219. {
  220. left: parent.left
  221. leftMargin: UM.Theme.getSize("default_margin").width
  222. right: parent.right
  223. rightMargin: UM.Theme.getSize("default_margin").width
  224. }
  225. Label
  226. {
  227. id: globalProfileLabel
  228. text: catalog.i18nc("@label","Profile:");
  229. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  230. font: UM.Theme.getFont("default");
  231. color: UM.Theme.getColor("text");
  232. }
  233. ToolButton
  234. {
  235. id: globalProfileSelection
  236. text: Cura.MachineManager.activeQualityName
  237. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  238. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  239. height: UM.Theme.getSize("setting_control").height
  240. tooltip: Cura.MachineManager.activeQualityName
  241. style: UM.Theme.styles.sidebar_header_button
  242. property var valueWarning: Cura.MachineManager.activeQualityId == "empty_quality"
  243. menu: ProfileMenu { }
  244. UM.SimpleButton
  245. {
  246. id: customisedSettings
  247. visible: Cura.MachineManager.hasUserSettings
  248. height: parent.height * 0.6
  249. width: parent.height * 0.6
  250. anchors.verticalCenter: parent.verticalCenter
  251. anchors.right: parent.right
  252. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("default_margin").width
  253. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  254. iconSource: UM.Theme.getIcon("star");
  255. onClicked: Cura.Actions.manageProfiles.trigger()
  256. onEntered:
  257. {
  258. var content = catalog.i18nc("@tooltip","Some setting values are different from the values stored in the profile.\n\nClick to open the profile manager.")
  259. base.showTooltip(globalProfileRow, Qt.point(0, globalProfileRow.height / 2), content)
  260. }
  261. onExited: base.hideTooltip()
  262. }
  263. }
  264. }
  265. UM.SettingPropertyProvider
  266. {
  267. id: machineExtruderCount
  268. containerStackId: Cura.MachineManager.activeMachineId
  269. key: "machine_extruder_count"
  270. watchedProperties: [ "value" ]
  271. storeIndex: 0
  272. }
  273. UM.I18nCatalog { id: catalog; name:"cura" }
  274. }