CheckBox.qml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (c) 2020 Ultimaker B.V.
  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 UM 1.3 as UM
  6. import Cura 1.1 as Cura
  7. //
  8. // Checkbox with Cura styling.
  9. //
  10. CheckBox
  11. {
  12. id: control
  13. hoverEnabled: true
  14. indicator: Rectangle
  15. {
  16. width: control.height
  17. height: control.height
  18. color:
  19. {
  20. if (!control.enabled)
  21. {
  22. return UM.Theme.getColor("setting_control_disabled")
  23. }
  24. if (control.hovered || control.activeFocus)
  25. {
  26. return UM.Theme.getColor("setting_control_highlight")
  27. }
  28. return UM.Theme.getColor("setting_control")
  29. }
  30. radius: UM.Theme.getSize("setting_control_radius").width
  31. border.width: UM.Theme.getSize("default_lining").width
  32. border.color:
  33. {
  34. if (!enabled)
  35. {
  36. return UM.Theme.getColor("setting_control_disabled_border")
  37. }
  38. if (control.hovered || control.activeFocus)
  39. {
  40. return UM.Theme.getColor("setting_control_border_highlight")
  41. }
  42. return UM.Theme.getColor("setting_control_border")
  43. }
  44. UM.RecolorImage
  45. {
  46. anchors.verticalCenter: parent.verticalCenter
  47. anchors.horizontalCenter: parent.horizontalCenter
  48. width: Math.round(parent.width / 2.5)
  49. height: Math.round(parent.height / 2.5)
  50. sourceSize.height: width
  51. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  52. source: UM.Theme.getIcon("Check")
  53. opacity: control.checked ? 1 : 0
  54. Behavior on opacity { NumberAnimation { duration: 100; } }
  55. }
  56. }
  57. contentItem: Label
  58. {
  59. id: textLabel
  60. leftPadding: control.indicator.width + control.spacing
  61. text: control.text
  62. font: control.font
  63. color: UM.Theme.getColor("text")
  64. renderType: Text.NativeRendering
  65. verticalAlignment: Text.AlignVCenter
  66. }
  67. }