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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import UM 1.5 as UM
import Cura 1.0 as Cura
/**
* Menu that allows you to select the configuration of the current printer, such
* as the nozzle sizes and materials in each extruder.
*/
Cura.ExpandablePopup
{
id: base
property var extrudersModel: CuraApplication.getExtrudersModel()
property var activeMachine: Cura.MachineManager.activeMachine
UM.I18nCatalog
{
id: catalog
name: "cura"
}
enum ConfigurationMethod
{
Auto,
Custom
}
contentPadding: UM.Theme.getSize("default_lining").width
enabled: activeMachine ? activeMachine.hasMaterials || activeMachine.hasVariants || activeMachine.hasVariantBuildplates : false; //Only let it drop down if there is any configuration that you could change.
headerItem: Item
{
id: headerBase
// Horizontal list that shows the extruders and their materials
RowLayout
{
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
width: parent.width - UM.Theme.getSize("standard_arrow").width
visible: activeMachine ? activeMachine.hasMaterials : false
Repeater
{
model: extrudersModel
delegate: Item
{
id: extruderItem
Layout.preferredWidth: Math.floor(headerBase.width / extrudersModel.count)
Layout.maximumWidth: Math.floor(headerBase.width / extrudersModel.count)
Layout.preferredHeight: headerBase.height
Layout.maximumHeight: headerBase.height
Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter
property var extruderStack: activeMachine ? activeMachine.extruderList[model.index]: null
property bool valueWarning: !Cura.ExtruderManager.getExtruderHasQualityForMaterial(extruderStack)
property bool valueError: activeMachine ? Cura.ContainerManager.getContainerMetaDataEntry(extruderStack.material.id, "compatible") != "True" : false
// Extruder icon. Shows extruder index and has the same color as the active material.
Cura.ExtruderIcon
{
id: extruderIcon
materialColor: model.color
extruderEnabled: model.enabled
anchors.verticalCenter: parent.verticalCenter
}
MouseArea // Connection status tooltip hover area
{
id: tooltipHoverArea
anchors.fill: parent
hoverEnabled: tooltip.text != ""
acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks
onEntered:
{
base.mouseArea.entered() // we want both this and the outer area to be entered
tooltip.show()
}
onExited: { tooltip.hide() }
}
UM.ToolTip
{
id: tooltip
x: 0
y: parent.height + UM.Theme.getSize("default_margin").height
width: UM.Theme.getSize("tooltip").width
targetPoint: Qt.point(Math.round(extruderIcon.width / 2), 0)
text:
{
if (!model.enabled)
{
return ""
}
if (extruderItem.valueError)
{
return catalog.i18nc("@tooltip", "The configuration of this extruder is not allowed, and prohibits slicing.")
}
if (extruderItem.valueWarning)
{
return catalog.i18nc("@tooltip", "There are no profiles matching the configuration of this extruder.")
}
return ""
}
}
// Warning icon that indicates if no qualities are available for the variant/material combination for this extruder
UM.ColorImage
{
id: badge
anchors
{
top: parent.top
topMargin: - Math.round(height * 1 / 6)
left: parent.left
leftMargin: extruderIcon.width - Math.round(width * 5 / 6)
}
width: UM.Theme.getSize("icon_indicator").width
height: UM.Theme.getSize("icon_indicator").height
visible: model.enabled && (extruderItem.valueError || extruderItem.valueWarning)
source:
{
if (extruderItem.valueError)
{
return UM.Theme.getIcon("ErrorBadge", "low")
}
if (extruderItem.valueWarning)
{
return UM.Theme.getIcon("WarningBadge", "low")
}
return ""
}
color:
{
if (extruderItem.valueError)
{
return UM.Theme.getColor("error")
}
if (extruderItem.valueWarning)
{
return UM.Theme.getColor("warning")
}
return "transparent"
}
// Make a themable circle in the background so we can change it in other themes
Rectangle
{
id: iconBackground
anchors.centerIn: parent
width: parent.width - 1.5 //1.5 pixels smaller, (at least sqrt(2), regardless of screen pixel scale) so that the circle doesn't show up behind the icon due to anti-aliasing.
height: parent.height - 1.5
radius: width / 2
z: parent.z - 1
color:
{
if (extruderItem.valueError)
{
return UM.Theme.getColor("error_badge_background")
}
if (extruderItem.valueWarning)
{
return UM.Theme.getColor("warning_badge_background")
}
return "transparent"
}
}
}
Column
{
opacity: model.enabled ? 1 : UM.Theme.getColor("extruder_disabled").a
spacing: 0
visible: width > 0
anchors
{
left: extruderIcon.right
leftMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
}
// Label for the brand of the material
UM.Label
{
id: materialBrandNameLabel
text: model.material_brand + " " + model.material_name
elide: Text.ElideRight
wrapMode: Text.NoWrap
width: parent.width
visible: !truncated
}
UM.Label
{
id: materialNameLabel
text: model.material_name
elide: Text.ElideRight
width: parent.width
wrapMode: Text.NoWrap
visible: !materialBrandNameLabel.visible && !truncated
}
UM.Label
{
id: materialTypeLabel
text: model.material_type
elide: Text.ElideRight
width: parent.width
wrapMode: Text.NoWrap
visible: !materialBrandNameLabel.visible && !materialNameLabel.visible
}
// Label that shows the name of the variant
UM.Label
{
id: variantLabel
visible: activeMachine ? activeMachine.hasVariants : false
text: model.variant
elide: Text.ElideRight
wrapMode: Text.NoWrap
font: UM.Theme.getFont("default_bold")
Layout.preferredWidth: parent.width
}
}
}
}
}
// Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder).
UM.Label
{
text: catalog.i18nc("@label", "Select configuration")
elide: Text.ElideRight
font: UM.Theme.getFont("medium")
visible: activeMachine ? !activeMachine.hasMaterials && (activeMachine.hasVariants || activeMachine.hasVariantBuildplates) : false
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
}
}
}
contentWidth: UM.Theme.getSize("configuration_selector").width
contentItem: Column
{
id: popupItem
padding: UM.Theme.getSize("default_margin").height
spacing: UM.Theme.getSize("default_margin").height
property bool is_connected: false // If current machine is connected to a printer. Only evaluated upon making popup visible.
property int configuration_method: ConfigurationMenu.ConfigurationMethod.Custom // Type of configuration being used. Only evaluated upon making popup visible.
property int manual_selected_method: -1 // It stores the configuration method selected by the user. By default the selected method is
onVisibleChanged:
{
is_connected = activeMachine.hasRemoteConnection && Cura.MachineManager.printerConnected && Cura.MachineManager.printerOutputDevices[0].uniqueConfigurations.length > 0 //Re-evaluate.
// If the printer is not connected or does not have configurations, we switch always to the custom mode. If is connected instead, the auto mode
// or the previous state is selected
configuration_method = is_connected ? (manual_selected_method == -1 ? ConfigurationMenu.ConfigurationMethod.Auto : manual_selected_method) : ConfigurationMenu.ConfigurationMethod.Custom
}
Item
{
width: parent.width - 2 * parent.padding
height:
{
var height = 0
if (autoConfiguration.visible)
{
height += autoConfiguration.height
}
if (customConfiguration.visible)
{
height += customConfiguration.height
}
return height
}
AutoConfiguration
{
id: autoConfiguration
visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Auto
}
CustomConfiguration
{
id: customConfiguration
visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Custom
}
}
Rectangle
{
id: separator
visible: buttonBar.visible
x: -parent.padding
width: parent.width
height: UM.Theme.getSize("default_lining").height
color: UM.Theme.getColor("lining")
}
//Allow switching between custom and auto.
Item
{
id: buttonBar
visible: popupItem.is_connected //Switching only makes sense if the "auto" part is possible.
width: parent.width - 2 * parent.padding
height: childrenRect.height
Cura.SecondaryButton
{
id: goToCustom
visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Auto
text: catalog.i18nc("@label", "Custom")
anchors.right: parent.right
iconSource: UM.Theme.getIcon("ChevronSingleRight")
isIconOnRightSide: true
onClicked:
{
popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.Custom
popupItem.manual_selected_method = popupItem.configuration_method
}
}
Cura.SecondaryButton
{
id: goToAuto
visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Custom
text: catalog.i18nc("@label", "Configurations")
iconSource: UM.Theme.getIcon("ChevronSingleLeft")
onClicked:
{
popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.Auto
popupItem.manual_selected_method = popupItem.configuration_method
}
}
}
}
Connections
{
target: Cura.MachineManager
function onGlobalContainerChanged() { popupItem.manual_selected_method = -1 } // When switching printers, reset the value of the manual selected method
}
}
|