SimpleCheckBox.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. UM.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. }
  43. UM.CheckBox
  44. {
  45. id: checkBox
  46. anchors {
  47. left: fieldLabel.right
  48. leftMargin: UM.Theme.getSize("default_margin").width
  49. verticalCenter: parent.verticalCenter
  50. }
  51. checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
  52. height: UM.Theme.getSize("checkbox").height
  53. text: ""
  54. onClicked:
  55. {
  56. propertyProvider.setPropertyValue("value", checked)
  57. forceUpdateOnChangeFunction()
  58. }
  59. }
  60. }