PrintSetupHeaderButton.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. Cura.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. border.color: 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. border.color: 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. border.color: 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. border.color: UM.Theme.getColor("setting_control_border_highlight")
  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. border.color: UM.Theme.getColor("setting_control_border")
  76. }
  77. }
  78. ]
  79. background: Rectangle
  80. {
  81. id: background
  82. radius: UM.Theme.getSize("setting_control_radius").width
  83. border.width: UM.Theme.getSize("default_lining").width
  84. color: UM.Theme.getColor("setting_control")
  85. border.color: UM.Theme.getColor("setting_control_border")
  86. UM.RecolorImage
  87. {
  88. id: downArrow
  89. anchors.verticalCenter: parent.verticalCenter
  90. anchors.right: parent.right
  91. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  92. width: UM.Theme.getSize("standard_arrow").width
  93. height: UM.Theme.getSize("standard_arrow").height
  94. sourceSize.height: width
  95. color: base.enabled ? UM.Theme.getColor("setting_control_button") : UM.Theme.getColor("setting_category_disabled_text")
  96. source: UM.Theme.getIcon("ChevronSingleDown")
  97. }
  98. }
  99. contentItem: UM.Label
  100. {
  101. id: printSetupComboBoxLabel
  102. text: base.text
  103. elide: Text.ElideRight;
  104. anchors.left: parent.left;
  105. anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
  106. anchors.right: downArrow.lef
  107. anchors.rightMargin: base.rightMargin
  108. anchors.verticalCenter: parent.verticalCenter
  109. }
  110. }