PrintSetupHeaderButton.qml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. // Button with a label-like appearance that displays different states (these can be displayed by setting the
  4. // `valueError` or `valueWarning` properties). Mainly used within the `CustomConfiguration` component.
  5. import QtQuick 2.1
  6. import QtQuick.Controls 2.1
  7. import Cura 1.0 as Cura
  8. import UM 1.5 as UM
  9. ToolButton
  10. {
  11. id: base
  12. property alias tooltip: tooltip.text
  13. property bool valueError: false;
  14. property bool valueWarning: false;
  15. UM.ToolTip
  16. {
  17. id: tooltip
  18. visible: base.hovered
  19. targetPoint: Qt.point(parent.x, Math.round(parent.y + parent.height / 2))
  20. }
  21. states:
  22. [
  23. State
  24. {
  25. name: "disabled"
  26. when: !base.enabled;
  27. PropertyChanges
  28. {
  29. target: background
  30. color: UM.Theme.getColor("setting_control_disabled")
  31. liningColor: UM.Theme.getColor("setting_control_disabled_border")
  32. }
  33. },
  34. State
  35. {
  36. name: "value_error"
  37. when: base.enabled && base.valueError
  38. PropertyChanges
  39. {
  40. target: background
  41. color: UM.Theme.getColor("setting_validation_error_background")
  42. liningColor: UM.Theme.getColor("setting_validation_error")
  43. }
  44. },
  45. State
  46. {
  47. name: "value_warning"
  48. when: base.enabled && base.valueWarning
  49. PropertyChanges
  50. {
  51. target: background
  52. color: UM.Theme.getColor("setting_validation_warning_background")
  53. liningColor: UM.Theme.getColor("setting_validation_warning")
  54. }
  55. },
  56. State
  57. {
  58. name: "highlight"
  59. when: base.enabled && base.hovered
  60. PropertyChanges
  61. {
  62. target: background
  63. color: UM.Theme.getColor("setting_control")
  64. liningColor: UM.Theme.getColor("border_main")
  65. }
  66. },
  67. State
  68. {
  69. name: "neutral"
  70. when: base.enabled && !base.hovered && !base.valueWarning && !base.valueError
  71. PropertyChanges
  72. {
  73. target: background
  74. color: UM.Theme.getColor("setting_control")
  75. liningColor: UM.Theme.getColor("border_field_light")
  76. }
  77. }
  78. ]
  79. background: UM.UnderlineBackground
  80. {
  81. id: background
  82. UM.ColorImage
  83. {
  84. id: downArrow
  85. anchors.verticalCenter: parent.verticalCenter
  86. anchors.right: parent.right
  87. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  88. width: UM.Theme.getSize("standard_arrow").width
  89. height: UM.Theme.getSize("standard_arrow").height
  90. color: base.enabled ? UM.Theme.getColor("setting_control_button") : UM.Theme.getColor("setting_category_disabled_text")
  91. source: UM.Theme.getIcon("ChevronSingleDown")
  92. }
  93. }
  94. contentItem: UM.Label
  95. {
  96. id: printSetupComboBoxLabel
  97. text: base.text
  98. elide: Text.ElideRight;
  99. anchors.left: parent.left;
  100. anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
  101. anchors.right: downArrow.lef
  102. anchors.rightMargin: base.rightMargin
  103. anchors.verticalCenter: parent.verticalCenter
  104. }
  105. }