mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 06:23:59 -06:00
Add a menuitem to load the nozzle/material loaded on the printer
CURA-2276
This commit is contained in:
parent
151fcfdda6
commit
cf7a6730d1
4 changed files with 46 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue