mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Reuse MaterialBrandSection component for Favorites, Generic and branded
materials. This component will show different children depending on the hasMaterialTypes flag. Adjust some small UI issues. Contributes to CURA-5682.
This commit is contained in:
parent
f871a89825
commit
bafc2b98c9
6 changed files with 61 additions and 148 deletions
|
|
@ -12,34 +12,34 @@ import Cura 1.0 as Cura
|
|||
|
||||
Rectangle
|
||||
{
|
||||
id: material_slot
|
||||
property var material
|
||||
id: materialSlot
|
||||
property var material: null
|
||||
property var hovered: false
|
||||
property var is_favorite: material.is_favorite
|
||||
property var is_favorite: material != null ? material.is_favorite : false
|
||||
|
||||
height: UM.Theme.getSize("favorites_row").height
|
||||
width: parent.width
|
||||
color: base.currentItem.root_material_id == material.root_material_id ? UM.Theme.getColor("favorites_row_selected") : "transparent"
|
||||
color: material != null ? (base.currentItem.root_material_id == material.root_material_id ? UM.Theme.getColor("favorites_row_selected") : "transparent") : "transparent"
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: swatch
|
||||
color: material.color_code
|
||||
color: material != null ? material.color_code : "transparent"
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: "black"
|
||||
width: UM.Theme.getSize("favorites_button_icon").width
|
||||
height: UM.Theme.getSize("favorites_button_icon").height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: materialSlot.verticalCenter
|
||||
anchors.left: materialSlot.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: material.brand + " " + material.name
|
||||
text: material != null ? material.brand + " " + material.name : ""
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
height: parent.height
|
||||
anchors.left: swatch.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenter: materialSlot.verticalCenter
|
||||
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
|
||||
}
|
||||
MouseArea
|
||||
|
|
@ -52,8 +52,8 @@ Rectangle
|
|||
base.currentItem = material
|
||||
}
|
||||
hoverEnabled: true
|
||||
onEntered: { material_slot.hovered = true }
|
||||
onExited: { material_slot.hovered = false }
|
||||
onEntered: { materialSlot.hovered = true }
|
||||
onExited: { materialSlot.hovered = false }
|
||||
}
|
||||
Button
|
||||
{
|
||||
|
|
@ -61,21 +61,21 @@ Rectangle
|
|||
text: ""
|
||||
implicitWidth: UM.Theme.getSize("favorites_button").width
|
||||
implicitHeight: UM.Theme.getSize("favorites_button").height
|
||||
visible: material_slot.hovered || material_slot.is_favorite || favorite_button.hovered
|
||||
visible: materialSlot.hovered || materialSlot.is_favorite || favorite_button.hovered
|
||||
anchors
|
||||
{
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
right: materialSlot.right
|
||||
verticalCenter: materialSlot.verticalCenter
|
||||
}
|
||||
onClicked:
|
||||
{
|
||||
if (material_slot.is_favorite) {
|
||||
if (materialSlot.is_favorite) {
|
||||
base.materialManager.removeFavorite(material.root_material_id)
|
||||
material_slot.is_favorite = false
|
||||
materialSlot.is_favorite = false
|
||||
return
|
||||
}
|
||||
base.materialManager.addFavorite(material.root_material_id)
|
||||
material_slot.is_favorite = true
|
||||
materialSlot.is_favorite = true
|
||||
return
|
||||
}
|
||||
style: ButtonStyle
|
||||
|
|
@ -89,8 +89,8 @@ Rectangle
|
|||
UM.RecolorImage {
|
||||
anchors
|
||||
{
|
||||
verticalCenter: parent.verticalCenter
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
verticalCenter: favorite_button.verticalCenter
|
||||
horizontalCenter: favorite_button.horizontalCenter
|
||||
}
|
||||
width: UM.Theme.getSize("favorites_button_icon").width
|
||||
height: UM.Theme.getSize("favorites_button_icon").height
|
||||
|
|
@ -104,7 +104,7 @@ Rectangle
|
|||
}
|
||||
else
|
||||
{
|
||||
if (material_slot.is_favorite)
|
||||
if (materialSlot.is_favorite)
|
||||
{
|
||||
return UM.Theme.getColor("primary")
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ Rectangle
|
|||
}
|
||||
}
|
||||
}
|
||||
source: material_slot.is_favorite ? UM.Theme.getIcon("favorites_star_full") : UM.Theme.getIcon("favorites_star_empty")
|
||||
source: materialSlot.is_favorite ? UM.Theme.getIcon("favorites_star_full") : UM.Theme.getIcon("favorites_star_empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue