add Copy all values to all extruders

context menu option
This commit is contained in:
Guillem 2018-03-13 12:31:03 +01:00
parent 73517cd176
commit 1bb5b8ff3e
2 changed files with 21 additions and 0 deletions

View file

@ -550,6 +550,18 @@ class MachineManager(QObject):
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value: if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
extruder_stack.userChanges.setProperty(key, "value", new_value) # TODO: nested property access, should be improved extruder_stack.userChanges.setProperty(key, "value", new_value) # TODO: nested property access, should be improved
## Copy the value of all settings of the current extruder to all other extruders as well as the global container.
@pyqtSlot()
def copyAllValuesToExtruders(self):
for key in self._active_container_stack.getAllKeys():
new_value = self._active_container_stack.getProperty(key, "value")
extruder_stacks = [stack for stack in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())]
# check in which stack the value has to be replaced
for extruder_stack in extruder_stacks:
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
extruder_stack.userChanges.setProperty(key, "value", new_value) # TODO: nested property access, should be improved
@pyqtProperty(str, notify = activeVariantChanged) @pyqtProperty(str, notify = activeVariantChanged)
def activeVariantName(self) -> str: def activeVariantName(self) -> str:
if self._active_container_stack: if self._active_container_stack:

View file

@ -485,6 +485,15 @@ Item
onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key) onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key)
} }
MenuItem
{
//: Settings context menu action
text: catalog.i18nc("@action:menu", "Copy all values to all extruders")
visible: machineExtruderCount.properties.value > 1
enabled: contextMenu.provider != undefined
onTriggered: Cura.MachineManager.copyAllValuesToExtruders()
}
MenuSeparator MenuSeparator
{ {
visible: machineExtruderCount.properties.value > 1 visible: machineExtruderCount.properties.value > 1