SettingPickDialog.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.2
  3. import QtQuick.Controls.Styles 1.2
  4. import UM 1.2 as UM
  5. import Cura 1.0 as Cura
  6. import ".."
  7. UM.Dialog
  8. {
  9. id: settingPickDialog
  10. title: catalog.i18nc("@title:window", "Select Settings to Customize for this model")
  11. width: screenScaleFactor * 360
  12. property var additional_excluded_settings
  13. onVisibilityChanged:
  14. {
  15. // force updating the model to sync it with addedSettingsModel
  16. if (visible)
  17. {
  18. // Set skip setting, it will prevent from resetting selected mesh_type
  19. contents.model.visibilityHandler.addSkipResetSetting(currentMeshType)
  20. listview.model.forceUpdate()
  21. updateFilter()
  22. }
  23. }
  24. function updateFilter()
  25. {
  26. var new_filter = {}
  27. new_filter["settable_per_mesh"] = true
  28. // Don't filter on "settable_per_meshgroup" any more when `printSequencePropertyProvider.properties.value`
  29. // is set to "one_at_a_time", because the current backend architecture isn't ready for that.
  30. if (filterInput.text != "")
  31. {
  32. new_filter["i18n_label"] = "*" + filterInput.text
  33. }
  34. listview.model.filter = new_filter
  35. }
  36. TextField {
  37. id: filterInput
  38. anchors {
  39. top: parent.top
  40. left: parent.left
  41. right: toggleShowAll.left
  42. rightMargin: UM.Theme.getSize("default_margin").width
  43. }
  44. placeholderText: catalog.i18nc("@label:textbox", "Filter...")
  45. onTextChanged: settingPickDialog.updateFilter()
  46. }
  47. CheckBox
  48. {
  49. id: toggleShowAll
  50. anchors {
  51. top: parent.top
  52. right: parent.right
  53. }
  54. text: catalog.i18nc("@label:checkbox", "Show all")
  55. checked: listview.model.showAll
  56. onClicked:
  57. {
  58. listview.model.showAll = checked
  59. }
  60. }
  61. ScrollView
  62. {
  63. id: scrollView
  64. anchors
  65. {
  66. top: filterInput.bottom
  67. left: parent.left
  68. right: parent.right
  69. bottom: parent.bottom
  70. }
  71. ListView
  72. {
  73. id:listview
  74. model: UM.SettingDefinitionsModel
  75. {
  76. id: definitionsModel
  77. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  78. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  79. expanded: [ "*" ]
  80. exclude:
  81. {
  82. var excluded_settings = [ "machine_settings", "command_line_settings", "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ]
  83. excluded_settings = excluded_settings.concat(settingPickDialog.additional_excluded_settings)
  84. return excluded_settings
  85. }
  86. }
  87. delegate:Loader
  88. {
  89. id: loader
  90. width: parent.width
  91. height: model.type != undefined ? UM.Theme.getSize("section").height : 0
  92. property var definition: model
  93. property var settingDefinitionsModel: definitionsModel
  94. asynchronous: true
  95. source:
  96. {
  97. switch(model.type)
  98. {
  99. case "category":
  100. return "PerObjectCategory.qml"
  101. default:
  102. return "PerObjectItem.qml"
  103. }
  104. }
  105. }
  106. Component.onCompleted: settingPickDialog.updateFilter()
  107. }
  108. }
  109. rightButtons: [
  110. Button {
  111. text: catalog.i18nc("@action:button", "Close")
  112. onClicked: {
  113. settingPickDialog.visible = false
  114. }
  115. }
  116. ]
  117. }