blob: de70b0e0f41305f79b1d7802e6fa8bdcb7928134 (
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
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
|
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.3
import UM 1.4 as UM
import Cura 1.0 as Cura
Item
{
id: base
property var outputDevice: null
height: childrenRect.height
function forceModelUpdate()
{
// FIXME For now the model has to be removed and then created again, otherwise changes in the printer don't automatically update the UI
configurationList.model = []
if (outputDevice)
{
configurationList.model = outputDevice.uniqueConfigurations
}
}
// This component will appear when there are no configurations (e.g. when losing connection or when they are being loaded)
Item
{
width: parent.width
visible: configurationList.model.length == 0
height: icon.height
anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("default_margin").height
UM.StatusIcon
{
id: icon
width: visible ? UM.Theme.getSize("section_icon").width : 0
height: width
anchors.verticalCenter: parent.verticalCenter
status: UM.StatusIcon.Status.WARNING
}
Label
{
id: label
anchors.left: icon.right
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: UM.Theme.getSize("default_margin").width
// There are two cases that we want to differentiate, one is when Cura is loading the configurations and the
// other when the connection was lost
text: Cura.MachineManager.printerConnected ?
catalog.i18nc("@label", "Loading available configurations from the printer...") :
catalog.i18nc("@label", "The configurations are not available because the printer is disconnected.")
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
wrapMode: Text.WordWrap
}
}
ScrollView
{
id: container
width: parent.width
readonly property int maximumHeight: 350 * screenScaleFactor
height: Math.round(Math.min(configurationList.height, maximumHeight))
contentHeight: configurationList.height
clip: true
ScrollBar.vertical.policy: (configurationList.height > maximumHeight) ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff //The AsNeeded policy also hides it when the cursor is away, and we don't want that.
ScrollBar.vertical.background: Rectangle
{
implicitWidth: UM.Theme.getSize("scrollbar").width
radius: width / 2
color: UM.Theme.getColor("scrollbar_background")
}
ScrollBar.vertical.contentItem: Rectangle
{
implicitWidth: UM.Theme.getSize("scrollbar").width
radius: width / 2
color: UM.Theme.getColor(parent.pressed ? "scrollbar_handle_down" : parent.hovered ? "scrollbar_handle_hover" : "scrollbar_handle")
}
ButtonGroup
{
buttons: configurationList.children
}
ListView
{
id: configurationList
spacing: UM.Theme.getSize("narrow_margin").height
width: container.width - ((height > container.maximumHeight) ? container.ScrollBar.vertical.background.width : 0) //Make room for scroll bar if there is any.
height: contentHeight
interactive: false // let the ScrollView process scroll events.
section.property: "modelData.printerType"
section.criteria: ViewSection.FullString
section.delegate: Item
{
height: printerTypeLabel.height + UM.Theme.getSize("wide_margin").height //Causes a default margin above the label and a default margin below the label.
Cura.PrinterTypeLabel
{
id: printerTypeLabel
text: section
anchors.verticalCenter: parent.verticalCenter //One default margin above and one below.
autoFit: true
}
}
model: (outputDevice != null) ? outputDevice.uniqueConfigurations : []
delegate: ConfigurationItem
{
width: parent.width
configuration: modelData
}
}
}
Connections
{
target: outputDevice
function onUniqueConfigurationsChanged()
{
forceModelUpdate()
}
}
Connections
{
target: Cura.MachineManager
function onOutputDevicesChanged()
{
forceModelUpdate()
}
}
}
|