SettingPickDialog.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import QtQuick 2.2
  2. import QtQuick.Controls 1.2
  3. import QtQuick.Controls.Styles 1.2
  4. import UM 1.5 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. UM.CheckBox
  48. {
  49. id: toggleShowAll
  50. anchors
  51. {
  52. top: parent.top
  53. right: parent.right
  54. verticalCenter: filterInput.verticalCenter
  55. }
  56. text: catalog.i18nc("@label:checkbox", "Show all")
  57. }
  58. ScrollView
  59. {
  60. id: scrollView
  61. anchors
  62. {
  63. top: filterInput.bottom
  64. left: parent.left
  65. right: parent.right
  66. bottom: parent.bottom
  67. }
  68. ListView
  69. {
  70. id: listview
  71. model: UM.SettingDefinitionsModel
  72. {
  73. id: definitionsModel
  74. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  75. visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
  76. expanded: [ "*" ]
  77. exclude:
  78. {
  79. var excluded_settings = [ "machine_settings", "command_line_settings", "support_mesh", "anti_overhang_mesh", "cutting_mesh", "infill_mesh" ]
  80. excluded_settings = excluded_settings.concat(settingPickDialog.additional_excluded_settings)
  81. return excluded_settings
  82. }
  83. showAll: toggleShowAll.checked || filterInput.text !== ""
  84. }
  85. delegate: Loader
  86. {
  87. id: loader
  88. width: listview.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. }