mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 22:08:59 +08:00
Simplify code in MaterialsPage.qml
This commit is contained in:
parent
86b75ae3b6
commit
730048d2b2
@ -344,10 +344,19 @@ Item
|
|||||||
|
|
||||||
Row
|
Row
|
||||||
{
|
{
|
||||||
|
id: materialRow
|
||||||
spacing: (UM.Theme.getSize("default_margin").width / 2) | 0
|
spacing: (UM.Theme.getSize("default_margin").width / 2) | 0
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
property bool isItemActivated:
|
||||||
|
{
|
||||||
|
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
||||||
|
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
||||||
|
return model.root_material_id == root_material_id;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
width: Math.floor(parent.height * 0.8)
|
width: Math.floor(parent.height * 0.8)
|
||||||
@ -361,22 +370,14 @@ Item
|
|||||||
width: Math.floor((parent.width * 0.3))
|
width: Math.floor((parent.width * 0.3))
|
||||||
text: model.material
|
text: model.material
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.italic: {
|
font.italic: materialRow.isItemActivated
|
||||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
|
||||||
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
|
||||||
return model.root_material_id == root_material_id
|
|
||||||
}
|
|
||||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
||||||
}
|
}
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: (model.name != model.material) ? model.name : ""
|
text: (model.name != model.material) ? model.name : ""
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.italic: {
|
font.italic: materialRow.isItemActivated
|
||||||
const extruder_position = Cura.ExtruderManager.activeExtruderIndex;
|
|
||||||
const root_material_id = Cura.MachineManager.currentRootMaterialId[extruder_position];
|
|
||||||
return model.root_material_id == root_material_id;
|
|
||||||
}
|
|
||||||
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
color: parent.ListView.isCurrentItem ? palette.highlightedText : palette.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user