mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Add a context-menu item to copy a value to all extruders.
CURA-1758
This commit is contained in:
parent
89b601791d
commit
0857017ac6
2 changed files with 46 additions and 3 deletions
|
@ -505,6 +505,19 @@ class MachineManager(QObject):
|
||||||
return True
|
return True
|
||||||
return containers[0].isReadOnly()
|
return containers[0].isReadOnly()
|
||||||
|
|
||||||
|
## Copy the value of the setting of the current extruder to all other extruders as well as the global container.
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def copyValueToExtruders(self, key):
|
||||||
|
if not self._active_container_stack or self._global_container_stack.getProperty("machine_extruder_count", "value") <= 1:
|
||||||
|
return
|
||||||
|
|
||||||
|
new_value = self._active_container_stack.getProperty(key, "value")
|
||||||
|
stacks = [stack for stack in self._extruder_manager.getMachineExtruders(self._global_container_stack.getId())]
|
||||||
|
stacks.append(self._global_container_stack)
|
||||||
|
for extruder_stack in stacks:
|
||||||
|
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
|
||||||
|
extruder_stack.getTop().setProperty(key, "value", new_value)
|
||||||
|
|
||||||
@pyqtSlot(result = str)
|
@pyqtSlot(result = str)
|
||||||
def newQualityContainerFromQualityAndUser(self):
|
def newQualityContainerFromQualityAndUser(self):
|
||||||
new_container_id = self.duplicateContainer(self.activeQualityId)
|
new_container_id = self.duplicateContainer(self.activeQualityId)
|
||||||
|
|
|
@ -102,7 +102,12 @@ ScrollView
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: item
|
target: item
|
||||||
onContextMenuRequested: { contextMenu.key = model.key; contextMenu.popup() }
|
onContextMenuRequested:
|
||||||
|
{
|
||||||
|
contextMenu.key = model.key;
|
||||||
|
contextMenu.provider = provider
|
||||||
|
contextMenu.popup();
|
||||||
|
}
|
||||||
onShowTooltip: base.showTooltip(delegate, { x: 0, y: delegate.height / 2 }, text)
|
onShowTooltip: base.showTooltip(delegate, { x: 0, y: delegate.height / 2 }, text)
|
||||||
onHideTooltip: base.hideTooltip()
|
onHideTooltip: base.hideTooltip()
|
||||||
}
|
}
|
||||||
|
@ -134,9 +139,24 @@ ScrollView
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
{
|
{
|
||||||
id: contextMenu;
|
id: contextMenu
|
||||||
|
|
||||||
property string key;
|
property string key
|
||||||
|
property var provider
|
||||||
|
|
||||||
|
MenuItem
|
||||||
|
{
|
||||||
|
//: Settings context menu action
|
||||||
|
text: catalog.i18nc("@action:menu", "Copy value to all extruders")
|
||||||
|
visible: machineExtruderCount.properties.value > 1
|
||||||
|
enabled: contextMenu.provider.properties.settable_per_extruder != "False"
|
||||||
|
onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key)
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuSeparator
|
||||||
|
{
|
||||||
|
visible: machineExtruderCount.properties.value > 1
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
|
@ -152,5 +172,15 @@ ScrollView
|
||||||
onTriggered: Cura.Actions.configureSettingVisibility.trigger(contextMenu);
|
onTriggered: Cura.Actions.configureSettingVisibility.trigger(contextMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UM.SettingPropertyProvider
|
||||||
|
{
|
||||||
|
id: machineExtruderCount
|
||||||
|
|
||||||
|
containerStackId: Cura.MachineManager.activeMachineId
|
||||||
|
key: "machine_extruder_count"
|
||||||
|
watchedProperties: [ "value" ]
|
||||||
|
storeIndex: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue