SidebarHeader.qml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  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: Cura.ExtruderManager.activeExtruderIndex;
  13. property bool currentExtruderVisible: extrudersList.visible;
  14. property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
  15. spacing: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.9)
  16. signal showTooltip(Item item, point location, string text)
  17. signal hideTooltip()
  18. Item
  19. {
  20. anchors
  21. {
  22. left: parent.left
  23. right: parent.right
  24. }
  25. visible: extruderSelectionRow.visible
  26. height: UM.Theme.getSize("default_lining").height
  27. width: height
  28. }
  29. // Printer Type Row
  30. Item
  31. {
  32. id: printerTypeSelectionRow
  33. height: UM.Theme.getSize("sidebar_setup").height
  34. visible: printerConnected && !sidebar.monitoringPrint && !sidebar.hideSettings
  35. anchors
  36. {
  37. left: parent.left
  38. leftMargin: UM.Theme.getSize("sidebar_margin").width
  39. right: parent.right
  40. rightMargin: UM.Theme.getSize("sidebar_margin").width
  41. }
  42. Label
  43. {
  44. id: configurationLabel
  45. text: catalog.i18nc("@label", "Printer type");
  46. width: Math.round(parent.width * 0.4 - UM.Theme.getSize("default_margin").width)
  47. height: parent.height
  48. verticalAlignment: Text.AlignVCenter
  49. font: UM.Theme.getFont("default");
  50. color: UM.Theme.getColor("text");
  51. }
  52. ToolButton
  53. {
  54. id: printerTypeSelection
  55. text: catalog.i18nc("@label", "Printer type");
  56. height: UM.Theme.getSize("setting_control").height
  57. width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width
  58. anchors.right: parent.right
  59. style: UM.Theme.styles.sidebar_header_button
  60. activeFocusOnPress: true;
  61. menu: PrinterTypeMenu { }
  62. }
  63. }
  64. // Extruder Row
  65. Item
  66. {
  67. id: extruderSelectionRow
  68. width: parent.width
  69. height: Math.round(UM.Theme.getSize("sidebar_tabs").height * 2 / 3)
  70. visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint
  71. anchors
  72. {
  73. left: parent.left
  74. leftMargin: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.7)
  75. right: parent.right
  76. rightMargin: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.7)
  77. topMargin: UM.Theme.getSize("sidebar_margin").height
  78. }
  79. ListView
  80. {
  81. id: extrudersList
  82. property var index: 0
  83. height: UM.Theme.getSize("sidebar_header_mode_tabs").height
  84. width: Math.round(parent.width)
  85. boundsBehavior: Flickable.StopAtBounds
  86. anchors
  87. {
  88. left: parent.left
  89. leftMargin: Math.round(UM.Theme.getSize("default_margin").width / 2)
  90. right: parent.right
  91. rightMargin: Math.round(UM.Theme.getSize("default_margin").width / 2)
  92. verticalCenter: parent.verticalCenter
  93. }
  94. ExclusiveGroup { id: extruderMenuGroup; }
  95. orientation: ListView.Horizontal
  96. model: Cura.ExtrudersModel { id: extrudersModel; }
  97. Connections
  98. {
  99. target: Cura.MachineManager
  100. onGlobalContainerChanged: forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  101. }
  102. delegate: Button
  103. {
  104. height: ListView.view.height
  105. width: Math.round(ListView.view.width / extrudersModel.rowCount())
  106. text: model.name
  107. tooltip: model.name
  108. exclusiveGroup: extruderMenuGroup
  109. checked: base.currentExtruderIndex == index
  110. onClicked:
  111. {
  112. forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
  113. Cura.ExtruderManager.setActiveExtruderIndex(index);
  114. }
  115. style: ButtonStyle
  116. {
  117. background: Item
  118. {
  119. Rectangle
  120. {
  121. anchors.fill: parent
  122. border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width
  123. border.color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_border") :
  124. control.hovered ? UM.Theme.getColor("action_button_hovered_border") :
  125. UM.Theme.getColor("action_button_border")
  126. color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active") :
  127. control.hovered ? UM.Theme.getColor("action_button_hovered") :
  128. UM.Theme.getColor("action_button")
  129. Behavior on color { ColorAnimation { duration: 50; } }
  130. }
  131. Item
  132. {
  133. id: extruderButtonFace
  134. anchors.centerIn: parent
  135. width: {
  136. var extruderTextWidth = extruderStaticText.visible ? extruderStaticText.width : 0;
  137. var iconWidth = extruderIconItem.width;
  138. return Math.round(extruderTextWidth + iconWidth + UM.Theme.getSize("default_margin").width / 2);
  139. }
  140. // Static text "Extruder"
  141. Label
  142. {
  143. id: extruderStaticText
  144. anchors.verticalCenter: parent.verticalCenter
  145. anchors.left: parent.left
  146. color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
  147. control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
  148. UM.Theme.getColor("action_button_text")
  149. font: UM.Theme.getFont("large_nonbold")
  150. text: catalog.i18nc("@label", "Extruder")
  151. visible: width < (control.width - extruderIconItem.width - UM.Theme.getSize("default_margin").width)
  152. elide: Text.ElideRight
  153. }
  154. // Everthing for the extruder icon
  155. Item
  156. {
  157. id: extruderIconItem
  158. anchors.verticalCenter: parent.verticalCenter
  159. anchors.right: parent.right
  160. property var sizeToUse:
  161. {
  162. var minimumWidth = control.width < UM.Theme.getSize("button").width ? control.width : UM.Theme.getSize("button").width;
  163. var minimumHeight = control.height < UM.Theme.getSize("button").height ? control.height : UM.Theme.getSize("button").height;
  164. var minimumSize = minimumWidth < minimumHeight ? minimumWidth : minimumHeight;
  165. minimumSize -= Math.round(UM.Theme.getSize("default_margin").width / 2);
  166. return minimumSize;
  167. }
  168. width: sizeToUse
  169. height: sizeToUse
  170. UM.RecolorImage {
  171. id: mainCircle
  172. anchors.fill: parent
  173. sourceSize.width: parent.width
  174. sourceSize.height: parent.width
  175. source: UM.Theme.getIcon("extruder_button")
  176. color: extruderNumberText.color
  177. }
  178. Label
  179. {
  180. id: extruderNumberText
  181. anchors.centerIn: parent
  182. text: index + 1;
  183. color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_text") :
  184. control.hovered ? UM.Theme.getColor("action_button_hovered_text") :
  185. UM.Theme.getColor("action_button_text")
  186. font: UM.Theme.getFont("default_bold")
  187. }
  188. // Material colour circle
  189. // Only draw the filling colour of the material inside the SVG border.
  190. Rectangle
  191. {
  192. id: materialColorCircle
  193. anchors
  194. {
  195. right: parent.right
  196. top: parent.top
  197. rightMargin: Math.round(parent.sizeToUse * 0.01)
  198. topMargin: Math.round(parent.sizeToUse * 0.05)
  199. }
  200. color: model.color
  201. width: Math.round(parent.width * 0.35)
  202. height: Math.round(parent.height * 0.35)
  203. radius: Math.round(width / 2)
  204. border.width: 1
  205. border.color: UM.Theme.getColor("extruder_button_material_border")
  206. opacity: !control.checked ? 0.6 : 1.0
  207. }
  208. }
  209. }
  210. }
  211. label: Item {}
  212. }
  213. }
  214. }
  215. }
  216. Item
  217. {
  218. id: variantRowSpacer
  219. height: Math.round(UM.Theme.getSize("sidebar_margin").height / 4)
  220. width: height
  221. visible: !extruderSelectionRow.visible
  222. }
  223. // Material Row
  224. Item
  225. {
  226. id: materialRow
  227. height: UM.Theme.getSize("sidebar_setup").height
  228. visible: Cura.MachineManager.hasMaterials && !sidebar.monitoringPrint && !sidebar.hideSettings
  229. anchors
  230. {
  231. left: parent.left
  232. leftMargin: UM.Theme.getSize("sidebar_margin").width
  233. right: parent.right
  234. rightMargin: UM.Theme.getSize("sidebar_margin").width
  235. }
  236. Label
  237. {
  238. id: materialLabel
  239. text: catalog.i18nc("@label", "Material");
  240. width: Math.round(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
  241. height: parent.height
  242. verticalAlignment: Text.AlignVCenter
  243. font: UM.Theme.getFont("default");
  244. color: UM.Theme.getColor("text");
  245. }
  246. ToolButton
  247. {
  248. id: materialSelection
  249. property var currentRootMaterialName:
  250. {
  251. var materials = Cura.MachineManager.currentRootMaterialName;
  252. var materialName = "";
  253. if (base.currentExtruderIndex in materials) {
  254. materialName = materials[base.currentExtruderIndex];
  255. }
  256. return materialName;
  257. }
  258. text: currentRootMaterialName
  259. tooltip: currentRootMaterialName
  260. visible: Cura.MachineManager.hasMaterials
  261. enabled: !extrudersList.visible || base.currentExtruderIndex > -1
  262. height: UM.Theme.getSize("setting_control").height
  263. width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width
  264. anchors.right: parent.right
  265. style: UM.Theme.styles.sidebar_header_button
  266. activeFocusOnPress: true;
  267. menu: MaterialMenu {
  268. extruderIndex: base.currentExtruderIndex
  269. }
  270. property var valueError: !isMaterialSupported()
  271. property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
  272. function isMaterialSupported () {
  273. return Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible") == "True"
  274. }
  275. }
  276. }
  277. //Variant row
  278. Item
  279. {
  280. id: variantRow
  281. height: UM.Theme.getSize("sidebar_setup").height
  282. visible: Cura.MachineManager.hasVariants && !sidebar.monitoringPrint && !sidebar.hideSettings
  283. anchors
  284. {
  285. left: parent.left
  286. leftMargin: UM.Theme.getSize("sidebar_margin").width
  287. right: parent.right
  288. rightMargin: UM.Theme.getSize("sidebar_margin").width
  289. }
  290. Label
  291. {
  292. id: variantLabel
  293. text: Cura.MachineManager.activeDefinitionVariantsName;
  294. width: Math.round(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
  295. height: parent.height
  296. verticalAlignment: Text.AlignVCenter
  297. font: UM.Theme.getFont("default");
  298. color: UM.Theme.getColor("text");
  299. }
  300. ToolButton {
  301. id: variantSelection
  302. text: Cura.MachineManager.activeVariantName
  303. tooltip: Cura.MachineManager.activeVariantName;
  304. visible: Cura.MachineManager.hasVariants
  305. height: UM.Theme.getSize("setting_control").height
  306. width: Math.round(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
  307. anchors.right: parent.right
  308. style: UM.Theme.styles.sidebar_header_button
  309. activeFocusOnPress: true;
  310. menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
  311. }
  312. }
  313. //Buildplate row separator
  314. Rectangle {
  315. id: separator
  316. anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
  317. anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
  318. anchors.horizontalCenter: parent.horizontalCenter
  319. visible: buildplateRow.visible
  320. width: parent.width - UM.Theme.getSize("sidebar_margin").width * 2
  321. height: visible ? Math.floor(UM.Theme.getSize("sidebar_lining_thin").height / 2) : 0
  322. color: UM.Theme.getColor("sidebar_lining_thin")
  323. }
  324. //Buildplate row
  325. Item
  326. {
  327. id: buildplateRow
  328. height: UM.Theme.getSize("sidebar_setup").height
  329. visible: Cura.MachineManager.hasVariantBuildplates && !sidebar.monitoringPrint && !sidebar.hideSettings
  330. anchors
  331. {
  332. left: parent.left
  333. leftMargin: UM.Theme.getSize("sidebar_margin").width
  334. right: parent.right
  335. rightMargin: UM.Theme.getSize("sidebar_margin").width
  336. }
  337. Label
  338. {
  339. id: bulidplateLabel
  340. text: catalog.i18nc("@label", "Build plate");
  341. width: Math.floor(parent.width * 0.45 - UM.Theme.getSize("default_margin").width)
  342. height: parent.height
  343. verticalAlignment: Text.AlignVCenter
  344. font: UM.Theme.getFont("default");
  345. color: UM.Theme.getColor("text");
  346. }
  347. ToolButton {
  348. id: buildplateSelection
  349. text: Cura.MachineManager.activeVariantBuildplateName
  350. tooltip: Cura.MachineManager.activeVariantBuildplateName
  351. visible: Cura.MachineManager.hasVariantBuildplates
  352. height: UM.Theme.getSize("setting_control").height
  353. width: Math.floor(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
  354. anchors.right: parent.right
  355. style: UM.Theme.styles.sidebar_header_button
  356. activeFocusOnPress: true;
  357. menu: BuildplateMenu {}
  358. property var valueError: !Cura.MachineManager.variantBuildplateCompatible && !Cura.MachineManager.variantBuildplateUsable
  359. property var valueWarning: Cura.MachineManager.variantBuildplateUsable
  360. }
  361. }
  362. // Material info row
  363. Item
  364. {
  365. id: materialInfoRow
  366. height: Math.round(UM.Theme.getSize("sidebar_setup").height / 2)
  367. visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings
  368. anchors
  369. {
  370. left: parent.left
  371. leftMargin: UM.Theme.getSize("sidebar_margin").width
  372. right: parent.right
  373. rightMargin: UM.Theme.getSize("sidebar_margin").width
  374. }
  375. Item {
  376. height: UM.Theme.getSize("sidebar_setup").height
  377. anchors.right: parent.right
  378. width: Math.round(parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width)
  379. UM.RecolorImage {
  380. id: warningImage
  381. anchors.right: materialInfoLabel.left
  382. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  383. anchors.verticalCenter: parent.Bottom
  384. source: UM.Theme.getIcon("warning")
  385. width: UM.Theme.getSize("section_icon").width
  386. height: UM.Theme.getSize("section_icon").height
  387. color: UM.Theme.getColor("material_compatibility_warning")
  388. visible: !Cura.MachineManager.isCurrentSetupSupported
  389. }
  390. Label {
  391. id: materialInfoLabel
  392. wrapMode: Text.WordWrap
  393. text: "<a href='%1'>" + catalog.i18nc("@label", "Check compatibility") + "</a>"
  394. font: UM.Theme.getFont("default")
  395. color: UM.Theme.getColor("text")
  396. linkColor: UM.Theme.getColor("text_link")
  397. verticalAlignment: Text.AlignTop
  398. anchors.top: parent.top
  399. anchors.right: parent.right
  400. anchors.bottom: parent.bottom
  401. MouseArea {
  402. anchors.fill: parent
  403. hoverEnabled: true
  404. onClicked: {
  405. // open the material URL with web browser
  406. var version = UM.Application.version;
  407. var machineName = Cura.MachineManager.activeMachine.definition.id;
  408. var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName + "?utm_source=cura&utm_medium=software&utm_campaign=resources";
  409. Qt.openUrlExternally(url);
  410. }
  411. onEntered: {
  412. var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com.");
  413. base.showTooltip(
  414. materialInfoRow,
  415. Qt.point(-UM.Theme.getSize("sidebar_margin").width, 0),
  416. catalog.i18nc("@tooltip", content)
  417. );
  418. }
  419. onExited: base.hideTooltip();
  420. }
  421. }
  422. }
  423. }
  424. UM.SettingPropertyProvider
  425. {
  426. id: machineExtruderCount
  427. containerStackId: Cura.MachineManager.activeMachineId
  428. key: "machine_extruder_count"
  429. watchedProperties: [ "value" ]
  430. storeIndex: 0
  431. }
  432. UM.I18nCatalog { id: catalog; name:"cura" }
  433. }