mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 11:06:01 +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
|
title: model.name
|
||||||
visible: machineExtruderCount.properties.value > 1
|
visible: machineExtruderCount.properties.value > 1
|
||||||
|
|
||||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants }
|
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
|
||||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials }
|
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
|
||||||
ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); }
|
ProfileMenu { title: catalog.i18nc("@title:menu", "&Profile"); }
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
|
@ -12,11 +12,32 @@ Menu
|
|||||||
id: menu
|
id: menu
|
||||||
title: "Material"
|
title: "Material"
|
||||||
|
|
||||||
|
property int extruderIndex: 0
|
||||||
|
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||||
|
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
id: automaticMaterial
|
id: automaticMaterial
|
||||||
text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[material_name]")
|
text:
|
||||||
visible: false
|
{
|
||||||
|
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
|
MenuSeparator
|
||||||
|
@ -12,11 +12,27 @@ Menu
|
|||||||
id: menu
|
id: menu
|
||||||
title: "Nozzle"
|
title: "Nozzle"
|
||||||
|
|
||||||
|
property int extruderIndex: 0
|
||||||
|
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||||
|
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
id: automaticNozzle
|
id: automaticNozzle
|
||||||
text: catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg("[nozzle_name]")
|
text:
|
||||||
visible: false
|
{
|
||||||
|
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
|
MenuSeparator
|
||||||
@ -26,6 +42,7 @@ Menu
|
|||||||
|
|
||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
|
id: nozzleInstantiator
|
||||||
model: UM.InstanceContainersModel
|
model: UM.InstanceContainersModel
|
||||||
{
|
{
|
||||||
filter:
|
filter:
|
||||||
|
@ -223,7 +223,7 @@ Column
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
style: UM.Theme.styles.sidebar_header_button
|
style: UM.Theme.styles.sidebar_header_button
|
||||||
|
|
||||||
menu: NozzleMenu { }
|
menu: NozzleMenu { extruderIndex: base.currentExtruderIndex }
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
@ -251,7 +251,7 @@ Column
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
style: UM.Theme.styles.sidebar_header_button
|
style: UM.Theme.styles.sidebar_header_button
|
||||||
|
|
||||||
menu: MaterialMenu { }
|
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user