diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py index c27f8db4a6..1feb748006 100644 --- a/plugins/MachineSettingsAction/MachineSettingsAction.py +++ b/plugins/MachineSettingsAction/MachineSettingsAction.py @@ -29,6 +29,7 @@ class MachineSettingsAction(MachineAction): self._container_registry = ContainerRegistry.getInstance() self._container_registry.containerAdded.connect(self._onContainerAdded) + Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged) def _reset(self): global_container_stack = Application.getInstance().getGlobalContainerStack() @@ -67,13 +68,21 @@ class MachineSettingsAction(MachineAction): def _onContainerAdded(self, container): # Add this action as a supported action to all machine definitions if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine": - if container.getProperty("machine_extruder_count", "value") > 1: - # Multiextruder printers are not currently supported - Logger.log("d", "Not attaching MachineSettingsAction to %s; Multi-extrusion printers are not supported", container.getId()) - return - Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey()) + def _onGlobalContainerChanged(self): + self.globalContainerChanged.emit() + + globalContainerChanged = pyqtSignal() + + @pyqtProperty(int, notify = globalContainerChanged) + def definedExtruderCount(self): + global_container_stack = Application.getInstance().getGlobalContainerStack() + if not global_container_stack: + return 0 + + return len(global_container_stack.getMetaDataEntry("machine_extruder_trains")) + @pyqtSlot() def forceUpdate(self): # Force rebuilding the build volume by reloading the global container stack. diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.qml b/plugins/MachineSettingsAction/MachineSettingsAction.qml index 26bbccd44a..4dfb7548d6 100644 --- a/plugins/MachineSettingsAction/MachineSettingsAction.qml +++ b/plugins/MachineSettingsAction/MachineSettingsAction.qml @@ -345,6 +345,35 @@ Cura.MachineAction Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height } Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height } + Label + { + text: catalog.i18nc("@label", "Number of Extruders") + } + + ComboBox + { + id: extruderCountComboBox + model: ListModel + { + id: extruderCountModel + Component.onCompleted: + { + for(var i = 0; i < manager.definedExtruderCount; i++) + { + extruderCountModel.append({text: String(i + 1), value: i}); + } + } + } + currentIndex: machineExtruderCountProvider.properties.value - 1 + onActivated: + { + machineExtruderCountProvider.setPropertyValue("value", index + 1); + manager.forceUpdate(); + } + } + Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height } + + Label { text: catalog.i18nc("@label", "Nozzle size") @@ -532,6 +561,16 @@ Cura.MachineAction storeIndex: manager.containerIndex } + UM.SettingPropertyProvider + { + id: machineExtruderCountProvider + + containerStackId: Cura.MachineManager.activeMachineId + key: "machine_extruder_count" + watchedProperties: [ "value" ] + storeIndex: manager.containerIndex + } + UM.SettingPropertyProvider { id: gantryHeightProvider