SidebarHeader.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. // Copyright (c) 2017 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. property bool currentExtruderVisible: extrudersList.visible;
  14. spacing: UM.Theme.getSize("default_margin").height
  15. signal showTooltip(Item item, point location, string text)
  16. signal hideTooltip()
  17. Item
  18. {
  19. id: extruderSelectionRow
  20. width: parent.width
  21. height: UM.Theme.getSize("sidebar_tabs").height
  22. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  23. Rectangle
  24. {
  25. id: extruderSeparator
  26. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  27. width: parent.width
  28. height: parent.height
  29. color: UM.Theme.getColor("sidebar_lining")
  30. anchors.top: extruderSelectionRow.top
  31. }
  32. ListView
  33. {
  34. id: extrudersList
  35. property var index: 0
  36. height: UM.Theme.getSize("sidebar_header_mode_tabs").height
  37. width: parent.width
  38. boundsBehavior: Flickable.StopAtBounds
  39. anchors
  40. {
  41. left: parent.left
  42. right: parent.right
  43. bottom: extruderSelectionRow.bottom
  44. }
  45. ExclusiveGroup { id: extruderMenuGroup; }
  46. orientation: ListView.Horizontal
  47. model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: false }
  48. Connections
  49. {
  50. target: Cura.MachineManager
  51. onGlobalContainerChanged:
  52. {
  53. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  54. var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
  55. ExtruderManager.setActiveExtruderIndex(extruder_index);
  56. }
  57. }
  58. delegate: Button
  59. {
  60. height: ListView.view.height
  61. width: ListView.view.width / extrudersModel.rowCount()
  62. text: model.name
  63. tooltip: model.name
  64. exclusiveGroup: extruderMenuGroup
  65. checked: base.currentExtruderIndex == index
  66. onClicked:
  67. {
  68. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  69. ExtruderManager.setActiveExtruderIndex(index);
  70. }
  71. style: ButtonStyle
  72. {
  73. background: Rectangle
  74. {
  75. border.width: UM.Theme.getSize("default_lining").width
  76. border.color: control.checked ? UM.Theme.getColor("tab_checked_border") :
  77. control.pressed ? UM.Theme.getColor("tab_active_border") :
  78. control.hovered ? UM.Theme.getColor("tab_hovered_border") : UM.Theme.getColor("tab_unchecked_border")
  79. color: control.checked ? UM.Theme.getColor("tab_checked") :
  80. control.pressed ? UM.Theme.getColor("tab_active") :
  81. control.hovered ? UM.Theme.getColor("tab_hovered") : UM.Theme.getColor("tab_unchecked")
  82. Behavior on color { ColorAnimation { duration: 50; } }
  83. Rectangle
  84. {
  85. id: highlight
  86. visible: control.checked
  87. anchors.left: parent.left
  88. anchors.right: parent.right
  89. anchors.top: parent.top
  90. height: UM.Theme.getSize("sidebar_header_highlight").height
  91. color: UM.Theme.getColor("sidebar_header_bar")
  92. }
  93. Rectangle
  94. {
  95. id: swatch
  96. visible: index > -1
  97. height: UM.Theme.getSize("setting_control").height / 2
  98. width: height
  99. anchors.left: parent.left
  100. anchors.leftMargin: (parent.height - height) / 2
  101. anchors.verticalCenter: parent.verticalCenter
  102. color: model.color
  103. border.width: UM.Theme.getSize("default_lining").width
  104. border.color: UM.Theme.getColor("setting_control_border")
  105. }
  106. Text
  107. {
  108. anchors.verticalCenter: parent.verticalCenter
  109. anchors.left: swatch.visible ? swatch.right : parent.left
  110. anchors.leftMargin: swatch.visible ? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("default_margin").width
  111. anchors.right: parent.right
  112. anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2
  113. color: control.checked ? UM.Theme.getColor("tab_checked_text") :
  114. control.pressed ? UM.Theme.getColor("tab_active_text") :
  115. control.hovered ? UM.Theme.getColor("tab_hovered_text") : UM.Theme.getColor("tab_unchecked_text")
  116. font: UM.Theme.getFont("default")
  117. text: control.text
  118. elide: Text.ElideRight
  119. }
  120. }
  121. label: Item { }
  122. }
  123. }
  124. }
  125. }
  126. Item
  127. {
  128. id: variantRowSpacer
  129. height: UM.Theme.getSize("default_margin").height / 4
  130. width: height
  131. visible: !extruderSelectionRow.visible
  132. }
  133. // Material Row
  134. Item
  135. {
  136. id: materialRow
  137. height: UM.Theme.getSize("sidebar_setup").height
  138. visible: Cura.MachineManager.hasMaterials && !sidebar.monitoringPrint && !sidebar.hideSettings
  139. anchors
  140. {
  141. left: parent.left
  142. leftMargin: UM.Theme.getSize("default_margin").width
  143. right: parent.right
  144. rightMargin: UM.Theme.getSize("default_margin").width
  145. }
  146. Text
  147. {
  148. id: materialLabel
  149. text: catalog.i18nc("@label","Material");
  150. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  151. font: UM.Theme.getFont("default");
  152. color: UM.Theme.getColor("text");
  153. }
  154. ToolButton {
  155. id: materialSelection
  156. text: Cura.MachineManager.activeMaterialName
  157. tooltip: Cura.MachineManager.activeMaterialName
  158. visible: Cura.MachineManager.hasMaterials
  159. property var valueError:
  160. {
  161. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  162. if(data == "False")
  163. {
  164. return true
  165. }
  166. else
  167. {
  168. return false
  169. }
  170. }
  171. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  172. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  173. height: UM.Theme.getSize("setting_control").height
  174. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  175. anchors.right: parent.right
  176. style: UM.Theme.styles.sidebar_header_button
  177. activeFocusOnPress: true;
  178. menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
  179. }
  180. }
  181. // Print core row
  182. Item
  183. {
  184. id: printCoreRow
  185. height: UM.Theme.getSize("sidebar_setup").height
  186. visible: Cura.MachineManager.hasVariants && !sidebar.monitoringPrint && !sidebar.hideSettings
  187. anchors
  188. {
  189. left: parent.left
  190. leftMargin: UM.Theme.getSize("default_margin").width
  191. right: parent.right
  192. rightMargin: UM.Theme.getSize("default_margin").width
  193. }
  194. Text
  195. {
  196. id: printCoreLabel
  197. text: Cura.MachineManager.activeDefinitionVariantsName;
  198. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  199. font: UM.Theme.getFont("default");
  200. color: UM.Theme.getColor("text");
  201. }
  202. ToolButton {
  203. id: printCoreSelection
  204. text: Cura.MachineManager.activeVariantName
  205. tooltip: Cura.MachineManager.activeVariantName;
  206. visible: Cura.MachineManager.hasVariants
  207. height: UM.Theme.getSize("setting_control").height
  208. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  209. anchors.right: parent.right
  210. style: UM.Theme.styles.sidebar_header_button
  211. activeFocusOnPress: true;
  212. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  213. }
  214. }
  215. // Material info row
  216. Item
  217. {
  218. id: materialInfoRow
  219. height: UM.Theme.getSize("sidebar_setup").height
  220. visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings
  221. anchors
  222. {
  223. left: parent.left
  224. leftMargin: UM.Theme.getSize("default_margin").width
  225. right: parent.right
  226. rightMargin: UM.Theme.getSize("default_margin").width
  227. }
  228. Item
  229. {
  230. height: UM.Theme.getSize("sidebar_setup").height
  231. anchors.right: parent.right
  232. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  233. Text
  234. {
  235. id: materialInfoLabel
  236. wrapMode: Text.WordWrap
  237. text: catalog.i18nc("@label","Check material compability");
  238. font: UM.Theme.getFont("default");
  239. verticalAlignment: Text.AlignVCenter
  240. anchors.top: parent.top
  241. anchors.bottom: parent.bottom
  242. color:
  243. {
  244. if (!Cura.MachineManager.isActiveQualitySupported)
  245. {
  246. UM.Theme.getColor("setting_validation_error");
  247. }
  248. else
  249. {
  250. UM.Theme.getColor("text");
  251. }
  252. }
  253. MouseArea
  254. {
  255. anchors.fill: parent
  256. hoverEnabled: true
  257. onClicked:
  258. {
  259. // open the material URL with web browser
  260. var version = UM.Application.version;
  261. var machineName = Cura.MachineManager.activeMachine.definition.id;
  262. var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName;
  263. Qt.openUrlExternally(url);
  264. }
  265. onEntered:
  266. {
  267. var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com.");
  268. base.showTooltip(
  269. materialInfoRow,
  270. Qt.point(-UM.Theme.getSize("default_margin").width, 0),
  271. catalog.i18nc("@tooltip", content)
  272. );
  273. }
  274. onExited: base.hideTooltip();
  275. }
  276. }
  277. UM.RecolorImage
  278. {
  279. id: warningImage
  280. anchors.right: parent.right
  281. anchors.verticalCenter: parent.Bottom
  282. source: UM.Theme.getIcon("warning")
  283. width: UM.Theme.getSize("section_icon").width
  284. height: UM.Theme.getSize("section_icon").height
  285. //sourceSize.width: width + 5
  286. //sourceSize.height: width + 5
  287. color: UM.Theme.getColor("setting_control_text")
  288. visible: !Cura.MachineManager.isActiveQualitySupported
  289. }
  290. }
  291. }
  292. UM.SettingPropertyProvider
  293. {
  294. id: machineExtruderCount
  295. containerStackId: Cura.MachineManager.activeMachineId
  296. key: "machine_extruder_count"
  297. watchedProperties: [ "value" ]
  298. storeIndex: 0
  299. }
  300. UM.I18nCatalog { id: catalog; name:"cura" }
  301. }