RecommendedQualityProfileSelector.qml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls 2.3 as Controls2
  6. import QtQuick.Controls.Styles 1.4
  7. import UM 1.2 as UM
  8. import Cura 1.6 as Cura
  9. import ".."
  10. Item
  11. {
  12. id: qualityRow
  13. height: childrenRect.height
  14. property real labelColumnWidth: Math.round(width / 3)
  15. property real settingsColumnWidth: width - labelColumnWidth
  16. // Here are the elements that are shown in the left column
  17. Column
  18. {
  19. anchors
  20. {
  21. left: parent.left
  22. right: parent.right
  23. }
  24. spacing: UM.Theme.getSize("default_margin").height
  25. Controls2.ButtonGroup
  26. {
  27. id: activeProfileButtonGroup
  28. exclusive: true
  29. onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
  30. }
  31. Item
  32. {
  33. height: childrenRect.height
  34. anchors
  35. {
  36. left: parent.left
  37. right: parent.right
  38. }
  39. Cura.IconWithText
  40. {
  41. id: profileLabel
  42. source: UM.Theme.getIcon("category_layer_height")
  43. text: catalog.i18nc("@label", "Profiles")
  44. font: UM.Theme.getFont("medium")
  45. width: labelColumnWidth
  46. }
  47. UM.SimpleButton
  48. {
  49. id: resetToDefaultQualityButton
  50. visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
  51. height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
  52. width: height
  53. anchors
  54. {
  55. right: profileLabel.right
  56. rightMargin: UM.Theme.getSize("default_margin").width
  57. leftMargin: UM.Theme.getSize("default_margin").width
  58. verticalCenter: parent.verticalCenter
  59. }
  60. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
  61. iconSource: UM.Theme.getIcon("reset")
  62. onClicked:
  63. {
  64. // if the current profile is user-created, switch to a built-in quality
  65. Cura.MachineManager.resetToUseDefaultQuality()
  66. }
  67. onEntered:
  68. {
  69. var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
  70. base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
  71. }
  72. onExited: base.hideTooltip()
  73. }
  74. Cura.LabelBar
  75. {
  76. id: labelbar
  77. anchors
  78. {
  79. left: profileLabel.right
  80. right: parent.right
  81. }
  82. model: Cura.QualityProfilesDropDownMenuModel
  83. modelKey: "layer_height"
  84. }
  85. }
  86. Repeater
  87. {
  88. model: Cura.IntentCategoryModel {}
  89. Item
  90. {
  91. anchors
  92. {
  93. left: parent.left
  94. right: parent.right
  95. }
  96. height: intentCategoryLabel.height
  97. Label
  98. {
  99. id: intentCategoryLabel
  100. text: model.name
  101. width: labelColumnWidth - UM.Theme.getSize("section_icon").width
  102. anchors.left: parent.left
  103. anchors.leftMargin: UM.Theme.getSize("section_icon").width + UM.Theme.getSize("narrow_margin").width
  104. font: UM.Theme.getFont("medium")
  105. color: UM.Theme.getColor("text")
  106. renderType: Text.NativeRendering
  107. elide: Text.ElideRight
  108. }
  109. Cura.RadioCheckbar
  110. {
  111. anchors
  112. {
  113. left: intentCategoryLabel.right
  114. right: parent.right
  115. }
  116. dataModel: model["qualities"]
  117. buttonGroup: activeProfileButtonGroup
  118. function checkedFunction(modelItem)
  119. {
  120. if(Cura.MachineManager.hasCustomQuality)
  121. {
  122. // When user created profile is active, no quality tickbox should be active.
  123. return false
  124. }
  125. if(modelItem === null)
  126. {
  127. return false
  128. }
  129. return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
  130. }
  131. isCheckedFunction: checkedFunction
  132. }
  133. MouseArea // Intent description tooltip hover area
  134. {
  135. id: intentDescriptionHoverArea
  136. anchors.fill: parent
  137. hoverEnabled: true
  138. enabled: model.description !== undefined
  139. acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
  140. Timer
  141. {
  142. id: intentTooltipTimer
  143. interval: 500
  144. running: false
  145. repeat: false
  146. onTriggered: base.showTooltip(
  147. intentCategoryLabel,
  148. Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0),
  149. model.description
  150. )
  151. }
  152. onEntered: intentTooltipTimer.start()
  153. onExited:
  154. {
  155. base.hideTooltip()
  156. intentTooltipTimer.stop()
  157. }
  158. }
  159. NoIntentIcon // This icon has hover priority over intentDescriptionHoverArea, so draw it above it.
  160. {
  161. affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
  162. intent_type: model.name
  163. anchors.right: intentCategoryLabel.right
  164. anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
  165. width: intentCategoryLabel.height * 0.75
  166. anchors.verticalCenter: parent.verticalCenter
  167. height: width
  168. visible: Cura.MachineManager.activeIntentCategory == model.intent_category && affected_extruders.length
  169. }
  170. }
  171. }
  172. }
  173. }