mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-30 15:54:32 +08:00
Fix setting material of non-active extruder through menu
This commit is contained in:
parent
975e7f04b4
commit
8d72ba5fe7
@ -39,17 +39,20 @@ Menu
|
|||||||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
|
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
var material_id = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
|
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||||
|
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||||
|
var materialId = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
|
||||||
var items = materialsModel.items;
|
var items = materialsModel.items;
|
||||||
// materialsModel.find cannot be used because we need to look inside the metadata property of items
|
// materialsModel.find cannot be used because we need to look inside the metadata property of items
|
||||||
for(var i in items)
|
for(var i in items)
|
||||||
{
|
{
|
||||||
if (items[i]["metadata"]["GUID"] == material_id)
|
if (items[i]["metadata"]["GUID"] == materialId)
|
||||||
{
|
{
|
||||||
Cura.MachineManager.setActiveMaterial(items[i].id);
|
Cura.MachineManager.setActiveMaterial(items[i].id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +67,15 @@ Menu
|
|||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
text: model.name
|
text: model.name
|
||||||
checkable: true;
|
checkable: true
|
||||||
checked: model.id == Cura.MachineManager.activeMaterialId;
|
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||||
exclusiveGroup: group;
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
|
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||||
|
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||||
Cura.MachineManager.setActiveMaterial(model.id);
|
Cura.MachineManager.setActiveMaterial(model.id);
|
||||||
|
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onObjectAdded: menu.insertItem(index, object)
|
onObjectAdded: menu.insertItem(index, object)
|
||||||
@ -102,12 +108,15 @@ Menu
|
|||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
text: model.name
|
text: model.name
|
||||||
checkable: true;
|
checkable: true
|
||||||
checked: model.id == Cura.MachineManager.activeMaterialId;
|
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||||
exclusiveGroup: group;
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
|
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||||
|
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||||
Cura.MachineManager.setActiveMaterial(model.id);
|
Cura.MachineManager.setActiveMaterial(model.id);
|
||||||
|
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user