|
@@ -8,106 +8,45 @@ import QtQuick.Layouts 1.3
|
|
|
import UM 1.5 as UM
|
|
|
import Cura 1.0 as Cura
|
|
|
|
|
|
-Item
|
|
|
+Column
|
|
|
{
|
|
|
id: material_type_section
|
|
|
- property var materialType
|
|
|
+ property var materialType: null
|
|
|
+ property string materialBrand: materialType !== null ? materialType.brand : ""
|
|
|
+ property string materialName: materialType !== null ? materialType.name : ""
|
|
|
+ property bool expanded: materialList.expandedTypes.indexOf(`${materialBrand}_${materialName}`) !== -1
|
|
|
+ property var colorsModel: materialType !== null ? materialType.colors : null
|
|
|
|
|
|
- property string materialBrand: materialType != null ? materialType.brand : ""
|
|
|
- property string materialName: materialType != null ? materialType.name : ""
|
|
|
- property var expanded: materialList.expandedTypes.indexOf(materialBrand + "_" + materialName) > -1
|
|
|
- property var colorsModel: materialType != null ? materialType.colors: null
|
|
|
- height: childrenRect.height
|
|
|
- width: parent ? parent.width : undefined
|
|
|
- anchors.left: parent ? parent.left : undefined
|
|
|
- Rectangle
|
|
|
- {
|
|
|
- id: material_type_header_background
|
|
|
- color:
|
|
|
- {
|
|
|
- if (!expanded && `${materialBrand}_${materialName}` == materialList.currentType)
|
|
|
- {
|
|
|
- return UM.Theme.getColor("favorites_row_selected")
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return "transparent"
|
|
|
- }
|
|
|
- }
|
|
|
- width: parent.width
|
|
|
- height: material_type_header.height
|
|
|
- }
|
|
|
- Rectangle
|
|
|
- {
|
|
|
- id: material_type_header_border
|
|
|
- color: UM.Theme.getColor("favorites_header_bar")
|
|
|
- anchors.bottom: material_type_header.bottom
|
|
|
- anchors.left: material_type_header.left
|
|
|
- height: UM.Theme.getSize("default_lining").height
|
|
|
- width: material_type_header.width
|
|
|
- }
|
|
|
- Row
|
|
|
- {
|
|
|
- id: material_type_header
|
|
|
- width: parent.width
|
|
|
- leftPadding: UM.Theme.getSize("default_margin").width
|
|
|
- anchors
|
|
|
- {
|
|
|
- left: parent ? parent.left : undefined
|
|
|
- }
|
|
|
- UM.Label
|
|
|
- {
|
|
|
- text: materialName
|
|
|
- height: UM.Theme.getSize("favorites_row").height
|
|
|
- width: parent.width - parent.leftPadding - UM.Theme.getSize("favorites_button").width
|
|
|
- id: material_type_name
|
|
|
- }
|
|
|
- Item // this one causes lots of warnings
|
|
|
- {
|
|
|
- implicitWidth: UM.Theme.getSize("favorites_button").width
|
|
|
- implicitHeight: UM.Theme.getSize("favorites_button").height
|
|
|
- UM.RecolorImage {
|
|
|
- anchors
|
|
|
- {
|
|
|
- verticalCenter: parent ? parent.verticalCenter : undefined
|
|
|
- horizontalCenter: parent ? parent.horizontalCenter : undefined
|
|
|
- }
|
|
|
- width: UM.Theme.getSize("standard_arrow").width
|
|
|
- height: UM.Theme.getSize("standard_arrow").height
|
|
|
- color: "black"
|
|
|
- source: material_type_section.expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft")
|
|
|
- }
|
|
|
+ width: parent.width
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- MouseArea // causes lots of warnings
|
|
|
+ Cura.CategoryButton
|
|
|
{
|
|
|
- anchors.fill: material_type_header
|
|
|
- onPressed:
|
|
|
+ width: parent.width
|
|
|
+ height: UM.Theme.getSize("favorites_row").height
|
|
|
+ labelText: materialName
|
|
|
+ labelFont: UM.Theme.getFont("default")
|
|
|
+ expanded: material_type_section.expanded
|
|
|
+ onClicked:
|
|
|
{
|
|
|
- const identifier = materialBrand + "_" + materialName;
|
|
|
- const i = materialList.expandedTypes.indexOf(identifier)
|
|
|
- if (i > -1)
|
|
|
+ const identifier = `${materialBrand}_${materialName}`;
|
|
|
+ const i = materialList.expandedTypes.indexOf(identifier);
|
|
|
+ if (i !== -1)
|
|
|
{
|
|
|
- // Remove it
|
|
|
- materialList.expandedTypes.splice(i, 1)
|
|
|
- material_type_section.expanded = false
|
|
|
+ materialList.expandedTypes.splice(i, 1); // remove
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- // Add it
|
|
|
- materialList.expandedTypes.push(identifier)
|
|
|
- material_type_section.expanded = true
|
|
|
+ materialList.expandedTypes.push(identifier); // add
|
|
|
}
|
|
|
UM.Preferences.setValue("cura/expanded_types", materialList.expandedTypes.join(";"));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
Column
|
|
|
{
|
|
|
- height: material_type_section.expanded ? childrenRect.height : 0
|
|
|
visible: material_type_section.expanded
|
|
|
width: parent.width
|
|
|
- anchors.top: material_type_header.bottom
|
|
|
+
|
|
|
Repeater
|
|
|
{
|
|
|
model: colorsModel
|
|
@@ -128,7 +67,7 @@ Item
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- expanded = materialList.expandedTypes.indexOf(materialBrand + "_" + materialName) > -1
|
|
|
+ material_type_section.expanded = materialList.expandedTypes.indexOf(`${materialBrand}_${materialName}`) !== -1;
|
|
|
}
|
|
|
}
|
|
|
}
|