mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 12:46:01 +08:00
Move branded materials into a submenu
CURA-2194
This commit is contained in:
parent
13e9a4f1a5
commit
0799a9e278
@ -16,23 +16,7 @@ Menu
|
|||||||
{
|
{
|
||||||
model: UM.InstanceContainersModel
|
model: UM.InstanceContainersModel
|
||||||
{
|
{
|
||||||
filter:
|
filter: materialFilter("Generic")
|
||||||
{
|
|
||||||
var result = { "type": "material" }
|
|
||||||
if(Cura.MachineManager.filterMaterialsByMachine)
|
|
||||||
{
|
|
||||||
result.definition = Cura.MachineManager.activeDefinitionId
|
|
||||||
if(Cura.MachineManager.hasVariants)
|
|
||||||
{
|
|
||||||
result.variant = Cura.MachineManager.activeVariantId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.definition = "fdmprinter"
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
@ -48,10 +32,101 @@ Menu
|
|||||||
onObjectAdded: menu.insertItem(index, object)
|
onObjectAdded: menu.insertItem(index, object)
|
||||||
onObjectRemoved: menu.removeItem(object)
|
onObjectRemoved: menu.removeItem(object)
|
||||||
}
|
}
|
||||||
|
MenuSeparator { }
|
||||||
|
Instantiator
|
||||||
|
{
|
||||||
|
model: brandModel
|
||||||
|
Menu
|
||||||
|
{
|
||||||
|
id: brandMenu
|
||||||
|
title: model.brandName
|
||||||
|
property string brand: model.brandName
|
||||||
|
|
||||||
|
Instantiator
|
||||||
|
{
|
||||||
|
model: UM.InstanceContainersModel
|
||||||
|
{
|
||||||
|
filter: materialFilter(brandMenu.brandName)
|
||||||
|
}
|
||||||
|
MenuItem
|
||||||
|
{
|
||||||
|
text: model.name
|
||||||
|
checkable: true;
|
||||||
|
checked: model.id == Cura.MachineManager.activeMaterialId;
|
||||||
|
exclusiveGroup: group;
|
||||||
|
onTriggered:
|
||||||
|
{
|
||||||
|
Cura.MachineManager.setActiveMaterial(model.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onObjectAdded: brandMenu.insertItem(index, object)
|
||||||
|
onObjectRemoved: brandMenu.removeItem(object)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onObjectAdded: menu.insertItem(index, object)
|
||||||
|
onObjectRemoved: menu.removeItem(object)
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel
|
||||||
|
{
|
||||||
|
id: brandModel
|
||||||
|
Component.onCompleted: populateBrandModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
//: Model used to populate the brandModel
|
||||||
|
UM.InstanceContainersModel
|
||||||
|
{
|
||||||
|
id: materialsModel
|
||||||
|
filter: materialFilter()
|
||||||
|
onDataChanged: populateBrandModel()
|
||||||
|
}
|
||||||
|
|
||||||
ExclusiveGroup { id: group }
|
ExclusiveGroup { id: group }
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
|
|
||||||
MenuItem { action: Cura.Actions.manageMaterials }
|
MenuItem { action: Cura.Actions.manageMaterials }
|
||||||
|
|
||||||
|
function populateBrandModel()
|
||||||
|
{
|
||||||
|
var brands = materialsModel.getUniqueValues("brand")
|
||||||
|
var material_types = materialsModel.getUniqueValues("material")
|
||||||
|
brandModel.clear();
|
||||||
|
for (var i in brands)
|
||||||
|
{
|
||||||
|
if(brands[i] != "Generic")
|
||||||
|
{
|
||||||
|
brandModel.append({
|
||||||
|
brandName: brands[i],
|
||||||
|
materials: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function materialFilter(brand, material)
|
||||||
|
{
|
||||||
|
var result = { "type": "material" }
|
||||||
|
if(brand != undefined)
|
||||||
|
{
|
||||||
|
result.brand = brand
|
||||||
|
}
|
||||||
|
if(material != undefined)
|
||||||
|
{
|
||||||
|
result.material = material
|
||||||
|
}
|
||||||
|
if(Cura.MachineManager.filterMaterialsByMachine)
|
||||||
|
{
|
||||||
|
result.definition = Cura.MachineManager.activeDefinitionId
|
||||||
|
if(Cura.MachineManager.hasVariants)
|
||||||
|
{
|
||||||
|
result.variant = Cura.MachineManager.activeVariantId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.definition = "fdmprinter"
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user