SimpleCheckBox.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 QtQuick.Layouts 1.3
  6. import UM 1.5 as UM
  7. import Cura 1.1 as Cura
  8. //
  9. // CheckBox widget for the on/off or true/false settings in the Machine Settings Dialog.
  10. //
  11. UM.TooltipArea
  12. {
  13. id: simpleCheckBox
  14. UM.I18nCatalog { id: catalog; name: "cura"; }
  15. property int controlHeight: UM.Theme.getSize("setting_control").height
  16. height: controlHeight
  17. width: childrenRect.width
  18. text: tooltip
  19. property alias containerStackId: propertyProvider.containerStackId
  20. property alias settingKey: propertyProvider.key
  21. property alias settingStoreIndex: propertyProvider.storeIndex
  22. property alias labelText: fieldLabel.text
  23. property alias labelFont: fieldLabel.font
  24. property alias labelWidth: fieldLabel.width
  25. property string tooltip: propertyProvider.properties.description ? propertyProvider.properties.description : ""
  26. // callback functions
  27. property var forceUpdateOnChangeFunction: dummy_func
  28. // a dummy function for default property values
  29. function dummy_func() {}
  30. UM.SettingPropertyProvider
  31. {
  32. id: propertyProvider
  33. watchedProperties: [ "value", "description" ]
  34. }
  35. Label
  36. {
  37. id: fieldLabel
  38. anchors.left: parent.left
  39. anchors.verticalCenter: checkBox.verticalCenter
  40. visible: text != ""
  41. font: UM.Theme.getFont("medium")
  42. color: UM.Theme.getColor("text")
  43. renderType: Text.NativeRendering
  44. }
  45. UM.CheckBox
  46. {
  47. id: checkBox
  48. anchors {
  49. left: fieldLabel.right
  50. leftMargin: UM.Theme.getSize("default_margin").width
  51. verticalCenter: parent.verticalCenter
  52. }
  53. checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
  54. height: UM.Theme.getSize("checkbox").height
  55. text: ""
  56. onClicked:
  57. {
  58. propertyProvider.setPropertyValue("value", checked)
  59. forceUpdateOnChangeFunction()
  60. }
  61. }
  62. }