SidebarHeader.qml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 totalHeightHeader: childrenRect.height
  13. property int currentExtruderIndex:ExtruderManager.activeExtruderIndex;
  14. spacing: UM.Theme.getSize("default_margin").height
  15. signal showTooltip(Item item, point location, string text)
  16. signal hideTooltip()
  17. Row
  18. {
  19. id: machineSelectionRow
  20. height: UM.Theme.getSize("sidebar_setup").height
  21. anchors
  22. {
  23. left: parent.left
  24. leftMargin: UM.Theme.getSize("default_margin").width
  25. right: parent.right
  26. rightMargin: UM.Theme.getSize("default_margin").width
  27. }
  28. Label
  29. {
  30. id: machineSelectionLabel
  31. text: catalog.i18nc("@label:listbox", "Printer:");
  32. anchors.verticalCenter: parent.verticalCenter
  33. font: UM.Theme.getFont("default");
  34. color: UM.Theme.getColor("text");
  35. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  36. }
  37. ToolButton
  38. {
  39. id: machineSelection
  40. text: Cura.MachineManager.activeMachineName;
  41. height: UM.Theme.getSize("setting_control").height
  42. tooltip: Cura.MachineManager.activeMachineName
  43. anchors.verticalCenter: parent.verticalCenter
  44. style: UM.Theme.styles.sidebar_header_button
  45. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  46. menu: PrinterMenu { }
  47. }
  48. }
  49. ListView
  50. {
  51. id: extrudersList
  52. property var index: 0
  53. visible: machineExtruderCount.properties.value > 1
  54. height: UM.Theme.getSize("sidebar_header_mode_toggle").height
  55. boundsBehavior: Flickable.StopAtBounds
  56. anchors
  57. {
  58. left: parent.left
  59. leftMargin: UM.Theme.getSize("default_margin").width
  60. right: parent.right
  61. rightMargin: UM.Theme.getSize("default_margin").width
  62. }
  63. ExclusiveGroup { id: extruderMenuGroup; }
  64. orientation: ListView.Horizontal
  65. model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: true }
  66. Connections
  67. {
  68. target: Cura.MachineManager
  69. onGlobalContainerChanged:
  70. {
  71. base.currentExtruderIndex = -1;
  72. forceActiveFocus()
  73. ExtruderManager.setActiveExtruderIndex(base.currentExtruderIndex);
  74. }
  75. }
  76. delegate: Button
  77. {
  78. height: ListView.view.height
  79. width: ListView.view.width / extrudersModel.rowCount()
  80. text: model.name
  81. tooltip: model.name
  82. exclusiveGroup: extruderMenuGroup
  83. checkable: true
  84. checked: base.currentExtruderIndex == index
  85. onClicked:
  86. {
  87. forceActiveFocus() //Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  88. base.currentExtruderIndex = index;
  89. ExtruderManager.setActiveExtruderIndex(index);
  90. }
  91. style: ButtonStyle
  92. {
  93. background: Rectangle
  94. {
  95. border.width: UM.Theme.getSize("default_lining").width
  96. border.color: control.checked ? UM.Theme.getColor("toggle_checked_border") :
  97. control.pressed ? UM.Theme.getColor("toggle_active_border") :
  98. control.hovered ? UM.Theme.getColor("toggle_hovered_border") : UM.Theme.getColor("toggle_unchecked_border")
  99. color: control.checked ? UM.Theme.getColor("toggle_checked") :
  100. control.pressed ? UM.Theme.getColor("toggle_active") :
  101. control.hovered ? UM.Theme.getColor("toggle_hovered") : UM.Theme.getColor("toggle_unchecked")
  102. Behavior on color { ColorAnimation { duration: 50; } }
  103. Rectangle
  104. {
  105. id: swatch
  106. visible: index > -1
  107. height: UM.Theme.getSize("setting_control").height / 2
  108. width: height
  109. anchors.left: parent.left
  110. anchors.leftMargin: (parent.height - height) / 2
  111. anchors.verticalCenter: parent.verticalCenter
  112. color: model.colour
  113. border.width: UM.Theme.getSize("default_lining").width
  114. border.color: UM.Theme.getColor("toggle_checked")
  115. }
  116. Label
  117. {
  118. anchors.verticalCenter: parent.verticalCenter
  119. anchors.left: swatch.visible ? swatch.right : parent.left
  120. anchors.leftMargin: swatch.visible ? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("default_margin").width
  121. anchors.right: parent.right
  122. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  123. color: control.checked ? UM.Theme.getColor("toggle_checked_text") :
  124. control.pressed ? UM.Theme.getColor("toggle_active_text") :
  125. control.hovered ? UM.Theme.getColor("toggle_hovered_text") : UM.Theme.getColor("toggle_unchecked_text")
  126. font: UM.Theme.getFont("default")
  127. text: control.text
  128. elide: Text.ElideRight
  129. }
  130. }
  131. label: Item { }
  132. }
  133. }
  134. }
  135. Row
  136. {
  137. id: variantRow
  138. height: UM.Theme.getSize("sidebar_setup").height
  139. visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
  140. anchors
  141. {
  142. left: parent.left
  143. leftMargin: UM.Theme.getSize("default_margin").width
  144. right: parent.right
  145. rightMargin: UM.Theme.getSize("default_margin").width
  146. }
  147. Label
  148. {
  149. id: variantLabel
  150. text: (Cura.MachineManager.hasVariants && Cura.MachineManager.hasMaterials) ? catalog.i18nc("@label","Nozzle & Material:"):
  151. Cura.MachineManager.hasVariants ? catalog.i18nc("@label","Nozzle:") : catalog.i18nc("@label","Material:");
  152. anchors.verticalCenter: parent.verticalCenter
  153. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  154. font: UM.Theme.getFont("default");
  155. color: UM.Theme.getColor("text");
  156. }
  157. Rectangle
  158. {
  159. anchors.verticalCenter: parent.verticalCenter
  160. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  161. height: UM.Theme.getSize("setting_control").height
  162. ToolButton {
  163. id: variantSelection
  164. text: Cura.MachineManager.activeVariantName
  165. tooltip: Cura.MachineManager.activeVariantName;
  166. visible: Cura.MachineManager.hasVariants
  167. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  168. height: UM.Theme.getSize("setting_control").height
  169. width: materialSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  170. anchors.left: parent.left
  171. style: UM.Theme.styles.sidebar_header_button
  172. menu: NozzleMenu { }
  173. }
  174. ToolButton {
  175. id: materialSelection
  176. text: Cura.MachineManager.activeMaterialName
  177. tooltip: Cura.MachineManager.activeMaterialName
  178. visible: Cura.MachineManager.hasMaterials
  179. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  180. height: UM.Theme.getSize("setting_control").height
  181. width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  182. anchors.right: parent.right
  183. style: UM.Theme.styles.sidebar_header_button
  184. menu: MaterialMenu { }
  185. }
  186. }
  187. }
  188. Row
  189. {
  190. id: globalProfileRow
  191. height: UM.Theme.getSize("sidebar_setup").height
  192. anchors
  193. {
  194. left: parent.left
  195. leftMargin: UM.Theme.getSize("default_margin").width
  196. right: parent.right
  197. rightMargin: UM.Theme.getSize("default_margin").width
  198. }
  199. Label
  200. {
  201. id: globalProfileLabel
  202. text: catalog.i18nc("@label","Profile:");
  203. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  204. font: UM.Theme.getFont("default");
  205. color: UM.Theme.getColor("text");
  206. }
  207. ToolButton
  208. {
  209. id: globalProfileSelection
  210. text: Cura.MachineManager.activeQualityName
  211. width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width
  212. height: UM.Theme.getSize("setting_control").height
  213. tooltip: Cura.MachineManager.activeQualityName
  214. style: UM.Theme.styles.sidebar_header_button
  215. menu: ProfileMenu { }
  216. UM.SimpleButton
  217. {
  218. id: customisedSettings
  219. visible: Cura.MachineManager.hasUserSettings
  220. height: parent.height * 0.6
  221. width: parent.height * 0.6
  222. anchors.verticalCenter: parent.verticalCenter
  223. anchors.right: parent.right
  224. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("default_margin").width
  225. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button");
  226. iconSource: UM.Theme.getIcon("star");
  227. onClicked: Cura.Actions.manageProfiles.trigger()
  228. onEntered:
  229. {
  230. var content = catalog.i18nc("@tooltip","Some setting values are different from the values stored in the profile.\n\nClick to open the profile manager.")
  231. base.showTooltip(globalProfileRow, Qt.point(0, globalProfileRow.height / 2), content)
  232. }
  233. onExited: base.hideTooltip()
  234. }
  235. }
  236. }
  237. UM.SettingPropertyProvider
  238. {
  239. id: machineExtruderCount
  240. containerStackId: Cura.MachineManager.activeMachineId
  241. key: "machine_extruder_count"
  242. watchedProperties: [ "value" ]
  243. storeIndex: 0
  244. }
  245. UM.I18nCatalog { id: catalog; name:"cura" }
  246. }