ConfigurationMenu.qml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: Item
  84. {
  85. id: popup
  86. width: base.width - 2 * UM.Theme.getSize("default_margin").width
  87. height: 200
  88. property var configuration_method: "auto"
  89. AutoConfiguration
  90. {
  91. id: autoConfiguration
  92. visible: popup.configuration_method === "auto"
  93. anchors.top: header.bottom
  94. height: visible ? childrenRect.height : 0
  95. }
  96. CustomConfiguration
  97. {
  98. id: customConfiguration
  99. visible: popup.configuration_method === "custom"
  100. anchors.top: header.bottom
  101. height: visible ? childrenRect.height : 0
  102. }
  103. Rectangle
  104. {
  105. id: separator
  106. anchors
  107. {
  108. left: parent.left
  109. right: parent.right
  110. bottom: buttonBar.top
  111. bottomMargin: UM.Theme.getSize("default_margin").height
  112. }
  113. height: UM.Theme.getSize("default_lining").height
  114. color: UM.Theme.getColor("lining")
  115. }
  116. Rectangle
  117. {
  118. id: buttonBar
  119. anchors
  120. {
  121. left: parent.left
  122. right: parent.right
  123. bottom: parent.bottom
  124. }
  125. height: childrenRect.height
  126. Cura.ActionButton
  127. {
  128. id: goToCustom
  129. visible: popup.configuration_method === "auto"
  130. text: catalog.i18nc("@label", "Custom")
  131. anchors
  132. {
  133. right: parent.right
  134. bottom: parent.bottom
  135. }
  136. color: UM.Theme.getColor("secondary")
  137. hoverColor: UM.Theme.getColor("secondary")
  138. textColor: UM.Theme.getColor("primary")
  139. textHoverColor: UM.Theme.getColor("text")
  140. height: UM.Theme.getSize("action_panel_button").height
  141. leftPadding: UM.Theme.getSize("default_margin").width
  142. rightPadding: UM.Theme.getSize("default_margin").width
  143. onClicked: popup.configuration_method = "custom"
  144. }
  145. Cura.ActionButton
  146. {
  147. id: goToAuto
  148. visible: popup.configuration_method === "custom"
  149. text: catalog.i18nc("@label", "Configurations")
  150. anchors
  151. {
  152. left: parent.left
  153. bottom: parent.bottom
  154. }
  155. color: UM.Theme.getColor("secondary")
  156. hoverColor: UM.Theme.getColor("secondary")
  157. textColor: UM.Theme.getColor("primary")
  158. textHoverColor: UM.Theme.getColor("text")
  159. height: UM.Theme.getSize("action_panel_button").height
  160. leftPadding: UM.Theme.getSize("default_margin").width
  161. rightPadding: UM.Theme.getSize("default_margin").width
  162. onClicked: popup.configuration_method = "auto"
  163. }
  164. }
  165. }
  166. }