mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Changing the material is now possible
CURA-1278
This commit is contained in:
parent
89c0644e4b
commit
f5e63f2e71
2 changed files with 17 additions and 4 deletions
|
@ -17,8 +17,14 @@ class MachineManagerModel(QObject):
|
|||
activeMaterialChanged = pyqtSignal()
|
||||
|
||||
def _onGlobalContainerChanged(self):
|
||||
Application.getInstance().getGlobalContainerStack().containersChanged.connect(self._onInstanceContainersChanged)
|
||||
self.globalContainerChanged.emit()
|
||||
|
||||
def _onInstanceContainersChanged(self, container):
|
||||
container_type = container.getMetaDataEntry("type")
|
||||
if container_type == "material":
|
||||
self.activeMaterialChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveMachine(self, stack_id):
|
||||
containers = ContainerRegistry.getInstance().findContainerStacks(id = stack_id)
|
||||
|
@ -61,6 +67,13 @@ class MachineManagerModel(QObject):
|
|||
if material:
|
||||
return material.getName()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveMaterial(self, material_id):
|
||||
containers = ContainerRegistry.getInstance().findInstanceContainers(id=material_id)
|
||||
old_material = Application.getInstance().getGlobalContainerStack().findContainer({"type":"material"})
|
||||
material_index = Application.getInstance().getGlobalContainerStack().getContainerIndex(old_material)
|
||||
Application.getInstance().getGlobalContainerStack().replaceContainer(material_index, containers[0])
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def renameMachine(self, machine_id, new_name):
|
||||
containers = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||
|
|
|
@ -201,14 +201,14 @@ Item
|
|||
exclusiveGroup: materialSelectionMenuGroup;
|
||||
onTriggered:
|
||||
{
|
||||
UM.MachineManager.setActiveMaterial(machineMaterialsModel.getItem(index).name);
|
||||
if (typeof(model) !== "undefined" && !model.active) {
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
/*if (typeof(model) !== "undefined" && !model.active) {
|
||||
//Selecting a material was canceled; undo menu selection
|
||||
materialSelectionInstantiator.model.setProperty(index, "active", false);
|
||||
var activeMaterialName = UM.MachineManager.activeMaterial;
|
||||
var activeMaterialName = Cura.MachineManager.activeMaterialName
|
||||
var activeMaterialIndex = materialSelectionInstantiator.model.find("name", activeMaterialName);
|
||||
materialSelectionInstantiator.model.setProperty(activeMaterialIndex, "active", true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
onObjectAdded: materialSelectionMenu.insertItem(index, object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue