SettingPickDialog.qml 3.8 KB

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