SimpleCheckBox.qml 1.9 KB

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