SettingPickDialog.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. }
  57. ScrollView
  58. {
  59. id: scrollView
  60. anchors
  61. {
  62. top: filterInput.bottom
  63. left: parent.left
  64. right: parent.right
  65. bottom: parent.bottom
  66. }
  67. ListView
  68. {
  69. id: listview
  70. model: UM.SettingDefinitionsModel
  71. {
  72. id: definitionsModel
  73. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  74. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  75. expanded: [ "*" ]
  76. exclude:
  77. {
  78. var excluded_settings = [ "machine_settings", "command_line_settings", "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ]
  79. excluded_settings = excluded_settings.concat(settingPickDialog.additional_excluded_settings)
  80. return excluded_settings
  81. }
  82. showAll: toggleShowAll.checked || filterInput.text !== ""
  83. }
  84. delegate: Loader
  85. {
  86. id: loader
  87. width: listview.width
  88. height: model.type != undefined ? UM.Theme.getSize("section").height : 0
  89. property var definition: model
  90. property var settingDefinitionsModel: definitionsModel
  91. asynchronous: true
  92. source:
  93. {
  94. switch(model.type)
  95. {
  96. case "category":
  97. return "PerObjectCategory.qml"
  98. default:
  99. return "PerObjectItem.qml"
  100. }
  101. }
  102. }
  103. Component.onCompleted: settingPickDialog.updateFilter()
  104. }
  105. }
  106. rightButtons: [
  107. Button
  108. {
  109. text: catalog.i18nc("@action:button", "Close")
  110. onClicked: settingPickDialog.visible = false
  111. }
  112. ]
  113. }