SettingVisibilityPage.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.setAllVisible(true)
  64. }
  65. else
  66. {
  67. definitionsModel.setAllVisible(false)
  68. }
  69. // After change set "Custom" option
  70. // If already "Custom" then don't do nothing
  71. if (visibilityPreset.currentIndex != visibilityPreset.model.count - 1)
  72. {
  73. visibilityPreset.currentIndex = visibilityPreset.model.count - 1
  74. UM.Preferences.setValue("cura/active_setting_visibility_preset", visibilityPreset.model.getItem(visibilityPreset.currentIndex).id)
  75. }
  76. }
  77. }
  78. }
  79. TextField
  80. {
  81. id: filter;
  82. anchors
  83. {
  84. top: parent.top
  85. left: toggleVisibleSettings.right
  86. leftMargin: UM.Theme.getSize("default_margin").width
  87. right: visibilityPreset.left
  88. rightMargin: UM.Theme.getSize("default_margin").width
  89. }
  90. placeholderText: catalog.i18nc("@label:textbox", "Filter...")
  91. onTextChanged: definitionsModel.filter = {"i18n_label": "*" + text}
  92. }
  93. ComboBox
  94. {
  95. id: visibilityPreset
  96. width: 150 * screenScaleFactor
  97. anchors
  98. {
  99. top: parent.top
  100. right: parent.right
  101. }
  102. model: settingVisibilityPresetsModel
  103. textRole: "name"
  104. currentIndex:
  105. {
  106. // Load previously selected preset.
  107. var index = settingVisibilityPresetsModel.find("id", settingVisibilityPresetsModel.activePreset)
  108. if (index == -1)
  109. {
  110. return 0
  111. }
  112. return index
  113. }
  114. onActivated:
  115. {
  116. var preset_id = settingVisibilityPresetsModel.getItem(index).id;
  117. settingVisibilityPresetsModel.setActivePreset(preset_id);
  118. }
  119. }
  120. ScrollView
  121. {
  122. id: scrollView
  123. frameVisible: true
  124. anchors
  125. {
  126. top: filter.bottom;
  127. topMargin: UM.Theme.getSize("default_margin").height
  128. left: parent.left;
  129. right: parent.right;
  130. bottom: parent.bottom;
  131. }
  132. ListView
  133. {
  134. id: settingsListView
  135. model: UM.SettingDefinitionsModel
  136. {
  137. id: definitionsModel
  138. containerId: Cura.MachineManager.activeDefinitionId
  139. showAll: true
  140. exclude: ["machine_settings", "command_line_settings"]
  141. showAncestors: true
  142. expanded: ["*"]
  143. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  144. }
  145. delegate: Loader
  146. {
  147. id: loader
  148. width: parent.width
  149. height: model.type != undefined ? UM.Theme.getSize("section").height : 0
  150. property var definition: model
  151. property var settingDefinitionsModel: definitionsModel
  152. asynchronous: true
  153. active: model.type != undefined
  154. sourceComponent:
  155. {
  156. switch(model.type)
  157. {
  158. case "category":
  159. return settingVisibilityCategory
  160. default:
  161. return settingVisibilityItem
  162. }
  163. }
  164. }
  165. }
  166. }
  167. UM.I18nCatalog { name: "cura"; }
  168. SystemPalette { id: palette; }
  169. Component
  170. {
  171. id: settingVisibilityCategory;
  172. UM.SettingVisibilityCategory { }
  173. }
  174. Component
  175. {
  176. id: settingVisibilityItem;
  177. UM.SettingVisibilityItem { }
  178. }
  179. }
  180. }