SettingPickDialog.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. listview.model.forceUpdate()
  19. updateFilter()
  20. }
  21. }
  22. function updateFilter()
  23. {
  24. var new_filter = {}
  25. new_filter["settable_per_mesh"] = true
  26. // Don't filter on "settable_per_meshgroup" any more when `printSequencePropertyProvider.properties.value`
  27. // is set to "one_at_a_time", because the current backend architecture isn't ready for that.
  28. if (filterInput.text != "")
  29. {
  30. new_filter["i18n_label"] = "*" + filterInput.text
  31. }
  32. listview.model.filter = new_filter
  33. }
  34. TextField
  35. {
  36. id: filterInput
  37. anchors
  38. {
  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. {
  52. top: parent.top
  53. right: parent.right
  54. }
  55. text: catalog.i18nc("@label:checkbox", "Show all")
  56. checked: listview.model.showAll
  57. onClicked: listview.model.showAll = checked
  58. }
  59. ScrollView
  60. {
  61. id: scrollView
  62. anchors
  63. {
  64. top: filterInput.bottom
  65. left: parent.left
  66. right: parent.right
  67. bottom: parent.bottom
  68. }
  69. ListView
  70. {
  71. id:listview
  72. model: UM.SettingDefinitionsModel
  73. {
  74. id: definitionsModel
  75. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  76. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  77. expanded: [ "*" ]
  78. exclude:
  79. {
  80. var excluded_settings = [ "machine_settings", "command_line_settings", "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ]
  81. excluded_settings = excluded_settings.concat(settingPickDialog.additional_excluded_settings)
  82. return excluded_settings
  83. }
  84. }
  85. delegate:Loader
  86. {
  87. id: loader
  88. width: parent.width
  89. height: model.type != undefined ? UM.Theme.getSize("section").height : 0
  90. property var definition: model
  91. property var settingDefinitionsModel: definitionsModel
  92. asynchronous: true
  93. source:
  94. {
  95. switch(model.type)
  96. {
  97. case "category":
  98. return "PerObjectCategory.qml"
  99. default:
  100. return "PerObjectItem.qml"
  101. }
  102. }
  103. }
  104. Component.onCompleted: settingPickDialog.updateFilter()
  105. }
  106. }
  107. rightButtons: [
  108. Button
  109. {
  110. text: catalog.i18nc("@action:button", "Close")
  111. onClicked: settingPickDialog.visible = false
  112. }
  113. ]
  114. }