mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 05:53:59 -06:00
Move branded materials into a submenu
CURA-2194
This commit is contained in:
parent
13e9a4f1a5
commit
0799a9e278
1 changed files with 92 additions and 17 deletions
|
@ -16,23 +16,7 @@ Menu
|
|||
{
|
||||
model: UM.InstanceContainersModel
|
||||
{
|
||||
filter:
|
||||
{
|
||||
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
|
||||
}
|
||||
filter: materialFilter("Generic")
|
||||
}
|
||||
MenuItem
|
||||
{
|
||||
|
@ -48,10 +32,101 @@ Menu
|
|||
onObjectAdded: menu.insertItem(index, 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 }
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
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…
Add table
Add a link
Reference in a new issue