SettingCategory.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Uranium is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.1 as UM
  8. import Cura 1.0 as Cura
  9. Button {
  10. id: base;
  11. style: UM.Theme.styles.sidebar_category;
  12. signal showTooltip(string text);
  13. signal hideTooltip();
  14. signal contextMenuRequested()
  15. signal showAllHiddenInheritedSettings(string category_id)
  16. text: definition.label
  17. iconSource: UM.Theme.getIcon(definition.icon)
  18. checkable: true
  19. checked: definition.expanded
  20. onClicked: { forceActiveFocus(); definition.expanded ? settingDefinitionsModel.collapse(definition.key) : settingDefinitionsModel.expandAll(definition.key) }
  21. UM.SimpleButton
  22. {
  23. id: settingsButton
  24. visible: base.hovered || settingsButton.hovered
  25. height: base.height * 0.6
  26. width: base.height * 0.6
  27. anchors {
  28. right: inheritButton.visible ? inheritButton.left : parent.right
  29. rightMargin: inheritButton.visible? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("setting_preferences_button_margin").width
  30. verticalCenter: parent.verticalCenter;
  31. }
  32. color: UM.Theme.getColor("setting_control_button");
  33. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  34. iconSource: UM.Theme.getIcon("settings");
  35. onClicked: {
  36. Cura.Actions.configureSettingVisibility.trigger(definition)
  37. }
  38. }
  39. UM.SimpleButton
  40. {
  41. id: inheritButton;
  42. anchors.verticalCenter: parent.verticalCenter
  43. anchors.right: parent.right
  44. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width
  45. visible:
  46. {
  47. if(Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0)
  48. {
  49. var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(definition.key)
  50. for(var i = 0; i < children_with_override.length; i++)
  51. {
  52. if(!settingDefinitionsModel.getVisible(children_with_override[i]))
  53. {
  54. return true
  55. }
  56. }
  57. return false
  58. }
  59. return false
  60. }
  61. height: parent.height / 2
  62. width: height
  63. onClicked:
  64. {
  65. settingDefinitionsModel.expandAll(definition.key);
  66. base.checked = true;
  67. base.showAllHiddenInheritedSettings(definition.key);
  68. }
  69. color: UM.Theme.getColor("setting_control_button")
  70. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  71. iconSource: UM.Theme.getIcon("notice")
  72. onEntered:
  73. {
  74. base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))
  75. }
  76. onExited:
  77. {
  78. base.hideTooltip();
  79. }
  80. UM.I18nCatalog { id: catalog; name: "cura" }
  81. }
  82. }