Replace material sub-menus with custom Popup

The sub-menus were giving segfaults for some reason. We couldn't figure out how to circumvent that. So now we're at a last resort: Implement the whole thing ourselves, but with Popup instead of Menu.

Contributes to issue CURA-8640.
This commit is contained in:
Ghostkeeper 2022-04-08 11:57:03 +02:00
parent 4abdd675f6
commit 11b557b3d9
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
3 changed files with 108 additions and 38 deletions

View file

@ -98,45 +98,12 @@ Cura.Menu
Instantiator
{
model: brandModel
Cura.Menu
delegate: Cura.MaterialBrandMenu
{
id: brandMenu
title: brandName
property string brandName: model.name
property var brandMaterials: model.material_types
Instantiator
{
model: brandMaterials
delegate: Cura.Menu
{
id: brandMaterialsMenu
title: materialName
property string materialName: model.name
property var brandMaterialColors: model.colors
Instantiator
{
model: brandMaterialColors
delegate: Cura.MenuItem
{
text: model.name
checkable: true
enabled: isActiveExtruderEnabled
checked: model.id === materialMenu.activeMaterialId
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
}
onObjectAdded: function(index, object) { brandMaterialsMenu.insertItem(index, object)}
onObjectRemoved: function(object) {brandMaterialsMenu.removeItem(object)}
}
}
onObjectAdded: function(index, object) { brandMenu.insertMenu(index, object)}
onObjectRemoved: function(object) {brandMenu.removeMenu(object)}
}
text: model.name
}
onObjectAdded: function(index, object) {materialMenu.insertMenu(index + 4, object)}
onObjectRemoved: function(object) { materialMenu.removeMenu(object)}
onObjectAdded: function(index, object) { materialMenu.insertItem(index + 4, object)}
onObjectRemoved: function(object) { materialMenu.removeItem(index) }
}
Cura.MenuSeparator {}