123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- // 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: catalog.i18nc("@label:category menu label", "Material")
- property int extruderIndex: 0
- property string currentRootMaterialId: Cura.MachineManager.currentRootMaterialId[extruderIndex]
- property string activeMaterialId: Cura.MachineManager.allActiveMaterialIds[Cura.ExtruderManager.extruderIds[extruderIndex]]
- property bool updateModels: true
- Cura.FavoriteMaterialsModel
- {
- id: favoriteMaterialsModel
- extruderPosition: menu.extruderIndex
- enabled: updateModels
- }
- Cura.GenericMaterialsModel
- {
- id: genericMaterialsModel
- extruderPosition: menu.extruderIndex
- enabled: updateModels
- }
- Cura.MaterialBrandsModel
- {
- id: brandModel
- extruderPosition: menu.extruderIndex
- enabled: updateModels
- }
- MenuItem
- {
- text: catalog.i18nc("@label:category menu label", "Favorites")
- enabled: false
- visible: favoriteMaterialsModel.items.length > 0
- }
- Instantiator
- {
- model: favoriteMaterialsModel
- delegate: MenuItem
- {
- text: model.brand + " " + model.name
- checkable: true
- checked: model.root_material_id === menu.currentRootMaterialId
- 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 {}
- Menu
- {
- id: genericMenu
- title: catalog.i18nc("@label:category menu label", "Generic")
- Instantiator
- {
- model: genericMaterialsModel
- delegate: MenuItem
- {
- text: model.name
- checkable: true
- checked: model.root_material_id === menu.currentRootMaterialId
- 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.material_types
- 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 === menu.activeMaterialId
- 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
- }
- }
|