RecommendedQualityProfileSelector.qml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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("PrintQuality")
  43. text: catalog.i18nc("@label", "Profiles")
  44. font: UM.Theme.getFont("medium")
  45. width: labelColumnWidth
  46. iconSize: UM.Theme.getSize("medium_button_icon").width
  47. }
  48. UM.SimpleButton
  49. {
  50. id: resetToDefaultQualityButton
  51. visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
  52. height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
  53. width: height
  54. anchors
  55. {
  56. right: profileLabel.right
  57. rightMargin: UM.Theme.getSize("default_margin").width
  58. leftMargin: UM.Theme.getSize("default_margin").width
  59. verticalCenter: parent.verticalCenter
  60. }
  61. color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
  62. iconSource: UM.Theme.getIcon("ArrowReset")
  63. onClicked:
  64. {
  65. // if the current profile is user-created, switch to a built-in quality
  66. Cura.MachineManager.resetToUseDefaultQuality()
  67. }
  68. onEntered:
  69. {
  70. var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
  71. base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
  72. }
  73. onExited: base.hideTooltip()
  74. }
  75. Cura.LabelBar
  76. {
  77. id: labelbar
  78. anchors
  79. {
  80. left: profileLabel.right
  81. right: parent.right
  82. verticalCenter: profileLabel.verticalCenter
  83. }
  84. model: Cura.QualityProfilesDropDownMenuModel
  85. modelKey: "layer_height"
  86. }
  87. }
  88. Repeater
  89. {
  90. model: Cura.IntentCategoryModel {}
  91. Item
  92. {
  93. anchors
  94. {
  95. left: parent.left
  96. right: parent.right
  97. }
  98. height: intentCategoryLabel.height
  99. Label
  100. {
  101. id: intentCategoryLabel
  102. text: model.name
  103. width: labelColumnWidth - UM.Theme.getSize("section_icon").width
  104. anchors.left: parent.left
  105. anchors.leftMargin: UM.Theme.getSize("section_icon").width + UM.Theme.getSize("narrow_margin").width
  106. font: UM.Theme.getFont("medium")
  107. color: UM.Theme.getColor("text")
  108. renderType: Text.NativeRendering
  109. elide: Text.ElideRight
  110. }
  111. Cura.RadioCheckbar
  112. {
  113. anchors
  114. {
  115. left: intentCategoryLabel.right
  116. right: parent.right
  117. }
  118. dataModel: model["qualities"]
  119. buttonGroup: activeProfileButtonGroup
  120. function checkedFunction(modelItem)
  121. {
  122. if(Cura.MachineManager.hasCustomQuality)
  123. {
  124. // When user created profile is active, no quality tickbox should be active.
  125. return false
  126. }
  127. if(modelItem === null)
  128. {
  129. return false
  130. }
  131. return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
  132. }
  133. isCheckedFunction: checkedFunction
  134. }
  135. MouseArea // Intent description tooltip hover area
  136. {
  137. id: intentDescriptionHoverArea
  138. anchors.fill: parent
  139. hoverEnabled: true
  140. enabled: model.description !== undefined
  141. acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
  142. Timer
  143. {
  144. id: intentTooltipTimer
  145. interval: 500
  146. running: false
  147. repeat: false
  148. onTriggered: base.showTooltip(
  149. intentCategoryLabel,
  150. Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0),
  151. model.description
  152. )
  153. }
  154. onEntered: intentTooltipTimer.start()
  155. onExited:
  156. {
  157. base.hideTooltip()
  158. intentTooltipTimer.stop()
  159. }
  160. }
  161. NoIntentIcon // This icon has hover priority over intentDescriptionHoverArea, so draw it above it.
  162. {
  163. affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
  164. intent_type: model.name
  165. anchors.right: intentCategoryLabel.right
  166. anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
  167. width: intentCategoryLabel.height * 0.75
  168. anchors.verticalCenter: parent.verticalCenter
  169. height: width
  170. visible: Cura.MachineManager.activeIntentCategory == model.intent_category && affected_extruders.length
  171. }
  172. }
  173. }
  174. }
  175. }