mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-30 18:15:59 +08:00

This commit adds a button "Add more materials from Marketplace" in the menu that pops up in the material list while configuring the materials into custom ones. The button redirects the user to the Marketplace materials page (https://marketplace.ultimaker.com/app/cura/materials) CURA-7027
168 lines
4.8 KiB
QML
168 lines
4.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: catalog.i18nc("@label:category menu label", "Material")
|
|
|
|
property int extruderIndex: 0
|
|
property string currentRootMaterialId:
|
|
{
|
|
var value = Cura.MachineManager.currentRootMaterialId[extruderIndex]
|
|
return (value === undefined) ? "" : value
|
|
}
|
|
property var activeExtruder:
|
|
{
|
|
var activeMachine = Cura.MachineManager.activeMachine
|
|
return (activeMachine === null) ? null : activeMachine.extruderList[extruderIndex]
|
|
}
|
|
property bool isActiveExtruderEnabled: activeExtruder === null ? false : activeExtruder.isEnabled
|
|
|
|
property string activeMaterialId: activeExtruder === null ? false : activeExtruder.material.id
|
|
|
|
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
|
|
enabled: isActiveExtruderEnabled
|
|
checked: model.root_material_id === menu.currentRootMaterialId
|
|
onTriggered: Cura.MachineManager.setMaterial(extruderIndex, model.container_node)
|
|
exclusiveGroup: favoriteGroup // One favorite and one item from the others can be active at the same time.
|
|
}
|
|
onObjectAdded: menu.insertItem(index, object)
|
|
onObjectRemoved: menu.removeItem(index)
|
|
}
|
|
|
|
MenuSeparator {}
|
|
|
|
Menu
|
|
{
|
|
id: genericMenu
|
|
title: catalog.i18nc("@label:category menu label", "Generic")
|
|
|
|
Instantiator
|
|
{
|
|
model: genericMaterialsModel
|
|
delegate: MenuItem
|
|
{
|
|
text: model.name
|
|
checkable: true
|
|
enabled: isActiveExtruderEnabled
|
|
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(index)
|
|
}
|
|
}
|
|
|
|
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
|
|
enabled: isActiveExtruderEnabled
|
|
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
|
|
}
|
|
|
|
ExclusiveGroup
|
|
{
|
|
id: favoriteGroup
|
|
}
|
|
|
|
MenuSeparator {}
|
|
|
|
MenuItem
|
|
{
|
|
action: Cura.Actions.manageMaterials
|
|
}
|
|
|
|
MenuSeparator {}
|
|
|
|
MenuItem
|
|
{
|
|
action: Cura.Actions.marketplaceMaterials
|
|
}
|
|
}
|