SettingCheckBox.qml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Uranium is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.Controls 1.1
  6. import QtQuick.Controls.Styles 1.1
  7. import UM 1.2 as UM
  8. SettingItem
  9. {
  10. id: base
  11. MouseArea
  12. {
  13. id: control
  14. property bool checked:
  15. {
  16. if(value == "True")
  17. {
  18. return true;
  19. }
  20. else if(value == "False")
  21. {
  22. return false;
  23. }
  24. else
  25. {
  26. return value;
  27. }
  28. }
  29. Rectangle
  30. {
  31. anchors
  32. {
  33. top: parent.top
  34. bottom: parent.bottom
  35. left: parent.left
  36. }
  37. width: height
  38. color:
  39. {
  40. if (!enabled)
  41. {
  42. return base.style.controlDisabledColor
  43. }
  44. if(base.containsMouse || base.activeFocus)
  45. {
  46. return base.style.controlHighlightColor
  47. }
  48. else
  49. {
  50. return base.style.controlColor
  51. }
  52. }
  53. border.width: base.style.controlBorderWidth;
  54. border.color: !enabled ? base.style.controlDisabledBorderColor : control.containsMouse ? base.style.controlBorderHighlightColor : base.style.controlBorderColor;
  55. UM.RecolorImage {
  56. anchors.verticalCenter: parent.verticalCenter
  57. anchors.horizontalCenter: parent.horizontalCenter
  58. width: parent.width/2.5
  59. height: parent.height/2.5
  60. sourceSize.width: width
  61. sourceSize.height: width
  62. color: !enabled ? base.style.controlDisabledTextColor : base.style.controlTextColor;
  63. source: UM.Theme.getIcon("check")
  64. opacity: control.checked
  65. Behavior on opacity { NumberAnimation { duration: 100; } }
  66. }
  67. }
  68. }
  69. }