mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-16 15:35:54 +08:00
Update materials slot
CURA-8979
This commit is contained in:
parent
2dd440cc0c
commit
c6b8abd53e
@ -13,23 +13,31 @@ import Cura 1.5 as Cura
|
|||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
id: materialSlot
|
id: materialSlot
|
||||||
|
|
||||||
property var material: null
|
property var material: null
|
||||||
property var hovered: false
|
property bool hovered: false
|
||||||
property var is_favorite: material != null && material.is_favorite
|
|
||||||
|
|
||||||
height: UM.Theme.getSize("favorites_row").height
|
height: UM.Theme.getSize("favorites_row").height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color:
|
color: UM.Theme.getColor("main_background")
|
||||||
|
|
||||||
|
states:
|
||||||
|
[
|
||||||
|
State
|
||||||
{
|
{
|
||||||
if (material !== null && base.currentItem !== null)
|
name: "selected"
|
||||||
|
when: material !== null && base.currentItem !== null && base.currentItem.root_material_id === material.root_material_id
|
||||||
|
PropertyChanges { target: materialSlot; color: UM.Theme.getColor("background_3") }
|
||||||
|
PropertyChanges { target: materialLabel; font: UM.Theme.getFont("default_italic") }
|
||||||
|
},
|
||||||
|
State
|
||||||
{
|
{
|
||||||
if (base.currentItem.root_material_id === material.root_material_id)
|
name: "hovered"
|
||||||
{
|
when: hovered
|
||||||
return UM.Theme.getColor("favorites_row_selected");
|
PropertyChanges { target: materialSlot; color: UM.Theme.getColor("background_3") }
|
||||||
}
|
|
||||||
}
|
|
||||||
return "transparent";
|
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
id: swatch
|
id: swatch
|
||||||
@ -43,42 +51,73 @@ Rectangle
|
|||||||
}
|
}
|
||||||
UM.Label
|
UM.Label
|
||||||
{
|
{
|
||||||
text: material != null ? material.brand + " " + material.name : ""
|
id: materialLabel
|
||||||
|
text: material != null ? `${material.brand} ${material.name}` : ""
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
height: parent.height
|
|
||||||
anchors.left: swatch.right
|
anchors.left: swatch.right
|
||||||
anchors.verticalCenter: materialSlot.verticalCenter
|
anchors.verticalCenter: materialSlot.verticalCenter
|
||||||
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
|
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
font.italic: material != null && Cura.MachineManager.currentRootMaterialId[Cura.ExtruderManager.activeExtruderIndex] == material.root_material_id
|
font: UM.Theme.getFont("default")
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
materialList.currentBrand = material.brand
|
materialList.currentBrand = material.brand;
|
||||||
materialList.currentType = material.brand + "_" + material.material
|
materialList.currentType = `${material.brand}_${material.material}`;
|
||||||
base.setExpandedActiveMaterial(material.root_material_id)
|
base.setExpandedActiveMaterial(material.root_material_id);
|
||||||
}
|
}
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: { materialSlot.hovered = true }
|
onEntered: { materialSlot.hovered = true }
|
||||||
onExited: { materialSlot.hovered = false }
|
onExited: { materialSlot.hovered = false }
|
||||||
}
|
}
|
||||||
Button
|
|
||||||
|
Item
|
||||||
{
|
{
|
||||||
id: favorite_button
|
id: favoriteButton
|
||||||
text: ""
|
|
||||||
implicitWidth: UM.Theme.getSize("favorites_button").width
|
states:
|
||||||
implicitHeight: UM.Theme.getSize("favorites_button").height
|
[
|
||||||
visible: materialSlot.hovered || materialSlot.is_favorite || favorite_button.hovered
|
State
|
||||||
anchors
|
|
||||||
{
|
{
|
||||||
right: materialSlot.right
|
name: "favorite"
|
||||||
verticalCenter: materialSlot.verticalCenter
|
when: material !== null && material.is_favorite
|
||||||
|
PropertyChanges { target: favoriteIndicator; source: UM.Theme.getIcon("StarFilled"); color: UM.Theme.getColor("primary") }
|
||||||
|
PropertyChanges { target: favoriteButton; visible: true }
|
||||||
|
},
|
||||||
|
State
|
||||||
|
{
|
||||||
|
name: "hovered"
|
||||||
|
when: hovered
|
||||||
|
PropertyChanges { target: favoriteButton; visible: true }
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
implicitHeight: parent.height
|
||||||
|
implicitWidth: height
|
||||||
|
anchors.right: materialSlot.right
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
UM.RecolorImage
|
||||||
|
{
|
||||||
|
id: favoriteIndicator
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: UM.Theme.getSize("small_button_icon").width
|
||||||
|
height: UM.Theme.getSize("small_button_icon").height
|
||||||
|
color: UM.Theme.getColor("text_inactive")
|
||||||
|
source: UM.Theme.getIcon("Star")
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
anchors.fill: parent
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
if (materialSlot.is_favorite)
|
if (material !== null)
|
||||||
|
{
|
||||||
|
if (material.is_favorite)
|
||||||
{
|
{
|
||||||
CuraApplication.getMaterialManagementModel().removeFavorite(material.root_material_id)
|
CuraApplication.getMaterialManagementModel().removeFavorite(material.root_material_id)
|
||||||
}
|
}
|
||||||
@ -87,35 +126,7 @@ Rectangle
|
|||||||
CuraApplication.getMaterialManagementModel().addFavorite(material.root_material_id)
|
CuraApplication.getMaterialManagementModel().addFavorite(material.root_material_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.RecolorImage
|
|
||||||
{
|
|
||||||
anchors
|
|
||||||
{
|
|
||||||
verticalCenter: favorite_button.verticalCenter
|
|
||||||
horizontalCenter: favorite_button.horizontalCenter
|
|
||||||
}
|
|
||||||
width: UM.Theme.getSize("favorites_button_icon").width
|
|
||||||
height: UM.Theme.getSize("favorites_button_icon").height
|
|
||||||
color:
|
|
||||||
{
|
|
||||||
if (favorite_button.hovered)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("primary_hover")
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (materialSlot.is_favorite)
|
|
||||||
{
|
|
||||||
return UM.Theme.getColor("primary")
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UM.Theme.getColor("text_inactive")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
source: materialSlot.is_favorite ? UM.Theme.getIcon("StarFilled") : UM.Theme.getIcon("Star")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user