blob: b61f866833256a66ced49f7dd8cb69e1ad97630f (
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
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
|
// Copyright (c) 2018 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.Window 2.1
import UM 1.2 as UM
import Cura 1.0 as Cura
UM.ManagementPage
{
id: base;
title: catalog.i18nc("@title:tab", "Printers");
model: Cura.GlobalStacksModel { }
sectionRole: "discoverySource"
activeId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id: ""
activeIndex: activeMachineIndex()
function activeMachineIndex()
{
for(var i = 0; i < model.count; i++)
{
if (model.getItem(i).id == base.activeId)
{
return i;
}
}
return -1;
}
buttons: [
Button
{
id: activateMenuButton
text: catalog.i18nc("@action:button", "Activate");
iconName: "list-activate";
enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMachine.id
onClicked: Cura.MachineManager.setActiveMachine(base.currentItem.id)
},
Button
{
id: addMenuButton
text: catalog.i18nc("@action:button", "Add");
iconName: "list-add";
onClicked: Cura.Actions.addMachine.trigger()
},
Button
{
id: removeMenuButton
text: catalog.i18nc("@action:button", "Remove");
iconName: "list-remove";
enabled: base.currentItem != null && model.count > 1
onClicked: confirmDialog.open();
},
Button
{
id: renameMenuButton
text: catalog.i18nc("@action:button", "Rename");
iconName: "edit-rename";
enabled: base.currentItem != null && base.currentItem.metadata.group_name == null
onClicked: renameDialog.open();
}
]
Item
{
visible: base.currentItem != null
anchors.fill: parent
Label
{
id: machineName
text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
font: UM.Theme.getFont("large_bold")
width: parent.width
elide: Text.ElideRight
}
Flow
{
id: machineActions
visible: currentItem && currentItem.id == Cura.MachineManager.activeMachine.id
anchors.left: parent.left
anchors.right: parent.right
anchors.top: machineName.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
Repeater
{
id: machineActionRepeater
model: base.currentItem ? Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) : null
Item
{
width: Math.round(childrenRect.width + 2 * screenScaleFactor)
height: childrenRect.height
Button
{
text: machineActionRepeater.model[index].label
onClicked:
{
var currentItem = machineActionRepeater.model[index]
actionDialog.loader.manager = currentItem
actionDialog.loader.source = currentItem.qmlPath
actionDialog.title = currentItem.label
actionDialog.show()
}
}
}
}
}
UM.Dialog
{
id: actionDialog
minimumWidth: UM.Theme.getSize("modal_window_minimum").width
minimumHeight: UM.Theme.getSize("modal_window_minimum").height
maximumWidth: minimumWidth * 3
maximumHeight: minimumHeight * 3
rightButtons: Button
{
text: catalog.i18nc("@action:button", "Close")
iconName: "dialog-close"
onClicked: actionDialog.reject()
}
}
UM.I18nCatalog { id: catalog; name: "cura"; }
UM.ConfirmRemoveDialog
{
id: confirmDialog
object: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
text: base.currentItem ? base.currentItem.removalWarning : "";
onYes:
{
Cura.MachineManager.removeMachine(base.currentItem.id)
if(!base.currentItem)
{
objectList.currentIndex = activeMachineIndex()
}
//Force updating currentItem and the details panel
objectList.onCurrentIndexChanged()
}
}
UM.RenameDialog
{
id: renameDialog;
object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
property var machine_name_validator: Cura.MachineNameValidator { }
validName: renameDialog.newName.match(renameDialog.machine_name_validator.machineNameRegex) != null;
onAccepted:
{
Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
//Force updating currentItem and the details panel
objectList.onCurrentIndexChanged()
}
}
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged:
{
objectList.currentIndex = activeMachineIndex()
objectList.onCurrentIndexChanged()
}
}
}
}
|