Cura/resources/qml/Menus/MaterialMenu.qml
Ghostkeeper c0fc0a7eba
Disable material if not compatible
Similar to how it's displayed in the printer.

Contributes to issue CURA-5460.
2018-07-10 15:26:23 +02:00

100 lines
2.8 KiB
QML

// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.4
import UM 1.2 as UM
import Cura 1.0 as Cura
Menu
{
id: menu
title: "Material"
property int extruderIndex: 0
Instantiator
{
model: genericMaterialsModel
MenuItem
{
text: model.name
checkable: true
checked: model.root_material_id == Cura.MachineManager.currentRootMaterialId[extruderIndex]
enabled: model.compatible
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)
}
Cura.GenericMaterialsModel
{
id: genericMaterialsModel
extruderPosition: menu.extruderIndex
}
Cura.BrandMaterialsModel
{
id: brandModel
extruderPosition: menu.extruderIndex
}
ExclusiveGroup { id: group }
MenuSeparator { }
MenuItem { action: Cura.Actions.manageMaterials }
}