ProfileMenu.qml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.4
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. Menu
  8. {
  9. id: menu
  10. Instantiator
  11. {
  12. model: Cura.QualityProfilesDropDownMenuModel
  13. MenuItem
  14. {
  15. text:
  16. {
  17. var full_text = (model.layer_height != "") ? model.name + " - " + model.layer_height + model.layer_height_unit : model.name
  18. full_text += model.is_experimental ? " - " + catalog.i18nc("@label", "Experimental") : ""
  19. return full_text
  20. }
  21. checkable: true
  22. checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name
  23. exclusiveGroup: group
  24. onTriggered: Cura.MachineManager.setQualityGroup(model.quality_group)
  25. visible: model.available
  26. }
  27. onObjectAdded: menu.insertItem(index, object)
  28. onObjectRemoved: menu.removeItem(object)
  29. }
  30. MenuSeparator
  31. {
  32. id: customSeparator
  33. visible: Cura.CustomQualityProfilesDropDownMenuModel.count > 0
  34. }
  35. Instantiator
  36. {
  37. id: customProfileInstantiator
  38. model: Cura.CustomQualityProfilesDropDownMenuModel
  39. Connections
  40. {
  41. target: Cura.CustomQualityProfilesDropDownMenuModel
  42. onModelReset: customSeparator.visible = Cura.CustomQualityProfilesDropDownMenuModel.count > 0
  43. }
  44. MenuItem
  45. {
  46. text: model.name
  47. checkable: true
  48. checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name
  49. exclusiveGroup: group
  50. onTriggered: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group)
  51. }
  52. onObjectAdded:
  53. {
  54. customSeparator.visible = model.count > 0;
  55. menu.insertItem(index, object);
  56. }
  57. onObjectRemoved:
  58. {
  59. customSeparator.visible = model.count > 0;
  60. menu.removeItem(object);
  61. }
  62. }
  63. ExclusiveGroup { id: group; }
  64. MenuSeparator { id: profileMenuSeparator }
  65. MenuItem { action: Cura.Actions.addProfile }
  66. MenuItem { action: Cura.Actions.updateProfile }
  67. MenuItem { action: Cura.Actions.resetProfile }
  68. MenuSeparator { }
  69. MenuItem { action: Cura.Actions.manageProfiles }
  70. }