ConfigurationMenu.qml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.0
  5. import QtQuick.Controls.Styles 1.4
  6. import QtQuick.Layouts 1.11
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. /**
  10. * Menu that allows you to select the configuration of the current printer, such
  11. * as the nozzle sizes and materials in each extruder.
  12. */
  13. Cura.ExpandableComponent
  14. {
  15. id: base
  16. Cura.ExtrudersModel
  17. {
  18. id: extrudersModel
  19. }
  20. UM.I18nCatalog
  21. {
  22. id: catalog
  23. name: "cura"
  24. }
  25. iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
  26. headerItem: Item
  27. {
  28. // Horizontal list that shows the extruders
  29. ListView
  30. {
  31. id: extrudersList
  32. orientation: ListView.Horizontal
  33. anchors.fill: parent
  34. model: extrudersModel
  35. delegate: Item
  36. {
  37. height: parent.height
  38. width: Math.round(ListView.view.width / extrudersModel.rowCount())
  39. // Extruder icon. Shows extruder index and has the same color as the active material.
  40. Cura.ExtruderIcon
  41. {
  42. id: extruderIcon
  43. materialColor: model.color
  44. extruderEnabled: model.enabled
  45. height: parent.height
  46. width: height
  47. }
  48. // Label for the brand of the material
  49. Label
  50. {
  51. id: brandNameLabel
  52. text: model.material_brand
  53. elide: Text.ElideRight
  54. font: UM.Theme.getFont("default")
  55. color: UM.Theme.getColor("text")
  56. anchors
  57. {
  58. left: extruderIcon.right
  59. leftMargin: UM.Theme.getSize("default_margin").width
  60. right: parent.right
  61. rightMargin: UM.Theme.getSize("default_margin").width
  62. }
  63. }
  64. // Label that shows the name of the material
  65. Label
  66. {
  67. text: model.material
  68. elide: Text.ElideRight
  69. font: UM.Theme.getFont("default")
  70. color: UM.Theme.getColor("text")
  71. anchors
  72. {
  73. left: extruderIcon.right
  74. leftMargin: UM.Theme.getSize("default_margin").width
  75. right: parent.right
  76. rightMargin: UM.Theme.getSize("default_margin").width
  77. top: brandNameLabel.bottom
  78. }
  79. }
  80. }
  81. }
  82. }
  83. popupItem: Column
  84. {
  85. id: popupItem
  86. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  87. height: implicitHeight //Required because ExpandableComponent will try to use this to determine the size of the background of the pop-up.
  88. spacing: UM.Theme.getSize("default_margin").height
  89. property var is_connected: false //If current machine is connected to a printer. Only evaluated upon making popup visible.
  90. onVisibleChanged:
  91. {
  92. is_connected = Cura.MachineManager.activeMachineNetworkKey !== "" && Cura.MachineManager.printerConnected //Re-evaluate.
  93. }
  94. property var configuration_method: is_connected ? "auto" : "custom" //Auto if connected to a printer at start-up, or Custom if not.
  95. Item
  96. {
  97. width: parent.width
  98. height: childrenRect.height
  99. AutoConfiguration
  100. {
  101. id: autoConfiguration
  102. visible: popupItem.configuration_method === "auto"
  103. }
  104. CustomConfiguration
  105. {
  106. id: customConfiguration
  107. visible: popupItem.configuration_method === "custom"
  108. }
  109. }
  110. Rectangle
  111. {
  112. id: separator
  113. visible: buttonBar.visible
  114. width: parent.width
  115. height: UM.Theme.getSize("default_lining").height
  116. color: UM.Theme.getColor("lining")
  117. }
  118. //Allow switching between custom and auto.
  119. Item
  120. {
  121. id: buttonBar
  122. visible: popupItem.is_connected //Switching only makes sense if the "auto" part is possible.
  123. width: parent.width
  124. height: childrenRect.height
  125. Cura.ActionButton
  126. {
  127. id: goToCustom
  128. visible: popupItem.configuration_method === "auto"
  129. text: catalog.i18nc("@label", "Custom")
  130. anchors
  131. {
  132. right: parent.right
  133. top: parent.top
  134. }
  135. color: UM.Theme.getColor("secondary")
  136. hoverColor: UM.Theme.getColor("secondary")
  137. textColor: UM.Theme.getColor("primary")
  138. textHoverColor: UM.Theme.getColor("text")
  139. iconSource: UM.Theme.getIcon("arrow_right")
  140. iconOnRightSide: true
  141. onClicked: popupItem.configuration_method = "custom"
  142. }
  143. Cura.ActionButton
  144. {
  145. id: goToAuto
  146. visible: popupItem.configuration_method === "custom"
  147. text: catalog.i18nc("@label", "Configurations")
  148. anchors
  149. {
  150. left: parent.left
  151. top: parent.top
  152. }
  153. color: UM.Theme.getColor("secondary")
  154. hoverColor: UM.Theme.getColor("secondary")
  155. textColor: UM.Theme.getColor("primary")
  156. textHoverColor: UM.Theme.getColor("text")
  157. iconSource: UM.Theme.getIcon("arrow_left")
  158. onClicked: popupItem.configuration_method = "auto"
  159. }
  160. }
  161. }
  162. }