File: MonitorPrintJobCard.qml

package info (click to toggle)
cura 5.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 122,888 kB
  • sloc: python: 44,572; sh: 81; xml: 32; makefile: 16
file content (242 lines) | stat: -rw-r--r-- 8,880 bytes parent folder | download | duplicates (2)
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
// Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.5 as UM
import Cura 1.0 as Cura

/**
 * A Print Job Card is essentially just a filled-in Expandable Card item. All
 * data within it is derived from being passed a printJob property.
 *
 * NOTE: For most labels, a fixed height with vertical alignment is used to make
 * layouts more deterministic (like the fixed-size textboxes used in original
 * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
 * with '// FIXED-LINE-HEIGHT:'.
 */
Item
{
    id: base

    // The print job which all other data is derived from
    property var printJob: null

    width: parent.width
    height: childrenRect.height

    ExpandableCard
    {
        enabled: printJob != null
        borderColor: printJob && printJob.configurationChanges.length !== 0 ? UM.Theme.getColor("warning") : UM.Theme.getColor("monitor_card_border")
        headerItem: Row
        {
            height: Math.round(48 * screenScaleFactor) // TODO: Theme!
            anchors.left: parent.left
            anchors.leftMargin: Math.round(24 * screenScaleFactor) // TODO: Theme!
            spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!

            MonitorPrintJobPreview
            {
                printJob: base.printJob
                size: Math.round(32 * screenScaleFactor) // TODO: Theme!
                anchors.verticalCenter: parent.verticalCenter
            }

            Item
            {
                anchors.verticalCenter: parent.verticalCenter
                height: Math.round(18 * screenScaleFactor) // TODO: Theme!
                width: UM.Theme.getSize("monitor_column").width
                Rectangle
                {
                    color: UM.Theme.getColor("monitor_skeleton_loading")
                    width: Math.round(parent.width / 2)
                    height: parent.height
                    visible: !printJob
                    radius: 2 * screenScaleFactor // TODO: Theme!
                }
                UM.Label
                {
                    text: printJob && printJob.name ? printJob.name : ""
                    elide: Text.ElideRight
                    font: UM.Theme.getFont("medium") // 14pt, regular
                    visible: printJob

                    // FIXED-LINE-HEIGHT:
                    width: parent.width
                    height: parent.height
                }
            }

            Item
            {
                anchors.verticalCenter: parent.verticalCenter
                height: Math.round(18 * screenScaleFactor) // TODO: Theme!
                width: UM.Theme.getSize("monitor_column").width

                Rectangle
                {
                    color: UM.Theme.getColor("monitor_skeleton_loading")
                    width: Math.round(parent.width / 3)
                    height: parent.height
                    visible: !printJob
                    radius: 2 * screenScaleFactor // TODO: Theme!
                }

                UM.Label
                {
                    text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
                    elide: Text.ElideRight
                    font: UM.Theme.getFont("medium") // 14pt, regular
                    visible: printJob

                    // FIXED-LINE-HEIGHT:
                    height: Math.round(18 * screenScaleFactor) // TODO: Theme!
                }
            }

            Item
            {
                anchors.verticalCenter: parent.verticalCenter
                height: Math.round(18 * screenScaleFactor) // TODO: This should be childrenRect.height but QML throws warnings
                width: childrenRect.width

                Rectangle
                {
                    color: UM.Theme.getColor("monitor_skeleton_loading")
                    width: Math.round(72 * screenScaleFactor) // TODO: Theme!
                    height: parent.height
                    visible: !printJob
                    radius: 2 * screenScaleFactor // TODO: Theme!
                }

                UM.Label
                {
                    id: printerAssignmentLabel
                    anchors.verticalCenter: parent.verticalCenter
                    elide: Text.ElideRight
                    font: UM.Theme.getFont("medium") // 14pt, regular
                    text: {
                        if (printJob !== null)
                        {
                            if (printJob.assignedPrinter == null)
                            {
                                if (printJob.state == "error")
                                {
                                    return catalog.i18nc("@label", "Unavailable printer");
                                }
                                return catalog.i18nc("@label", "First available");
                            }
                            return printJob.assignedPrinter.name;
                        }
                        return "";
                    }
                    visible: printJob
                    width: Math.round(120 * screenScaleFactor) // TODO: Theme!

                    // FIXED-LINE-HEIGHT:
                    height: parent.height
                }

                Row
                {
                    id: printerFamilyPills
                    anchors
                    {
                        left: printerAssignmentLabel.right;
                        leftMargin: Math.round(12 * screenScaleFactor) // TODO: Theme!
                        verticalCenter: parent.verticalCenter
                    }
                    height: childrenRect.height
                    spacing: Math.round(6 * screenScaleFactor) // TODO: Theme!
                    visible: printJob

                    MonitorPrinterPill
                    {
                        text: printJob.configuration.printerType
                    }
                }
            }
        }
        drawerItem: Row
        {
            anchors
            {
                left: parent.left
                leftMargin: Math.round(74 * screenScaleFactor) // TODO: Theme!
            }
            height: Math.round(108 * screenScaleFactor) // TODO: Theme!
            spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!

            MonitorPrinterConfiguration
            {
                id: printerConfiguration
                anchors.verticalCenter: parent.verticalCenter
                buildplate: catalog.i18nc("@label", "Glass")
                configurations: base.printJob.configuration.extruderConfigurations
                height: Math.round(72 * screenScaleFactor) // TODO: Theme!
            }

            UM.Label
            {
                text: printJob && printJob.owner ? printJob.owner : ""
                elide: Text.ElideRight
                font: UM.Theme.getFont("medium") // 14pt, regular
                anchors.top: printerConfiguration.top

                // FIXED-LINE-HEIGHT:
                height: Math.round(18 * screenScaleFactor) // TODO: Theme!
            }
        }
    }

    MonitorContextMenuButton
    {
        id: contextMenuButton
        anchors
        {
            right: parent.right
            rightMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
            top: parent.top
            topMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
        }
        width: Math.round(32 * screenScaleFactor) // TODO: Theme!
        height: Math.round(32 * screenScaleFactor) // TODO: Theme!
        enabled: OutputDevice.supportsPrintJobActions
        onClicked: enabled ? contextMenu.switchPopupState() : {}
        visible:
        {
            if (!printJob)
            {
                return false;
            }
            var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"];
            return states.indexOf(printJob.state) !== -1;
        }
    }

    MonitorContextMenu
    {
        id: contextMenu
        printJob: base.printJob ? base.printJob : null
        target: contextMenuButton
    }

    // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available
    MouseArea
    {
        id: contextMenuDisabledButtonArea
        anchors.fill: contextMenuButton
        hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled
        onEntered: contextMenuDisabledInfo.open()
        onExited: contextMenuDisabledInfo.close()
        enabled: !contextMenuButton.enabled
    }

     MonitorInfoBlurb
     {
         id: contextMenuDisabledInfo
         text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
         target: contextMenuButton
     }
}