diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 11b55e8507..1503fb5f39 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -48,6 +48,8 @@ from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") from cura.Settings.GlobalStack import GlobalStack if TYPE_CHECKING: + from PyQt6.QtCore import QVariantList + from cura.CuraApplication import CuraApplication from cura.Machines.MaterialNode import MaterialNode from cura.Machines.QualityChangesGroup import QualityChangesGroup @@ -581,6 +583,10 @@ class MachineManager(QObject): def activeMachine(self) -> Optional["GlobalStack"]: return self._global_container_stack + @pyqtProperty("QVariantList", notify=activeVariantChanged) + def activeMachineExtruders(self) -> Optional["QVariantList"]: + return self._global_container_stack.extruderList if self._global_container_stack else None + @pyqtProperty(str, notify = activeStackChanged) def activeStackId(self) -> str: if self._active_container_stack: diff --git a/resources/qml/Menus/NozzleMenu.qml b/resources/qml/Menus/NozzleMenu.qml index f286410a11..a91f32a190 100644 --- a/resources/qml/Menus/NozzleMenu.qml +++ b/resources/qml/Menus/NozzleMenu.qml @@ -27,24 +27,17 @@ Cura.Menu { text: model.hotend_name checkable: true - property var activeMachine: Cura.MachineManager.activeMachine checked: { - if (activeMachine === null) - { - return false - } - var extruder = activeMachine.extruderList[extruderIndex] - return (extruder === undefined) ? false : (extruder.variant.name == model.hotend_name) + const extruder = Cura.MachineManager.activeMachineExtruders[extruderIndex]; + if (!extruder) return false; + return extruder.variant.name == model.hotend_name; } enabled: { - if (activeMachine === null) - { - return false - } - var extruder = activeMachine.extruderList[extruderIndex] - return (extruder === undefined) ? false : extruder.isEnabled + const extruder = Cura.MachineManager.activeMachineExtruders[extruderIndex]; + if (!extruder) return false; + return extruder.isEnabled; } onTriggered: Cura.MachineManager.setVariant(nozzleMenu.extruderIndex, model.container_node) } @@ -52,5 +45,4 @@ Cura.Menu onObjectAdded: function(index, object) { nozzleMenu.insertItem(index, object) } onObjectRemoved: function(index, object) {nozzleMenu.removeItem(object)} } - }