PrintSetupSelectorContents.qml 5.1 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.3
  5. import UM 1.3 as UM
  6. import Cura 1.0 as Cura
  7. import "Recommended"
  8. import "Custom"
  9. Item
  10. {
  11. id: popup
  12. width: UM.Theme.getSize("print_setup_widget").width - 2 * UM.Theme.getSize("default_margin").width
  13. height: childrenRect.height
  14. property int currentModeIndex: -1
  15. onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex)
  16. // Header of the popup
  17. Rectangle
  18. {
  19. id: header
  20. height: UM.Theme.getSize("print_setup_widget_header").height
  21. color: UM.Theme.getColor("secondary")
  22. anchors
  23. {
  24. top: parent.top
  25. right: parent.right
  26. left: parent.left
  27. }
  28. Label
  29. {
  30. id: headerLabel
  31. text: catalog.i18nc("@label", "Print settings")
  32. font: UM.Theme.getFont("default")
  33. renderType: Text.NativeRendering
  34. verticalAlignment: Text.AlignVCenter
  35. color: UM.Theme.getColor("text")
  36. height: parent.height
  37. anchors
  38. {
  39. topMargin: UM.Theme.getSize("default_margin").height
  40. left: parent.left
  41. leftMargin: UM.Theme.getSize("default_margin").height
  42. }
  43. }
  44. Button
  45. {
  46. id: closeButton
  47. width: UM.Theme.getSize("message_close").width
  48. height: UM.Theme.getSize("message_close").height
  49. anchors
  50. {
  51. right: parent.right
  52. rightMargin: UM.Theme.getSize("default_margin").width
  53. verticalCenter: parent.verticalCenter
  54. }
  55. contentItem: UM.RecolorImage
  56. {
  57. anchors.fill: parent
  58. sourceSize.width: width
  59. sourceSize.height: width
  60. color: UM.Theme.getColor("message_text")
  61. source: UM.Theme.getIcon("cross1")
  62. }
  63. background: Item {}
  64. onClicked: togglePopup() // Will hide the popup item
  65. }
  66. }
  67. Rectangle
  68. {
  69. id: topSeparator
  70. anchors.bottom: header.bottom
  71. width: parent.width
  72. height: UM.Theme.getSize("default_lining").height
  73. color: UM.Theme.getColor("lining")
  74. }
  75. Item
  76. {
  77. id: contents
  78. height: currentModeIndex == 0 ? recommendedPrintSetup.height : customPrintSetup.height
  79. anchors
  80. {
  81. top: header.bottom
  82. left: parent.left
  83. right: parent.right
  84. }
  85. RecommendedPrintSetup
  86. {
  87. id: recommendedPrintSetup
  88. anchors
  89. {
  90. left: parent.left
  91. right: parent.right
  92. top: parent.top
  93. }
  94. visible: currentModeIndex == 0
  95. }
  96. CustomPrintSetup
  97. {
  98. id: customPrintSetup
  99. anchors
  100. {
  101. left: parent.left
  102. right: parent.right
  103. top: parent.top
  104. }
  105. visible: currentModeIndex == 1
  106. }
  107. }
  108. Rectangle
  109. {
  110. id: buttonsSeparator
  111. anchors.top: contents.bottom
  112. width: parent.width
  113. height: UM.Theme.getSize("default_lining").height
  114. color: UM.Theme.getColor("lining")
  115. }
  116. Item
  117. {
  118. id: buttonRow
  119. property real padding: UM.Theme.getSize("default_margin").width
  120. height: childrenRect.height + 2 * padding
  121. // The buttonsSeparator is inside the buttonRow. This is to avoid some weird behaviours with the scroll bar.
  122. anchors
  123. {
  124. top: buttonsSeparator.top
  125. left: parent.left
  126. right: parent.right
  127. }
  128. Cura.SecondaryButton
  129. {
  130. anchors.top: parent.top
  131. anchors.left: parent.left
  132. anchors.margins: parent.padding
  133. leftPadding: UM.Theme.getSize("default_margin").width
  134. rightPadding: UM.Theme.getSize("default_margin").width
  135. text: catalog.i18nc("@button", "Recommended")
  136. iconSource: UM.Theme.getIcon("arrow_left")
  137. visible: currentModeIndex == 1
  138. onClicked: currentModeIndex = 0
  139. }
  140. Cura.SecondaryButton
  141. {
  142. anchors.top: parent.top
  143. anchors.right: parent.right
  144. anchors.margins: UM.Theme.getSize("default_margin").width
  145. leftPadding: UM.Theme.getSize("default_margin").width
  146. rightPadding: UM.Theme.getSize("default_margin").width
  147. text: catalog.i18nc("@button", "Custom")
  148. iconSource: UM.Theme.getIcon("arrow_right")
  149. iconOnRightSide: true
  150. visible: currentModeIndex == 0
  151. onClicked: currentModeIndex = 1
  152. }
  153. }
  154. Component.onCompleted:
  155. {
  156. var index = Math.round(UM.Preferences.getValue("cura/active_mode"))
  157. if(index != null && !isNaN(index))
  158. {
  159. currentModeIndex = index
  160. }
  161. else
  162. {
  163. currentModeIndex = 0
  164. }
  165. }
  166. }