SettingVisibilityItem.qml 3.1 KB

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