MaterialMenu.qml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. title: "Material"
  11. property int extruderIndex: 0
  12. Instantiator
  13. {
  14. model: genericMaterialsModel
  15. MenuItem
  16. {
  17. text: model.name
  18. checkable: true
  19. checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex]
  20. exclusiveGroup: group
  21. onTriggered:
  22. {
  23. Cura.MachineManager.setMaterial(extruderIndex, model.container_node);
  24. }
  25. }
  26. onObjectAdded: menu.insertItem(index, object)
  27. onObjectRemoved: menu.removeItem(object)
  28. }
  29. MenuSeparator { }
  30. Instantiator
  31. {
  32. model: brandModel
  33. Menu
  34. {
  35. id: brandMenu
  36. title: brandName
  37. property string brandName: model.name
  38. property var brandMaterials: model.materials
  39. Instantiator
  40. {
  41. model: brandMaterials
  42. Menu
  43. {
  44. id: brandMaterialsMenu
  45. title: materialName
  46. property string materialName: model.name
  47. property var brandMaterialColors: model.colors
  48. Instantiator
  49. {
  50. model: brandMaterialColors
  51. MenuItem
  52. {
  53. text: model.name
  54. checkable: true
  55. checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
  56. exclusiveGroup: group
  57. onTriggered:
  58. {
  59. Cura.MachineManager.setMaterial(extruderIndex, model.container_node);
  60. }
  61. }
  62. onObjectAdded: brandMaterialsMenu.insertItem(index, object)
  63. onObjectRemoved: brandMaterialsMenu.removeItem(object)
  64. }
  65. }
  66. onObjectAdded: brandMenu.insertItem(index, object)
  67. onObjectRemoved: brandMenu.removeItem(object)
  68. }
  69. }
  70. onObjectAdded: menu.insertItem(index, object)
  71. onObjectRemoved: menu.removeItem(object)
  72. }
  73. Cura.GenericMaterialsModel
  74. {
  75. id: genericMaterialsModel
  76. extruderPosition: menu.extruderIndex
  77. }
  78. Cura.BrandMaterialsModel
  79. {
  80. id: brandModel
  81. extruderPosition: menu.extruderIndex
  82. }
  83. ExclusiveGroup { id: group }
  84. MenuSeparator { }
  85. MenuItem { action: Cura.Actions.manageMaterials }
  86. }