SettingVisibilityPage.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. UM.PreferencesPage
  9. {
  10. title: catalog.i18nc("@title:tab", "Setting Visibility");
  11. property QtObject settingVisibilityPresetsModel: CuraApplication.getSettingVisibilityPresetsModel()
  12. property int scrollToIndex: 0
  13. signal scrollToSection( string key )
  14. onScrollToSection:
  15. {
  16. settingsListView.positionViewAtIndex(definitionsModel.getIndex(key), ListView.Beginning)
  17. }
  18. function reset()
  19. {
  20. UM.Preferences.resetPreference("general/visible_settings")
  21. // After calling this function update Setting visibility preset combobox.
  22. // Reset should set default setting preset ("Basic")
  23. visibilityPreset.currentIndex = 1
  24. }
  25. resetEnabled: true;
  26. Item
  27. {
  28. id: base;
  29. anchors.fill: parent;
  30. CheckBox
  31. {
  32. id: toggleVisibleSettings
  33. anchors
  34. {
  35. verticalCenter: filter.verticalCenter;
  36. left: parent.left;
  37. leftMargin: UM.Theme.getSize("default_margin").width
  38. }
  39. text: catalog.i18nc("@label:textbox", "Check all")
  40. checkedState:
  41. {
  42. if(definitionsModel.visibleCount == definitionsModel.categoryCount)
  43. {
  44. return Qt.Unchecked
  45. }
  46. else if(definitionsModel.visibleCount == definitionsModel.rowCount(null))
  47. {
  48. return Qt.Checked
  49. }
  50. else
  51. {
  52. return Qt.PartiallyChecked
  53. }
  54. }
  55. partiallyCheckedEnabled: true
  56. MouseArea
  57. {
  58. anchors.fill: parent;
  59. onClicked:
  60. {
  61. if(parent.checkedState == Qt.Unchecked || parent.checkedState == Qt.PartiallyChecked)
  62. {
  63. definitionsModel.setAllExpandedVisible(true)
  64. }
  65. else
  66. {
  67. definitionsModel.setAllExpandedVisible(false)
  68. }
  69. }
  70. }
  71. }
  72. TextField
  73. {
  74. id: filter;
  75. anchors
  76. {
  77. top: parent.top
  78. left: toggleVisibleSettings.right
  79. leftMargin: UM.Theme.getSize("default_margin").width
  80. right: visibilityPreset.left
  81. rightMargin: UM.Theme.getSize("default_margin").width
  82. }
  83. placeholderText: catalog.i18nc("@label:textbox", "Filter...")
  84. onTextChanged: definitionsModel.filter = {"i18n_label": "*" + text}
  85. }
  86. ComboBox
  87. {
  88. id: visibilityPreset
  89. width: 150 * screenScaleFactor
  90. anchors
  91. {
  92. top: parent.top
  93. right: parent.right
  94. }
  95. model: settingVisibilityPresetsModel
  96. textRole: "name"
  97. currentIndex:
  98. {
  99. // Load previously selected preset.
  100. var index = settingVisibilityPresetsModel.find("id", settingVisibilityPresetsModel.activePreset)
  101. if (index == -1)
  102. {
  103. return 0
  104. }
  105. return index
  106. }
  107. onActivated:
  108. {
  109. var preset_id = settingVisibilityPresetsModel.getItem(index).id;
  110. settingVisibilityPresetsModel.setActivePreset(preset_id);
  111. }
  112. }
  113. ScrollView
  114. {
  115. id: scrollView
  116. frameVisible: true
  117. anchors
  118. {
  119. top: filter.bottom;
  120. topMargin: UM.Theme.getSize("default_margin").height
  121. left: parent.left;
  122. right: parent.right;
  123. bottom: parent.bottom;
  124. }
  125. ListView
  126. {
  127. id: settingsListView
  128. model: UM.SettingDefinitionsModel
  129. {
  130. id: definitionsModel
  131. containerId: Cura.MachineManager.activeDefinitionId
  132. showAll: true
  133. exclude: ["machine_settings", "command_line_settings"]
  134. showAncestors: true
  135. expanded: ["*"]
  136. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  137. }
  138. delegate: Loader
  139. {
  140. id: loader
  141. width: parent.width
  142. height: model.type != undefined ? UM.Theme.getSize("section").height : 0
  143. property var definition: model
  144. property var settingDefinitionsModel: definitionsModel
  145. asynchronous: true
  146. active: model.type != undefined
  147. sourceComponent:
  148. {
  149. switch(model.type)
  150. {
  151. case "category":
  152. return settingVisibilityCategory
  153. default:
  154. return settingVisibilityItem
  155. }
  156. }
  157. }
  158. }
  159. }
  160. UM.I18nCatalog { name: "cura"; }
  161. SystemPalette { id: palette; }
  162. Component
  163. {
  164. id: settingVisibilityCategory;
  165. UM.SettingVisibilityCategory { }
  166. }
  167. Component
  168. {
  169. id: settingVisibilityItem;
  170. UM.SettingVisibilityItem { }
  171. }
  172. }
  173. }