SettingVisibilityItem.qml 3.0 KB

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