SettingVisibilityItem.qml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Uranium is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 2.1
  5. import UM 1.5 as UM
  6. Item
  7. {
  8. // Use the depth of the model to move the item, but also leave space for the visibility / enabled exclamation mark.
  9. // Align checkbox with SettingVisibilityCategory icon with + 5
  10. x: definition ? definition.depth * UM.Theme.getSize("narrow_margin").width : UM.Theme.getSize("default_margin").width
  11. UM.TooltipArea
  12. {
  13. text: definition ? definition.description : ""
  14. width: childrenRect.width;
  15. height: childrenRect.height;
  16. id: checkboxTooltipArea
  17. x: check.height
  18. UM.CheckBox
  19. {
  20. id: check
  21. text: definition ? definition.label: ""
  22. checked: definition ? definition.visible: false
  23. enabled: definition ? !definition.prohibited: false
  24. MouseArea
  25. {
  26. anchors.fill: parent
  27. onClicked: definitionsModel.setVisible(definition.key, !check.checked)
  28. }
  29. }
  30. }
  31. UM.TooltipArea
  32. {
  33. width: height
  34. height: check.height
  35. anchors.right: checkboxTooltipArea.left
  36. anchors.leftMargin: 2 * screenScaleFactor
  37. text:
  38. {
  39. if(provider.properties.enabled == "True")
  40. {
  41. return ""
  42. }
  43. var key = definition ? definition.key : ""
  44. var requires = settingDefinitionsModel.getRequires(key, "enabled")
  45. if (requires.length == 0)
  46. {
  47. return catalog.i18nc("@item:tooltip", "This setting has been hidden by the active machine and will not be visible.");
  48. }
  49. else
  50. {
  51. var requires_text = ""
  52. for (var i in requires)
  53. {
  54. if (requires_text == "")
  55. {
  56. requires_text = requires[i].label
  57. }
  58. else
  59. {
  60. requires_text += ", " + requires[i].label
  61. }
  62. }
  63. return catalog.i18ncp("@item:tooltip %1 is list of setting names", "This setting has been hidden by the value of %1. Change the value of that setting to make this setting visible.", "This setting has been hidden by the values of %1. Change the values of those settings to make this setting visible.", requires.length) .arg(requires_text);
  64. }
  65. }
  66. UM.ColorImage
  67. {
  68. anchors.centerIn: parent
  69. width: Math.round(check.height * 0.75) | 0
  70. height: width
  71. source: UM.Theme.getIcon("Information")
  72. color: UM.Theme.getColor("small_button_text")
  73. }
  74. visible: provider.properties.enabled == "False"
  75. }
  76. UM.SettingPropertyProvider
  77. {
  78. id: provider
  79. containerStackId: "global"
  80. watchedProperties: [ "enabled" ]
  81. key: definition ? definition.key : ""
  82. }
  83. }