SettingVisibilityPage.qml 5.8 KB

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