RecommendedQualityProfileSelectorButton.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright (c) 2023 UltiMaker
  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 QtQuick.Layouts 2.10
  6. import UM 1.5 as UM
  7. import Cura 1.7 as Cura
  8. Rectangle
  9. {
  10. id: base
  11. height: 60
  12. Layout.fillWidth: true
  13. color: mouseArea.containsMouse || selected ? UM.Theme.getColor("background_3") : UM.Theme.getColor("background_1")
  14. property bool selected: false
  15. property string profileName: ""
  16. property string icon: ""
  17. property string custom_icon: ""
  18. property alias tooltipText: tooltip.text
  19. signal clicked()
  20. MouseArea
  21. {
  22. id: mouseArea
  23. anchors.fill: parent
  24. hoverEnabled: true
  25. onClicked: base.clicked()
  26. }
  27. UM.ToolTip
  28. {
  29. id: tooltip
  30. visible: mouseArea.containsMouse
  31. targetPoint: Qt.point(base.x + (base.width / 2), base.y + (base.height / 2))
  32. width: UM.Theme.getSize("tooltip").width
  33. }
  34. Item
  35. {
  36. width: intentIcon.width
  37. anchors
  38. {
  39. top: parent.top
  40. bottom: qualityLabel.top
  41. horizontalCenter: parent.horizontalCenter
  42. topMargin: UM.Theme.getSize("narrow_margin").height
  43. }
  44. Item
  45. {
  46. id: intentIcon
  47. width: UM.Theme.getSize("recommended_button_icon").width
  48. height: UM.Theme.getSize("recommended_button_icon").height
  49. UM.ColorImage
  50. {
  51. anchors.fill: parent
  52. anchors.centerIn: parent
  53. visible: icon !== ""
  54. source: UM.Theme.getIcon(icon)
  55. color: UM.Theme.getColor("icon")
  56. }
  57. UM.ColorImage
  58. {
  59. anchors.fill: parent
  60. anchors.centerIn: parent
  61. visible: custom_icon !== ""
  62. source: custom_icon
  63. color: UM.Theme.getColor("icon")
  64. }
  65. Rectangle
  66. {
  67. id: circle
  68. anchors.fill: parent
  69. radius: width
  70. anchors.verticalCenter: parent.verticalCenter
  71. visible: icon === "" && custom_icon === ""
  72. border.width: UM.Theme.getSize("thick_lining").width
  73. border.color: UM.Theme.getColor("text")
  74. color: "transparent"
  75. UM.Label
  76. {
  77. id: initialLabel
  78. anchors.centerIn: parent
  79. text: profileName.charAt(0).toUpperCase()
  80. font: UM.Theme.getFont("small_bold")
  81. horizontalAlignment: Text.AlignHCenter
  82. }
  83. }
  84. }
  85. }
  86. UM.Label
  87. {
  88. id: qualityLabel
  89. text: profileName
  90. anchors
  91. {
  92. bottom: parent.bottom
  93. horizontalCenter: parent.horizontalCenter
  94. bottomMargin: UM.Theme.getSize("narrow_margin").height
  95. }
  96. }
  97. }