diff --git a/cura/Settings/ExtrudersModel.py b/cura/Settings/ExtrudersModel.py index 26c05d3787..0ba6cdcfd6 100644 --- a/cura/Settings/ExtrudersModel.py +++ b/cura/Settings/ExtrudersModel.py @@ -46,6 +46,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self.addRoleName(self.IndexRole, "index") self._add_global = False + self._simple_names = False self._active_extruder_stack = None @@ -70,6 +71,21 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): def addGlobal(self): return self._add_global + ## Set the simpleNames property. + def setSimpleNames(self, simple_names): + if simple_names != self._simple_names: + self._simple_names = simple_names + self.simpleNamesChanged.emit() + self._updateExtruders() + + ## Emitted when the simpleNames property changes. + simpleNamesChanged = pyqtSignal() + + ## Whether or not the model should show all definitions regardless of visibility. + @pyqtProperty(bool, fset = setSimpleNames, notify = simpleNamesChanged) + def simpleNames(self): + return self._simple_names + def _onActiveExtruderChanged(self): manager = ExtruderManager.getInstance() active_extruder_stack = manager.getActiveExtruderStack() @@ -119,7 +135,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): for extruder in manager.getMachineExtruders(global_container_stack.getId()): extruder_name = extruder.getName() material = extruder.findContainer({ "type": "material" }) - if material: + if material and not self._simple_names: extruder_name = "%s (%s)" % (material.getName(), extruder_name) position = extruder.getMetaDataEntry("position", default = "0") # Get the position try: diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index f2967c7797..5a91bc1706 100644 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -124,22 +124,6 @@ class MachineManager(QObject): else: Logger.log("w", "No variant found for printer definition %s with id %s" % (self._global_container_stack.getBottom().getId(), hotend_id)) - def _autoUpdateHotends(self): - extruder_manager = ExtruderManager.getInstance() - for position in self._auto_hotends_changed: - hotend_id = self._auto_hotends_changed[position] - old_index = extruder_manager.activeExtruderIndex - - if old_index != int(position): - extruder_manager.setActiveExtruderIndex(int(position)) - else: - old_index = None - Logger.log("d", "Setting hotend variant of hotend %s to %s" % (position, hotend_id)) - self.setActiveVariant(hotend_id) - - if old_index is not None: - extruder_manager.setActiveExtruderIndex(old_index) - def _onMaterialIdChanged(self, index, material_id): if not self._global_container_stack: return @@ -189,6 +173,22 @@ class MachineManager(QObject): if old_index is not None: extruder_manager.setActiveExtruderIndex(old_index) + def _autoUpdateHotends(self): + extruder_manager = ExtruderManager.getInstance() + for position in self._auto_hotends_changed: + hotend_id = self._auto_hotends_changed[position] + old_index = extruder_manager.activeExtruderIndex + + if old_index != int(position): + extruder_manager.setActiveExtruderIndex(int(position)) + else: + old_index = None + Logger.log("d", "Setting hotend variant of hotend %s to %s" % (position, hotend_id)) + self.setActiveVariant(hotend_id) + + if old_index is not None: + extruder_manager.setActiveExtruderIndex(old_index) + def _onGlobalContainerChanged(self): if self._global_container_stack: self._global_container_stack.nameChanged.disconnect(self._onMachineNameChanged) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py index ff404c0398..a09ac4f3d7 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/Profile.py @@ -80,7 +80,7 @@ class Profile: import VersionUpgrade21to22 # Import here to prevent circular dependencies. if self._name == "Current settings": - return None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition. + return None, None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition. config = configparser.ConfigParser(interpolation = None) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py index 0b021467c4..286667f5b0 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py @@ -118,6 +118,12 @@ _profile_translations = { "tpu_0.6_fast": "um2p_tpu_0.6_fast" } +## Settings that are no longer in the new version. +_removed_settings = { + "fill_perimeter_gaps", + "support_area_smoothing" +} + ## How to translate setting names from the old version to the new. _setting_name_translations = { "remove_overlapping_walls_0_enabled": "travel_compensate_overlapping_walls_0_enabled", @@ -385,7 +391,7 @@ class VersionUpgrade21to22(VersionUpgrade): @staticmethod def translateSettings(settings): for key, value in settings.items(): - if key == "fill_perimeter_gaps": #Setting is removed. + if key in _removed_settings: del settings[key] elif key == "retraction_combing": #Combing was made into an enum instead of a boolean. settings[key] = "off" if (value == "False") else "all" diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index a3dda4d7c2..eba803ef28 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -145,8 +145,8 @@ UM.MainWindow title: model.name visible: machineExtruderCount.properties.value > 1 - NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants } - MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials } + NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index } + MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index } ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); } MenuSeparator { } diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index 03c951debd..d2e6bc03ce 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -12,11 +12,32 @@ Menu id: menu title: "Material" + property int extruderIndex: 0 + property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + MenuItem { id: automaticMaterial - text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[material_name]") - visible: false + text: + { + var materialName = Cura.MachineManager.printerOutputDevices[0].materialNames[extruderIndex]; + return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(materialName); + } + visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex + onTriggered: + { + var material_id = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex]; + var items = materialsModel.items; + // materialsModel.find cannot be used because we need to look inside the metadata property of items + for(var i in items) + { + if (items[i]["metadata"]["GUID"] == material_id) + { + Cura.MachineManager.setActiveMaterial(items[i].id); + break; + } + } + } } MenuSeparator diff --git a/resources/qml/Menus/NozzleMenu.qml b/resources/qml/Menus/NozzleMenu.qml index fa83c22af1..7f1c652c4a 100644 --- a/resources/qml/Menus/NozzleMenu.qml +++ b/resources/qml/Menus/NozzleMenu.qml @@ -12,11 +12,27 @@ Menu id: menu title: "Nozzle" + property int extruderIndex: 0 + property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + MenuItem { id: automaticNozzle - text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[nozzle_name]") - visible: false + text: + { + var nozzleName = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex]; + return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(nozzleName); + } + visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex + onTriggered: + { + var hotendId = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex]; + var itemIndex = nozzleInstantiator.model.find("name", hotendId); + if(itemIndex > -1) + { + Cura.MachineManager.setActiveVariant(nozzleInstantiator.model.getItem(itemIndex).id) + } + } } MenuSeparator @@ -26,6 +42,7 @@ Menu Instantiator { + id: nozzleInstantiator model: UM.InstanceContainersModel { filter: diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index 65f6626378..94e452444e 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -14,7 +14,6 @@ UM.ManagementPage title: catalog.i18nc("@title:tab", "Profiles"); property var extrudersModel: Cura.ExtrudersModel{} - //Cura.ExtrudersModel { id: extrudersModel} model: UM.InstanceContainersModel { @@ -167,11 +166,11 @@ UM.ManagementPage elide: Text.ElideRight } - Row { + Flow { id: currentSettingsActions visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId - anchors.left: parent.left + anchors.right: parent.right anchors.top: profileName.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 27b0e532d4..8d04122aa8 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -14,7 +14,11 @@ Column id: printMonitor property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null - Cura.ExtrudersModel { id: extrudersModel } + Cura.ExtrudersModel + { + id: extrudersModel + simpleNames: true + } Label { diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 47c0fea9e3..9ed30477d8 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -223,7 +223,7 @@ Column anchors.left: parent.left style: UM.Theme.styles.sidebar_header_button - menu: NozzleMenu { } + menu: NozzleMenu { extruderIndex: base.currentExtruderIndex } } ToolButton { @@ -251,7 +251,7 @@ Column anchors.right: parent.right style: UM.Theme.styles.sidebar_header_button - menu: MaterialMenu { } + menu: MaterialMenu { extruderIndex: base.currentExtruderIndex } } } }