RecommendedQualityProfileSelector.qml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.5 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. UM.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. elide: Text.ElideRight
  106. }
  107. Cura.RadioCheckbar
  108. {
  109. anchors
  110. {
  111. left: intentCategoryLabel.right
  112. right: parent.right
  113. }
  114. dataModel: model["qualities"]
  115. buttonGroup: activeProfileButtonGroup
  116. function checkedFunction(modelItem)
  117. {
  118. if(Cura.MachineManager.hasCustomQuality)
  119. {
  120. // When user created profile is active, no quality tickbox should be active.
  121. return false
  122. }
  123. if(modelItem === null)
  124. {
  125. return false
  126. }
  127. return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
  128. }
  129. isCheckedFunction: checkedFunction
  130. }
  131. MouseArea // Intent description tooltip hover area
  132. {
  133. id: intentDescriptionHoverArea
  134. anchors.fill: parent
  135. hoverEnabled: true
  136. enabled: model.description !== undefined
  137. acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
  138. Timer
  139. {
  140. id: intentTooltipTimer
  141. interval: 500
  142. running: false
  143. repeat: false
  144. onTriggered: base.showTooltip(
  145. intentCategoryLabel,
  146. Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0),
  147. model.description
  148. )
  149. }
  150. onEntered: intentTooltipTimer.start()
  151. onExited:
  152. {
  153. base.hideTooltip()
  154. intentTooltipTimer.stop()
  155. }
  156. }
  157. NoIntentIcon // This icon has hover priority over intentDescriptionHoverArea, so draw it above it.
  158. {
  159. affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
  160. intent_type: model.name
  161. anchors.right: intentCategoryLabel.right
  162. anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
  163. width: intentCategoryLabel.height * 0.75
  164. anchors.verticalCenter: parent.verticalCenter
  165. height: width
  166. visible: Cura.MachineManager.activeIntentCategory == model.intent_category && affected_extruders.length
  167. }
  168. }
  169. }
  170. }
  171. }