mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
Add favorites to materials menu
Contributes to CURA-5162
This commit is contained in:
parent
57d41216e1
commit
e8cda90021
2 changed files with 95 additions and 66 deletions
|
@ -45,7 +45,7 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
metadata = container_node.metadata
|
||||
|
||||
# Only add results for favorite materials
|
||||
if metadata["id"] not in favorite_ids:
|
||||
if root_material_id not in favorite_ids:
|
||||
continue
|
||||
|
||||
# Do not include the materials from a to-be-removed package
|
||||
|
@ -66,5 +66,4 @@ class FavoriteMaterialsModel(BaseMaterialsModel):
|
|||
# Sort the item list by material name alphabetically
|
||||
item_list = sorted(item_list, key = lambda d: d["name"].upper())
|
||||
|
||||
print("FINAL FAVORITE LIST:", item_list)
|
||||
self.setItems(item_list)
|
||||
|
|
|
@ -14,68 +14,10 @@ Menu
|
|||
|
||||
property int extruderIndex: 0
|
||||
|
||||
Instantiator
|
||||
Cura.FavoriteMaterialsModel
|
||||
{
|
||||
model: genericMaterialsModel
|
||||
MenuItem
|
||||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
Cura.MachineManager.setMaterial(extruderIndex, model.container_node);
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
}
|
||||
MenuSeparator { }
|
||||
Instantiator
|
||||
{
|
||||
model: brandModel
|
||||
Menu
|
||||
{
|
||||
id: brandMenu
|
||||
title: brandName
|
||||
property string brandName: model.name
|
||||
property var brandMaterials: model.materials
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: brandMaterials
|
||||
Menu
|
||||
{
|
||||
id: brandMaterialsMenu
|
||||
title: materialName
|
||||
property string materialName: model.name
|
||||
property var brandMaterialColors: model.colors
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: brandMaterialColors
|
||||
MenuItem
|
||||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
Cura.MachineManager.setMaterial(extruderIndex, model.container_node);
|
||||
}
|
||||
}
|
||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
||||
}
|
||||
}
|
||||
onObjectAdded: brandMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMenu.removeItem(object)
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
id: favoriteMaterialsModel
|
||||
extruderPosition: menu.extruderIndex
|
||||
}
|
||||
|
||||
Cura.GenericMaterialsModel
|
||||
|
@ -90,9 +32,97 @@ Menu
|
|||
extruderPosition: menu.extruderIndex
|
||||
}
|
||||
|
||||
ExclusiveGroup { id: group }
|
||||
Instantiator
|
||||
{
|
||||
model: favoriteMaterialsModel
|
||||
delegate: MenuItem
|
||||
{
|
||||
text: model.brand + " " + model.name
|
||||
checkable: true
|
||||
checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex]
|
||||
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
|
||||
exclusiveGroup: group
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object) // TODO: This ain't gonna work, removeItem() takes an index, not object
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
MenuSeparator {}
|
||||
|
||||
MenuItem { action: Cura.Actions.manageMaterials }
|
||||
Menu
|
||||
{
|
||||
id: genericMenu
|
||||
title: "Generic"
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: genericMaterialsModel
|
||||
delegate: MenuItem
|
||||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex]
|
||||
exclusiveGroup: group
|
||||
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
|
||||
}
|
||||
onObjectAdded: genericMenu.insertItem(index, object)
|
||||
onObjectRemoved: genericMenu.removeItem(object) // TODO: This ain't gonna work, removeItem() takes an index, not object
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator {}
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: brandModel
|
||||
Menu
|
||||
{
|
||||
id: brandMenu
|
||||
title: brandName
|
||||
property string brandName: model.name
|
||||
property var brandMaterials: model.materials
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: brandMaterials
|
||||
delegate: Menu
|
||||
{
|
||||
id: brandMaterialsMenu
|
||||
title: materialName
|
||||
property string materialName: model.name
|
||||
property var brandMaterialColors: model.colors
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: brandMaterialColors
|
||||
delegate: MenuItem
|
||||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
|
||||
}
|
||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
||||
}
|
||||
}
|
||||
onObjectAdded: brandMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMenu.removeItem(object)
|
||||
}
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
}
|
||||
|
||||
ExclusiveGroup {
|
||||
id: group
|
||||
}
|
||||
|
||||
MenuSeparator {}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
action: Cura.Actions.manageMaterials
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue