RecommendedQualityProfileSelector.qml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.12
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls 2.3 as Controls2
  6. import QtQuick.Controls.Styles 1.4
  7. import QtQuick.Layouts 1.15
  8. import UM 1.2 as UM
  9. import Cura 1.6 as Cura
  10. import ".."
  11. Item
  12. {
  13. id: qualityRow
  14. height: childrenRect.height
  15. property real labelColumnWidth: Math.round(width / 3)
  16. property real settingsColumnWidth: width - labelColumnWidth
  17. // Here are the elements that are shown in the left column
  18. Column
  19. {
  20. spacing: UM.Theme.getSize("default_margin").height
  21. anchors{
  22. left: parent.left
  23. right: parent.right
  24. }
  25. Label
  26. {
  27. text: catalog.i18nc("@label", "Profiles")
  28. font: UM.Theme.getFont("medium")
  29. }
  30. Controls2.TabBar
  31. {
  32. id: intentSelection
  33. width: parent.width
  34. height: UM.Theme.getSize("recomended_quality_tab").height
  35. spacing: UM.Theme.getSize("narrow_margin").width
  36. Repeater
  37. {
  38. model: Cura.IntentCategoryModel{}
  39. Controls2.TabButton{
  40. id: "intentCategoryButton"
  41. anchors.verticalCenter:parent.verticalCenter
  42. height: parent.height
  43. background: Rectangle{
  44. color: (intentSelection.currentIndex==index) ? UM.Theme.getColor("setting_category_hover") : UM.Theme.getColor("main_background")
  45. }
  46. // function getFirstAvailableQuality(qualities){
  47. // console.log(qualities)
  48. // for(var i=0;i<qualities.count;i++){
  49. // console.log(qualities.name)
  50. // console.log(qualities.intent_category)
  51. // console.log(i, qualities.get(i).available)
  52. // if (qualities.available){
  53. // return i
  54. // }
  55. // }
  56. // }
  57. onClicked: Cura.IntentManager.selectIntent(model.intent_category, "normal" )
  58. //onClicked: getFirstAvailableQuality(model["qualities"]")
  59. ColumnLayout{
  60. spacing: 2
  61. anchors.fill: parent
  62. UM.RecolorImage
  63. {
  64. Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
  65. id: intent_category
  66. source: {
  67. switch (model.name) {
  68. case "Default":
  69. UM.Theme.getIcon("Placeholder", "high")
  70. break
  71. case "Visual":
  72. UM.Theme.getIcon("Art", "high")
  73. break
  74. case "Engineering":
  75. UM.Theme.getIcon("Machine", "high")
  76. break
  77. case "Draft":
  78. UM.Theme.getIcon("Easy", "high")
  79. break
  80. default:
  81. UM.Theme.getIcon("Placeholder", "high")
  82. break
  83. }
  84. }
  85. height: UM.Theme.getSize("high_resolution_icon").width/2
  86. width: UM.Theme.getSize("high_resolution_icon").height/2
  87. color: UM.Theme.getColor("text")
  88. }
  89. Text{
  90. text: model.name
  91. horizontalAlignment: Text.AlignHCenter
  92. Layout.fillWidth:true
  93. color: UM.Theme.getColor("text")
  94. }
  95. }
  96. MouseArea // Intent description tooltip hover area
  97. {
  98. id: intentDescriptionHoverArea
  99. anchors.fill: parent
  100. hoverEnabled: true
  101. enabled: model.description !== undefined
  102. acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
  103. Timer
  104. {
  105. id: intentTooltipTimer
  106. interval: 500
  107. running: false
  108. repeat: false
  109. onTriggered: base.showTooltip(
  110. intentCategoryButton,
  111. Qt.point(0, 0),
  112. model.description
  113. )
  114. }
  115. onEntered: intentTooltipTimer.start()
  116. onExited:
  117. {
  118. base.hideTooltip()
  119. intentTooltipTimer.stop()
  120. }
  121. }
  122. }
  123. }
  124. }
  125. StackLayout{
  126. width: parent.width
  127. currentIndex:intentSelection.currentIndex
  128. height:200
  129. Repeater
  130. {
  131. model: Cura.IntentCategoryModel{}
  132. Column{
  133. spacing:UM.Theme.getSize("default_margin").height
  134. // Cura.IconWithText
  135. // {
  136. // source: UM.Theme.getIcon("PrintQuality")
  137. // text: "resolution"
  138. // font: UM.Theme.getFont("default")
  139. // width: labelColumnWidth
  140. // iconSize: UM.Theme.getSize("medium_button_icon").width
  141. // }
  142. Label
  143. {
  144. text: catalog.i18nc("@label", "Resolution")
  145. font: UM.Theme.getFont("default")
  146. }
  147. RowLayout
  148. {
  149. //width:parent.width
  150. anchors.left:parent.left
  151. anchors.right:parent.right
  152. height: UM.Theme.getSize("recomended_resolution_button").height
  153. spacing: UM.Theme.getSize("narrow_margin").width
  154. property var intentCategory: model.intent_category
  155. property var intentModel: model["qualities"]
  156. Repeater
  157. {
  158. model: parent.intentModel
  159. Controls2.Button{
  160. property var intentCategoryLabel: parent.intentModel
  161. visible: model.available
  162. Layout.fillWidth: true
  163. Layout.fillHeight: true
  164. checkable:true
  165. height: UM.Theme.getSize("recomended_resolution_button").height
  166. Layout.minimumWidth: UM.Theme.getSize("recomended_resolution_button").width
  167. background: Rectangle{
  168. anchors.fill:parent
  169. color: parent.checked ? UM.Theme.getColor("setting_category_hover") : UM.Theme.getColor("main_background")
  170. }
  171. property var modelData: {
  172. "intent_category": parent.intentCategory,
  173. "quality_type": model.quality_type
  174. }
  175. function checkedFunction(modelItem)
  176. {
  177. if(Cura.MachineManager.hasCustomQuality)
  178. {
  179. // When user created profile is active, no quality tickbox should be active.
  180. return false
  181. }
  182. if(modelItem === null)
  183. {
  184. return false
  185. }
  186. return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
  187. }
  188. checked: checkedFunction(modelData)
  189. Controls2.ButtonGroup.group: activeProfileButtonGroup
  190. Row{
  191. padding: UM.Theme.getSize("narrow_margin").width
  192. spacing: UM.Theme.getSize("narrow_margin").width
  193. UM.RecolorImage
  194. {
  195. id: buttonIconLeft
  196. source: {
  197. switch (model.layer_height) {
  198. case 0.06:
  199. UM.Theme.getIcon("ResolutionExtrafine", "high")
  200. break
  201. case 0.1:
  202. UM.Theme.getIcon("ResolutionFine", "high")
  203. break
  204. case 0.15:
  205. UM.Theme.getIcon("ResolutionNormal", "high")
  206. break
  207. case 0.2:
  208. UM.Theme.getIcon("ResolutionFast", "high")
  209. break
  210. case 0.3:
  211. UM.Theme.getIcon("ResolutionExtrFast", "high")
  212. break
  213. case 0.4:
  214. UM.Theme.getIcon("ResolutionSprint", "high")
  215. break
  216. default:
  217. UM.Theme.getIcon("ResolutionNormal", "high")
  218. break
  219. }
  220. }
  221. height: UM.Theme.getSize("high_resolution_icon").width/2
  222. width: UM.Theme.getSize("high_resolution_icon").height/2
  223. color: UM.Theme.getColor("text")
  224. }
  225. Column{
  226. Text{ text: model.name}
  227. Text{ text: model.layer_height}
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. Controls2.ButtonGroup{
  237. id: activeProfileButtonGroup
  238. exclusive: true
  239. onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type)
  240. }
  241. // Item
  242. // {
  243. // height: childrenRect.height
  244. // anchors
  245. // {
  246. // left: parent.left
  247. // right: parent.right
  248. // }
  249. // Cura.IconWithText
  250. // {
  251. // id: profileLabel
  252. // source: UM.Theme.getIcon("PrintQuality")
  253. // text: catalog.i18nc("@label", "Profiles")
  254. // font: UM.Theme.getFont("medium")
  255. // width: labelColumnWidth
  256. // iconSize: UM.Theme.getSize("medium_button_icon").width
  257. // }
  258. // UM.SimpleButton
  259. // {
  260. // id: resetToDefaultQualityButton
  261. // visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality
  262. // height: visible ? UM.Theme.getSize("print_setup_icon").height : 0
  263. // width: height
  264. // anchors
  265. // {
  266. // right: profileLabel.right
  267. // rightMargin: UM.Theme.getSize("default_margin").width
  268. // leftMargin: UM.Theme.getSize("default_margin").width
  269. // verticalCenter: parent.verticalCenter
  270. // }
  271. // color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button")
  272. // iconSource: UM.Theme.getIcon("ArrowReset")
  273. // onClicked:
  274. // {
  275. // // if the current profile is user-created, switch to a built-in quality
  276. // Cura.MachineManager.resetToUseDefaultQuality()
  277. // }
  278. // onEntered:
  279. // {
  280. // var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.")
  281. // base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent)
  282. // }
  283. // onExited: base.hideTooltip()
  284. // }
  285. // Cura.LabelBar
  286. // {
  287. // id: labelbar
  288. // anchors
  289. // {
  290. // left: profileLabel.right
  291. // right: parent.right
  292. // verticalCenter: profileLabel.verticalCenter
  293. // }
  294. // model: Cura.QualityProfilesDropDownMenuModel
  295. // modelKey: "layer_height"
  296. // }
  297. // }
  298. // Repeater
  299. // {
  300. // model: Cura.IntentCategoryModel {}
  301. // Item
  302. // {
  303. // anchors
  304. // {
  305. // left: parent.left
  306. // right: parent.right
  307. // }
  308. // height: intentCategoryLabel.height
  309. // Label
  310. // {
  311. // id: intentCategoryLabel
  312. // text: model.name
  313. // width: labelColumnWidth - UM.Theme.getSize("section_icon").width
  314. // anchors.left: parent.left
  315. // anchors.leftMargin: UM.Theme.getSize("section_icon").width + UM.Theme.getSize("narrow_margin").width
  316. // font: UM.Theme.getFont("medium")
  317. // color: UM.Theme.getColor("text")
  318. // renderType: Text.NativeRendering
  319. // elide: Text.ElideRight
  320. // }
  321. // Cura.RadioCheckbar
  322. // {
  323. // anchors
  324. // {
  325. // left: intentCategoryLabel.right
  326. // right: parent.right
  327. // }
  328. // dataModel: model["qualities"]
  329. // buttonGroup: activeProfileButtonGroup
  330. // function checkedFunction(modelItem)
  331. // {
  332. // if(Cura.MachineManager.hasCustomQuality)
  333. // {
  334. // // When user created profile is active, no quality tickbox should be active.
  335. // return false
  336. // }
  337. // if(modelItem === null)
  338. // {
  339. // return false
  340. // }
  341. // return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category
  342. // }
  343. // isCheckedFunction: checkedFunction
  344. // }
  345. // MouseArea // Intent description tooltip hover area
  346. // {
  347. // id: intentDescriptionHoverArea
  348. // anchors.fill: parent
  349. // hoverEnabled: true
  350. // enabled: model.description !== undefined
  351. // acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
  352. // Timer
  353. // {
  354. // id: intentTooltipTimer
  355. // interval: 500
  356. // running: false
  357. // repeat: false
  358. // onTriggered: base.showTooltip(
  359. // intentCategoryLabel,
  360. // Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0),
  361. // model.description
  362. // )
  363. // }
  364. // onEntered: intentTooltipTimer.start()
  365. // onExited:
  366. // {
  367. // base.hideTooltip()
  368. // intentTooltipTimer.stop()
  369. // }
  370. // }
  371. // NoIntentIcon // This icon has hover priority over intentDescriptionHoverArea, so draw it above it.
  372. // {
  373. // affected_extruders: Cura.MachineManager.extruderPositionsWithNonActiveIntent
  374. // intent_type: model.name
  375. // anchors.right: intentCategoryLabel.right
  376. // anchors.rightMargin: UM.Theme.getSize("narrow_margin").width
  377. // width: intentCategoryLabel.height * 0.75
  378. // anchors.verticalCenter: parent.verticalCenter
  379. // height: width
  380. // visible: Cura.MachineManager.activeIntentCategory == model.intent_category && affected_extruders.length
  381. // }
  382. // }
  383. // }
  384. }
  385. }