blob: 9f7eeccc54b57ee031207685fb3f14be9cd11f63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import UM 1.5 as UM
import Cura 1.0 as Cura
// An expandable list of materials. Includes both the header (this file) and the items (brandMaterialList)
Column
{
id: brand_section
property string sectionName: ""
property var elementsModel // This can be a MaterialTypesModel or GenericMaterialsModel or FavoriteMaterialsModel
property bool hasMaterialTypes: true // It indicates whether it has material types or not
property bool expanded: materialList.expandedBrands.indexOf(sectionName) !== -1
width: parent.width
Cura.CategoryButton
{
width: parent.width
labelText: sectionName
height: UM.Theme.getSize("preferences_page_list_item").height
labelFont: UM.Theme.getFont("default_bold")
expanded: brand_section.expanded
onClicked:
{
const i = materialList.expandedBrands.indexOf(sectionName);
if (i !== -1)
{
materialList.expandedBrands.splice(i, 1); // remove
}
else
{
materialList.expandedBrands.push(sectionName); // add
}
UM.Preferences.setValue("cura/expanded_brands", materialList.expandedBrands.join(";"));
}
}
Column
{
id: brandMaterialList
width: parent.width
visible: brand_section.expanded
Repeater
{
model: elementsModel
delegate: Loader
{
width: parent.width
property var element: model
sourceComponent: hasMaterialTypes ? materialsTypeSection : materialSlot
}
}
}
Component
{
id: materialsTypeSection
MaterialsTypeSection
{
materialType: element
indented: true
}
}
Component
{
id: materialSlot
MaterialsSlot
{
material: element
}
}
Connections
{
target: UM.Preferences
function onPreferenceChanged(preference)
{
if (preference !== "cura/expanded_types" && preference !== "cura/expanded_brands")
{
return;
}
brand_section.expanded = materialList.expandedBrands.indexOf(sectionName) !== -1;
}
}
}
|