SidebarHeader.qml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. // Print core row
  134. Item
  135. {
  136. id: printCoreRow
  137. height: UM.Theme.getSize("sidebar_setup").height
  138. visible: Cura.MachineManager.hasVariants && !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: printCoreLabel
  149. text: Cura.MachineManager.activeDefinitionVariantsName;
  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: printCoreSelection
  156. text: Cura.MachineManager.activeVariantName
  157. tooltip: Cura.MachineManager.activeVariantName;
  158. visible: Cura.MachineManager.hasVariants
  159. height: UM.Theme.getSize("setting_control").height
  160. width: parent.width * 0.7 + UM.Theme.getSize("default_margin").width
  161. anchors.right: parent.right
  162. style: UM.Theme.styles.sidebar_header_button
  163. activeFocusOnPress: true;
  164. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  165. }
  166. }
  167. // Material Row
  168. Item
  169. {
  170. id: materialRow
  171. height: UM.Theme.getSize("sidebar_setup").height
  172. visible: Cura.MachineManager.hasMaterials && !sidebar.monitoringPrint && !sidebar.hideSettings
  173. anchors
  174. {
  175. left: parent.left
  176. leftMargin: UM.Theme.getSize("default_margin").width
  177. right: parent.right
  178. rightMargin: UM.Theme.getSize("default_margin").width
  179. }
  180. Text
  181. {
  182. id: materialLabel
  183. text: catalog.i18nc("@label","Material");
  184. width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width
  185. font: UM.Theme.getFont("default");
  186. color: UM.Theme.getColor("text");
  187. }
  188. ToolButton {
  189. id: materialSelection
  190. text: Cura.MachineManager.activeMaterialName
  191. tooltip: Cura.MachineManager.activeMaterialName
  192. visible: Cura.MachineManager.hasMaterials
  193. property var valueError:
  194. {
  195. var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible")
  196. if(data == "False")
  197. {
  198. return true
  199. }
  200. else
  201. {
  202. return false
  203. }
  204. }
  205. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  206. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  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: MaterialMenu { 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: UM.Theme.getColor("text")
  243. MouseArea
  244. {
  245. anchors.fill: parent
  246. hoverEnabled: true
  247. onClicked:
  248. {
  249. // open the material URL with web browser
  250. var version = UM.Application.version;
  251. var machineName = Cura.MachineManager.activeMachine.definition.id;
  252. var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName;
  253. Qt.openUrlExternally(url);
  254. }
  255. onEntered:
  256. {
  257. var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com.");
  258. base.showTooltip(
  259. materialInfoRow,
  260. Qt.point(-UM.Theme.getSize("default_margin").width, 0),
  261. catalog.i18nc("@tooltip", content)
  262. );
  263. }
  264. onExited: base.hideTooltip();
  265. }
  266. }
  267. UM.RecolorImage
  268. {
  269. id: warningImage
  270. anchors.right: parent.right
  271. anchors.verticalCenter: parent.Bottom
  272. source: UM.Theme.getIcon("warning")
  273. width: UM.Theme.getSize("section_icon").width
  274. height: UM.Theme.getSize("section_icon").height
  275. //sourceSize.width: width + 5
  276. //sourceSize.height: width + 5
  277. color: UM.Theme.getColor("setting_validation_warning")
  278. visible: !Cura.MachineManager.isActiveQualitySupported
  279. }
  280. }
  281. }
  282. UM.SettingPropertyProvider
  283. {
  284. id: machineExtruderCount
  285. containerStackId: Cura.MachineManager.activeMachineId
  286. key: "machine_extruder_count"
  287. watchedProperties: [ "value" ]
  288. storeIndex: 0
  289. }
  290. UM.I18nCatalog { id: catalog; name:"cura" }
  291. }