SettingCategory.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. signal focusReceived()
  17. signal setActiveFocusToNextSetting(bool forward)
  18. property var focusItem: base
  19. text: definition.label
  20. iconSource: UM.Theme.getIcon(definition.icon)
  21. checkable: true
  22. checked: definition.expanded
  23. onClicked:
  24. {
  25. forceActiveFocus();
  26. if(definition.expanded)
  27. {
  28. settingDefinitionsModel.collapse(definition.key);
  29. } else {
  30. settingDefinitionsModel.expandAll(definition.key);
  31. }
  32. }
  33. onActiveFocusChanged:
  34. {
  35. if(activeFocus)
  36. {
  37. base.focusReceived();
  38. }
  39. }
  40. Keys.onTabPressed:
  41. {
  42. base.setActiveFocusToNextSetting(true)
  43. }
  44. Keys.onBacktabPressed:
  45. {
  46. base.setActiveFocusToNextSetting(false)
  47. }
  48. UM.SimpleButton
  49. {
  50. id: settingsButton
  51. visible: base.hovered || settingsButton.hovered
  52. height: base.height * 0.6
  53. width: base.height * 0.6
  54. anchors {
  55. right: inheritButton.visible ? inheritButton.left : parent.right
  56. rightMargin: inheritButton.visible? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("setting_preferences_button_margin").width
  57. verticalCenter: parent.verticalCenter;
  58. }
  59. color: UM.Theme.getColor("setting_control_button");
  60. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  61. iconSource: UM.Theme.getIcon("settings");
  62. onClicked: {
  63. Cura.Actions.configureSettingVisibility.trigger(definition)
  64. }
  65. }
  66. UM.SimpleButton
  67. {
  68. id: inheritButton;
  69. anchors.verticalCenter: parent.verticalCenter
  70. anchors.right: parent.right
  71. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width
  72. visible:
  73. {
  74. if(Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0)
  75. {
  76. var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(definition.key)
  77. for(var i = 0; i < children_with_override.length; i++)
  78. {
  79. if(!settingDefinitionsModel.getVisible(children_with_override[i]))
  80. {
  81. return true
  82. }
  83. }
  84. return false
  85. }
  86. return false
  87. }
  88. height: parent.height / 2
  89. width: height
  90. onClicked:
  91. {
  92. settingDefinitionsModel.expandAll(definition.key);
  93. base.checked = true;
  94. base.showAllHiddenInheritedSettings(definition.key);
  95. }
  96. color: UM.Theme.getColor("setting_control_button")
  97. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  98. iconSource: UM.Theme.getIcon("notice")
  99. onEntered:
  100. {
  101. base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))
  102. }
  103. onExited:
  104. {
  105. base.hideTooltip();
  106. }
  107. UM.I18nCatalog { id: catalog; name: "cura" }
  108. }
  109. }