NozzleMenu.qml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2017 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.2
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. Menu
  8. {
  9. id: menu
  10. title: "Nozzle"
  11. property int extruderIndex: 0
  12. Cura.NozzleModel
  13. {
  14. id: nozzleModel
  15. }
  16. Instantiator
  17. {
  18. model: nozzleModel
  19. MenuItem
  20. {
  21. text: model.hotend_name
  22. checkable: true
  23. checked: {
  24. var activeMachine = Cura.MachineManager.activeMachine
  25. if (activeMachine === null)
  26. {
  27. return false
  28. }
  29. var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex]
  30. return (extruder === undefined) ? false : (extruder.variant.name == model.hotend_name)
  31. }
  32. exclusiveGroup: group
  33. enabled:
  34. {
  35. var activeMachine = Cura.MachineManager.activeMachine
  36. if (activeMachine === null)
  37. {
  38. return false
  39. }
  40. var extruder = Cura.MachineManager.activeMachine.extruderList[extruderIndex]
  41. return (extruder === undefined) ? false : extruder.isEnabled
  42. }
  43. onTriggered: {
  44. Cura.MachineManager.setVariant(menu.extruderIndex, model.container_node);
  45. }
  46. }
  47. onObjectAdded: menu.insertItem(index, object);
  48. onObjectRemoved: menu.removeItem(object);
  49. }
  50. ExclusiveGroup { id: group }
  51. }