Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MachinesPage.qml « Preferences « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bc75b9bc726ae8efa3a52dac968f9569c2f3b5a6 (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
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
// Copyright (c) 2016 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.MachineManagementModel { }

    activeId: Cura.MachineManager.activeMachineId
    activeIndex: activeMachineIndex()

    function activeMachineIndex()
    {
        for(var i = 0; i < model.count; i++)
        {
            if (model.getItem(i).id == Cura.MachineManager.activeMachineId)
            {
                return i;
            }
        }
        return -1;
    }

    buttons: [
        Button
        {
            text: catalog.i18nc("@action:button", "Activate");
            iconName: "list-activate";
            enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMaterialId
            onClicked: Cura.MachineManager.setActiveMachine(base.currentItem.id)
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Add");
            iconName: "list-add";
            onClicked: CuraApplication.requestAddPrinter()
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Remove");
            iconName: "list-remove";
            enabled: base.currentItem != null && model.count > 1
            onClicked: confirmDialog.open();
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Rename");
            iconName: "edit-rename";
            enabled: base.currentItem != null && base.currentItem.metadata.connect_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")
            width: parent.width
            elide: Text.ElideRight
        }

        Flow
        {
            id: machineActions
            visible: currentItem && currentItem.id == Cura.MachineManager.activeMachineId
            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: childrenRect.width + 2 * screenScaleFactor
                    height: childrenRect.height
                    Button
                    {
                        text: machineActionRepeater.model[index].label
                        onClicked:
                        {
                            actionDialog.content = machineActionRepeater.model[index].displayItem;
                            machineActionRepeater.model[index].displayItem.reset();
                            actionDialog.title = machineActionRepeater.model[index].label;
                            actionDialog.show();
                        }
                    }
                }
            }
        }

        UM.Dialog
        {
            id: actionDialog
            property var content
            onContentChanged:
            {
                contents = content;
                content.onCompleted.connect(hide)
                content.dialog = actionDialog
            }
            rightButtons: Button
            {
                text: catalog.i18nc("@action:button", "Close")
                iconName: "dialog-close"
                onClicked: actionDialog.reject()
            }
        }

        Grid
        {
            id: machineInfo

            anchors.top: machineActions.visible ? machineActions.bottom : machineActions.anchors.top
            anchors.topMargin: UM.Theme.getSize("default_margin").height
            anchors.left: parent.left
            anchors.right: parent.right
            spacing: UM.Theme.getSize("default_margin").height
            rowSpacing: UM.Theme.getSize("default_lining").height
            columns: 2

            visible: base.currentItem

            property bool printerConnected: Cura.MachineManager.printerConnected
            property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
            property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
            property var printJob: connectedPrinter != null ? connectedPrinter.activePrintJob: null
            Label
            {
                text: catalog.i18nc("@label", "Printer type:")
                visible: base.currentItem && "definition_name" in base.currentItem.metadata
            }
            Label
            {
                text: (base.currentItem && "definition_name" in base.currentItem.metadata) ? base.currentItem.metadata.definition_name : ""
            }
            Label
            {
                text: catalog.i18nc("@label", "Connection:")
                visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId
            }
            Label
            {
                width: (parent.width * 0.7) | 0
                text: machineInfo.printerConnected ? machineInfo.connectedPrinter.connectionText : catalog.i18nc("@info:status", "The printer is not connected.")
                visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId
                wrapMode: Text.WordWrap
            }
            Label
            {
                text: catalog.i18nc("@label", "State:")
                visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId && machineInfo.printerAcceptsCommands
            }
            Label {
                width: (parent.width * 0.7) | 0
                text:
                {
                    if(!machineInfo.printerConnected || !machineInfo.printerAcceptsCommands) {
                        return "";
                    }

                    if (machineInfo.printJob == null)
                    {
                        return catalog.i18nc("@label:MonitorStatus", "Waiting for a printjob");
                    }

                    switch(machineInfo.printJob.state)
                    {
                        case "printing":
                            return catalog.i18nc("@label:MonitorStatus", "Printing...");
                        case "paused":
                            return catalog.i18nc("@label:MonitorStatus", "Paused");
                        case "pre_print":
                            return catalog.i18nc("@label:MonitorStatus", "Preparing...");
                        case "wait_cleanup":
                            return catalog.i18nc("@label:MonitorStatus", "Waiting for someone to clear the build plate");
                        case "error":
                            return printerOutputDevice.errorText;
                        case "maintenance":
                            return catalog.i18nc("@label:MonitorStatus", "In maintenance. Please check the printer");
                        case "abort":  // note sure if this jobState actually occurs in the wild
                            return catalog.i18nc("@label:MonitorStatus", "Aborting print...");

                    }
                    return ""
                }
                visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId && machineInfo.printerAcceptsCommands
                wrapMode: Text.WordWrap
            }
        }

        Column {
            id: additionalComponentsColumn
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.top: machineInfo.visible ? machineInfo.bottom : machineInfo.anchors.top
            anchors.topMargin: UM.Theme.getSize("default_margin").width

            spacing: UM.Theme.getSize("default_margin").width
            visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId

            Component.onCompleted:
            {
                for (var component in CuraApplication.additionalComponents["machinesDetailPane"]) {
                    CuraApplication.additionalComponents["machinesDetailPane"][component].parent = additionalComponentsColumn
                }
            }
        }

        Component.onCompleted: {
            addAdditionalComponents("machinesDetailPane")
        }

        Connections {
            target: CuraApplication
            onAdditionalComponentsChanged: addAdditionalComponents
        }

        function addAdditionalComponents (areaId) {
            if(areaId == "machinesDetailPane") {
                for (var component in CuraApplication.additionalComponents["machinesDetailPane"]) {
                    CuraApplication.additionalComponents["machinesDetailPane"][component].parent = additionalComponentsColumn
                }
            }
        }

        UM.I18nCatalog { id: catalog; name: "cura"; }

        UM.ConfirmRemoveDialog
        {
            id: confirmDialog;
            object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
            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;
            width: 300 * screenScaleFactor
            height: 150 * screenScaleFactor
            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()
            }
        }

    }
}