SidebarHeader.qml 13 KB

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