mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 09:05:53 +08:00
Add a menuitem to load the nozzle/material loaded on the printer
CURA-2276
This commit is contained in:
parent
151fcfdda6
commit
cf7a6730d1
@ -145,8 +145,8 @@ UM.MainWindow
|
||||
title: model.name
|
||||
visible: machineExtruderCount.properties.value > 1
|
||||
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials }
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
|
||||
ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); }
|
||||
|
||||
MenuSeparator { }
|
||||
|
@ -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
|
||||
|
@ -12,11 +12,27 @@ Menu
|
||||
id: menu
|
||||
title: "Nozzle"
|
||||
|
||||
property int extruderIndex: 0
|
||||
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: automaticNozzle
|
||||
text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[nozzle_name]")
|
||||
visible: false
|
||||
text:
|
||||
{
|
||||
var nozzleName = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
|
||||
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(nozzleName);
|
||||
}
|
||||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex
|
||||
onTriggered:
|
||||
{
|
||||
var hotendId = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
|
||||
var itemIndex = nozzleInstantiator.model.find("name", hotendId);
|
||||
if(itemIndex > -1)
|
||||
{
|
||||
Cura.MachineManager.setActiveVariant(nozzleInstantiator.model.getItem(itemIndex).id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator
|
||||
@ -26,6 +42,7 @@ Menu
|
||||
|
||||
Instantiator
|
||||
{
|
||||
id: nozzleInstantiator
|
||||
model: UM.InstanceContainersModel
|
||||
{
|
||||
filter:
|
||||
|
@ -223,7 +223,7 @@ Column
|
||||
anchors.left: parent.left
|
||||
style: UM.Theme.styles.sidebar_header_button
|
||||
|
||||
menu: NozzleMenu { }
|
||||
menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
@ -251,7 +251,7 @@ Column
|
||||
anchors.right: parent.right
|
||||
style: UM.Theme.styles.sidebar_header_button
|
||||
|
||||
menu: MaterialMenu { }
|
||||
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user