SettingCheckBox.qml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 UM.Theme.getColor("setting_control_disabled")
  43. }
  44. if(base.containsMouse || base.activeFocus)
  45. {
  46. return UM.Theme.getColor("setting_control_highlight")
  47. }
  48. else
  49. {
  50. return UM.Theme.getColor("setting_control")
  51. }
  52. }
  53. border.width: UM.Theme.getSize("default_lining").width
  54. border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.containsMouse ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
  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 ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text");
  63. source: UM.Theme.getIcon("check")
  64. opacity: control.checked ? 1 : 0
  65. Behavior on opacity { NumberAnimation { duration: 100; } }
  66. }
  67. }
  68. }
  69. }