SettingCheckBox.qml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. contents: MouseArea
  12. {
  13. id: control
  14. anchors.fill: parent
  15. hoverEnabled: true
  16. property bool checked:
  17. {
  18. switch(propertyProvider.properties.value)
  19. {
  20. case "True":
  21. return true
  22. case "False":
  23. return false
  24. default:
  25. return propertyProvider.properties.value
  26. }
  27. }
  28. onClicked: { forceActiveFocus(); propertyProvider.setPropertyValue("value", !checked) }
  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(control.containsMouse || control.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. }