SidebarHeader.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. 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
  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 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. }