NozzleMenu.qml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.4
  5. import UM 1.5 as UM
  6. import Cura 1.0 as Cura
  7. Cura.Menu
  8. {
  9. id: nozzleMenu
  10. title: "Nozzle"
  11. property int extruderIndex: 0
  12. Cura.NozzleModel
  13. {
  14. id: nozzleModel
  15. }
  16. Instantiator
  17. {
  18. model: nozzleModel
  19. Cura.MenuItem
  20. {
  21. text: model.hotend_name
  22. checkable: true
  23. property var activeMachine: Cura.MachineManager.activeMachine
  24. checked:
  25. {
  26. if (activeMachine === null)
  27. {
  28. return false
  29. }
  30. var extruder = activeMachine.extruderList[extruderIndex]
  31. return (extruder === undefined) ? false : (extruder.variant.name == model.hotend_name)
  32. }
  33. enabled:
  34. {
  35. if (activeMachine === null)
  36. {
  37. return false
  38. }
  39. var extruder = activeMachine.extruderList[extruderIndex]
  40. return (extruder === undefined) ? false : extruder.isEnabled
  41. }
  42. onTriggered: Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node)
  43. }
  44. onObjectAdded: function(index, object) { nozzleMenu.insertItem(index, object) }
  45. onObjectRemoved: function(index, object) {nozzleMenu.removeItem(object)}
  46. }
  47. }