Skip to content

Commit 1d9e085

Browse files
committed
Add extruder count controls to CustomConfiguration
Replace the static header with a SettingPropertyProvider to watch the active machine's "machine_extruder_count", expose currentExtruderCount and maxExtruderCount properties, and add a header Row that includes the header label plus decrease/increase buttons to adjust the machine extruder count via Cura.MachineManager.setActiveMachineExtruderCount. Buttons are enabled/disabled based on bounds, and the tab bar anchor is updated to attach to the new headerRow.
1 parent 299a275 commit 1d9e085

File tree

1 file changed

+77
-7
lines changed

1 file changed

+77
-7
lines changed

resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,96 @@ Item
2727
width: parent.width
2828
height: childrenRect.height
2929

30-
UM.Label
30+
UM.SettingPropertyProvider
3131
{
32-
id: header
33-
text: catalog.i18nc("@header", "Custom")
34-
font: UM.Theme.getFont("medium")
35-
color: UM.Theme.getColor("small_button_text")
36-
height: contentHeight
32+
id: machineExtruderCountProvider
33+
containerStack: Cura.MachineManager.activeMachine
34+
key: "machine_extruder_count"
35+
watchedProperties: ["value"]
36+
storeIndex: 0
37+
}
38+
39+
property int currentExtruderCount: machineExtruderCountProvider.properties.value ? machineExtruderCountProvider.properties.value : 1
40+
property int maxExtruderCount: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.maxExtruderCount : 1
41+
42+
Row
43+
{
44+
id: headerRow
45+
width: parent.width
46+
height: header.height
47+
spacing: UM.Theme.getSize("default_margin").width
3748

3849
anchors
3950
{
4051
top: parent.top
4152
left: parent.left
4253
right: parent.right
4354
}
55+
56+
UM.Label
57+
{
58+
id: header
59+
text: catalog.i18nc("@header", "Custom")
60+
font: UM.Theme.getFont("medium")
61+
color: UM.Theme.getColor("small_button_text")
62+
height: contentHeight
63+
anchors.verticalCenter: parent.verticalCenter
64+
}
65+
66+
// Spacer to push buttons to the right
67+
Item
68+
{
69+
width: parent.width - header.width - decreaseExtruderButton.width - increaseExtruderButton.width - parent.spacing * 3
70+
height: 1
71+
}
72+
73+
UM.SimpleButton
74+
{
75+
id: decreaseExtruderButton
76+
width: UM.Theme.getSize("medium_button_icon").width
77+
height: UM.Theme.getSize("medium_button_icon").height
78+
iconSource: UM.Theme.getIcon("Minus")
79+
color: UM.Theme.getColor("icon")
80+
hoverColor: UM.Theme.getColor("icon_hover")
81+
anchors.verticalCenter: parent.verticalCenter
82+
83+
enabled: currentExtruderCount > 1
84+
85+
onClicked:
86+
{
87+
if (currentExtruderCount > 1)
88+
{
89+
Cura.MachineManager.setActiveMachineExtruderCount(currentExtruderCount - 1);
90+
}
91+
}
92+
}
93+
94+
UM.SimpleButton
95+
{
96+
id: increaseExtruderButton
97+
width: UM.Theme.getSize("medium_button_icon").width
98+
height: UM.Theme.getSize("medium_button_icon").height
99+
iconSource: UM.Theme.getIcon("Plus")
100+
color: UM.Theme.getColor("icon")
101+
hoverColor: UM.Theme.getColor("icon_hover")
102+
anchors.verticalCenter: parent.verticalCenter
103+
104+
enabled: currentExtruderCount < maxExtruderCount
105+
106+
onClicked:
107+
{
108+
if (currentExtruderCount < maxExtruderCount)
109+
{
110+
Cura.MachineManager.setActiveMachineExtruderCount(currentExtruderCount + 1);
111+
}
112+
}
113+
}
44114
}
45115

46116
UM.TabRow
47117
{
48118
id: tabBar
49-
anchors.top: header.bottom
119+
anchors.top: headerRow.bottom
50120
anchors.topMargin: UM.Theme.getSize("default_margin").height
51121
visible: extrudersModel.count > 1
52122

0 commit comments

Comments
 (0)