SettingVisibilityPage.qml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. settingVisibilityPresetsModel.setActivePreset("basic")
  21. }
  22. resetEnabled: true;
  23. Item
  24. {
  25. id: base;
  26. anchors.fill: parent;
  27. CheckBox
  28. {
  29. id: toggleVisibleSettings
  30. anchors
  31. {
  32. verticalCenter: filter.verticalCenter;
  33. left: parent.left;
  34. leftMargin: UM.Theme.getSize("default_margin").width
  35. }
  36. text: catalog.i18nc("@label:textbox", "Check all")
  37. checkedState:
  38. {
  39. if(definitionsModel.visibleCount == definitionsModel.categoryCount)
  40. {
  41. return Qt.Unchecked
  42. }
  43. else if(definitionsModel.visibleCount == definitionsModel.count)
  44. {
  45. return Qt.Checked
  46. }
  47. else
  48. {
  49. return Qt.PartiallyChecked
  50. }
  51. }
  52. partiallyCheckedEnabled: true
  53. MouseArea
  54. {
  55. anchors.fill: parent;
  56. onClicked:
  57. {
  58. if(parent.checkedState == Qt.Unchecked || parent.checkedState == Qt.PartiallyChecked)
  59. {
  60. definitionsModel.setAllExpandedVisible(true)
  61. }
  62. else
  63. {
  64. definitionsModel.setAllExpandedVisible(false)
  65. }
  66. }
  67. }
  68. }
  69. TextField
  70. {
  71. id: filter;
  72. anchors
  73. {
  74. top: parent.top
  75. left: toggleVisibleSettings.right
  76. leftMargin: UM.Theme.getSize("default_margin").width
  77. right: visibilityPreset.left
  78. rightMargin: UM.Theme.getSize("default_margin").width
  79. }
  80. placeholderText: catalog.i18nc("@label:textbox", "Filter...")
  81. onTextChanged: definitionsModel.filter = {"i18n_label": "*" + text}
  82. }
  83. ComboBox
  84. {
  85. id: visibilityPreset
  86. width: 150 * screenScaleFactor
  87. anchors
  88. {
  89. top: parent.top
  90. right: parent.right
  91. }
  92. model: settingVisibilityPresetsModel.items
  93. textRole: "name"
  94. currentIndex:
  95. {
  96. var idx = -1;
  97. for(var i = 0; i < settingVisibilityPresetsModel.items.length; ++i)
  98. {
  99. if(settingVisibilityPresetsModel.items[i].presetId == settingVisibilityPresetsModel.activePreset)
  100. {
  101. idx = i;
  102. break;
  103. }
  104. }
  105. return idx;
  106. }
  107. onActivated:
  108. {
  109. var preset_id = settingVisibilityPresetsModel.items[index].presetId
  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.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  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. }