SettingCategory.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 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. if(definition.expanded)
  26. {
  27. settingDefinitionsModel.collapse(definition.key);
  28. }
  29. else
  30. {
  31. settingDefinitionsModel.expandAll(definition.key);
  32. }
  33. //Set focus so that tab navigation continues from this point on.
  34. //NB: This must be set AFTER collapsing/expanding the category so that the scroll position is correct.
  35. forceActiveFocus();
  36. }
  37. onActiveFocusChanged:
  38. {
  39. if(activeFocus)
  40. {
  41. base.focusReceived();
  42. }
  43. }
  44. Keys.onTabPressed:
  45. {
  46. base.setActiveFocusToNextSetting(true)
  47. }
  48. Keys.onBacktabPressed:
  49. {
  50. base.setActiveFocusToNextSetting(false)
  51. }
  52. UM.SimpleButton
  53. {
  54. id: settingsButton
  55. visible: base.hovered || settingsButton.hovered
  56. height: base.height * 0.6
  57. width: base.height * 0.6
  58. anchors {
  59. right: inheritButton.visible ? inheritButton.left : parent.right
  60. rightMargin: inheritButton.visible? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("setting_preferences_button_margin").width
  61. verticalCenter: parent.verticalCenter;
  62. }
  63. color: UM.Theme.getColor("setting_control_button");
  64. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  65. iconSource: UM.Theme.getIcon("settings");
  66. onClicked: {
  67. Cura.Actions.configureSettingVisibility.trigger(definition)
  68. }
  69. }
  70. UM.SimpleButton
  71. {
  72. id: inheritButton;
  73. anchors.verticalCenter: parent.verticalCenter
  74. anchors.right: parent.right
  75. anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width
  76. visible:
  77. {
  78. if(Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0)
  79. {
  80. var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(definition.key)
  81. for(var i = 0; i < children_with_override.length; i++)
  82. {
  83. if(!settingDefinitionsModel.getVisible(children_with_override[i]))
  84. {
  85. return true
  86. }
  87. }
  88. return false
  89. }
  90. return false
  91. }
  92. height: parent.height / 2
  93. width: height
  94. onClicked:
  95. {
  96. settingDefinitionsModel.expandAll(definition.key);
  97. base.checked = true;
  98. base.showAllHiddenInheritedSettings(definition.key);
  99. }
  100. color: UM.Theme.getColor("setting_control_button")
  101. hoverColor: UM.Theme.getColor("setting_control_button_hover")
  102. iconSource: UM.Theme.getIcon("notice")
  103. onEntered:
  104. {
  105. base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))
  106. }
  107. onExited:
  108. {
  109. base.hideTooltip();
  110. }
  111. UM.I18nCatalog { id: catalog; name: "cura" }
  112. }
  113. }