RecommendedQualityProfileSelector.qml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.2 as UM
  6. import Cura 1.6 as Cura
  7. import ".."
  8. Item
  9. {
  10. id: qualityRow
  11. height: childrenRect.height
  12. property real labelColumnWidth: Math.round(width / 3)
  13. property real settingsColumnWidth: width - labelColumnWidth
  14. // Here are the elements that are shown in the left column
  15. Column
  16. {
  17. anchors
  18. {
  19. left: parent.left
  20. right: parent.right
  21. }
  22. spacing: UM.Theme.getSize("default_margin").height
  23. ButtonGroup
  24. {
  25. id: activeProfileButtonGroup
  26. exclusive: true
  27. onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
  28. }
  29. Item
  30. {
  31. height: childrenRect.height
  32. anchors
  33. {
  34. left: parent.left
  35. right: parent.right
  36. }
  37. Cura.IconWithText
  38. {
  39. id: profileLabel
  40. source: UM.Theme.getIcon("PrintQuality")
  41. text: catalog.i18nc("@label", "Profiles")
  42. font: UM.Theme.getFont("medium")
  43. width: labelColumnWidth
  44. iconSize: UM.Theme.getSize("medium_button_icon").width
  45. }
  46. UM.SimpleButton
  47. {
  48. id: resetToDefaultQualityButton
  49. visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
  50. height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
  51. width: height
  52. anchors
  53. {
  54. right: profileLabel.right
  55. rightMargin: UM.Theme.getSize("default_margin").width
  56. leftMargin: UM.Theme.getSize("default_margin").width
  57. verticalCenter: parent.verticalCenter
  58. }
  59. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
  60. iconSource: UM.Theme.getIcon("ArrowReset")
  61. onClicked:
  62. {
  63. // if the current profile is user-created, switch to a built-in quality
  64. Cura.MachineManager.resetToUseDefaultQuality()
  65. }
  66. onEntered:
  67. {
  68. var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
  69. base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
  70. }
  71. onExited: base.hideTooltip()
  72. }
  73. Cura.LabelBar
  74. {
  75. id: labelbar
  76. anchors
  77. {
  78. left: profileLabel.right
  79. right: parent.right
  80. verticalCenter: profileLabel.verticalCenter
  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. }