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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
|
//Copyright (c) 2022 Ultimaker B.V.
//Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Dialogs
import QtQuick.Layouts 1.15
import QtQuick.Window 2.1
import Cura 1.1 as Cura
import UM 1.5 as UM
Window
{
id: materialsSyncDialog
property variant catalog: UM.I18nCatalog { name: "cura" }
title: catalog.i18nc("@title:window", "Sync materials with printers")
minimumWidth: UM.Theme.getSize("modal_window_minimum").width
minimumHeight: UM.Theme.getSize("modal_window_minimum").height
width: minimumWidth
height: minimumHeight
modality: Qt.ApplicationModal
color: UM.Theme.getColor("main_background")
property variant syncModel
property alias pageIndex: swipeView.currentIndex
property alias syncStatusText: syncStatusLabel.text
property bool hasExportedUsb: false
SwipeView
{
id: swipeView
anchors.fill: parent
interactive: false
Item
{
id: introPage
ColumnLayout
{
spacing: UM.Theme.getSize("default_margin").height
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
UM.Label
{
text: catalog.i18nc("@title:header", "Sync materials with printers")
font: UM.Theme.getFont("large_bold")
Layout.fillWidth: true
}
UM.Label
{
text: catalog.i18nc("@text", "Following a few simple steps, you will be able to synchronize all your material profiles with your printers.")
font: UM.Theme.getFont("medium")
Layout.fillWidth: true
}
Image
{
Layout.fillWidth: true
Layout.fillHeight: true
source: UM.Theme.getImage("material_ecosystem")
fillMode: Image.PreserveAspectFit
sourceSize.width: width
}
Item
{
Layout.preferredHeight: childrenRect.height
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Cura.TertiaryButton
{
text: catalog.i18nc("@button", "Why do I need to sync material profiles?")
iconSource: UM.Theme.getIcon("LinkExternal")
isIconOnRightSide: true
onClicked: Qt.openUrlExternally("https://support.ultimaker.com/hc/en-us/articles/360013137919?utm_source=cura&utm_medium=software&utm_campaign=sync-material-printer-why")
}
Cura.PrimaryButton
{
anchors.right: parent.right
text: catalog.i18nc("@button", "Start")
onClicked:
{
if(Cura.API.account.isLoggedIn)
{
swipeView.currentIndex += 2; //Skip sign in page.
}
else
{
swipeView.currentIndex += 1;
}
}
}
}
}
}
Item
{
id: signinPage
// While this page is active, continue to the next page if the user logs in.
Connections
{
target: Cura.API.account
function onLoginStateChanged(is_logged_in)
{
if(is_logged_in && signinPage.SwipeView.isCurrentItem)
{
swipeView.currentIndex += 1;
}
}
}
ColumnLayout
{
spacing: UM.Theme.getSize("default_margin").height
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
UM.Label
{
text: catalog.i18nc("@title:header", "Sign in")
font: UM.Theme.getFont("large_bold")
Layout.fillWidth: true
}
UM.Label
{
text: catalog.i18nc("@text", "To automatically sync the material profiles with all your printers connected to Digital Factory you need to be signed in in Cura.")
font: UM.Theme.getFont("medium")
Layout.fillWidth: true
}
Image
{
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: parent.width / 2
source: UM.Theme.getImage("first_run_ultimaker_cloud")
Layout.fillHeight: true
sourceSize.width: width
fillMode: Image.PreserveAspectFit
}
Item
{
Layout.preferredHeight: childrenRect.height
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Cura.SecondaryButton
{
anchors.left: parent.left
text: catalog.i18nc("@button", "Sync materials with USB")
onClicked: swipeView.currentIndex = removableDriveSyncPage.SwipeView.index
}
Cura.PrimaryButton
{
anchors.right: parent.right
text: catalog.i18nc("@button", "Sign in")
onClicked: Cura.API.account.login()
}
}
}
}
Item
{
id: printerListPage
ColumnLayout
{
spacing: UM.Theme.getSize("default_margin").height
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
visible: cloudPrinterList.count > 0
Row
{
spacing: UM.Theme.getSize("default_margin").width
states: [
State
{
name: "idle"
when: typeof syncModel === "undefined" || syncModel.exportUploadStatus == "idle" || syncModel.exportUploadStatus == "uploading"
PropertyChanges { target: printerListHeader; text: catalog.i18nc("@title:header", "The following printers will receive the new material profiles:") }
PropertyChanges { target: printerListHeaderIcon; status: UM.StatusIcon.Status.NEUTRAL; width: 0 }
},
State
{
name: "error"
when: typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "error"
PropertyChanges { target: printerListHeader; text: catalog.i18nc("@title:header", "Something went wrong when sending the materials to the printers.") }
PropertyChanges { target: printerListHeaderIcon; status: UM.StatusIcon.Status.ERROR }
},
State
{
name: "success"
when: typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "success"
PropertyChanges { target: printerListHeader; text: catalog.i18nc("@title:header", "Material profiles successfully synced with the following printers:") }
PropertyChanges { target: printerListHeaderIcon; status: UM.StatusIcon.Status.POSITIVE }
}
]
UM.StatusIcon
{
id: printerListHeaderIcon
width: UM.Theme.getSize("section_icon").width
height: UM.Theme.getSize("section_icon").height
anchors.verticalCenter: parent.verticalCenter
}
UM.Label
{
id: printerListHeader
anchors.verticalCenter: parent.verticalCenter
//Text is always defined by the states above.
font: UM.Theme.getFont("large_bold")
}
}
Row
{
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
UM.Label
{
id: syncStatusLabel
anchors.left: parent.left
wrapMode: Text.Wrap
elide: Text.ElideRight
visible: text !== ""
font: UM.Theme.getFont("medium")
}
Cura.TertiaryButton
{
id: troubleshootingLink
anchors.right: parent.right
text: catalog.i18nc("@button", "Troubleshooting")
visible: typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "error"
iconSource: UM.Theme.getIcon("LinkExternal")
onClicked: Qt.openUrlExternally("https://support.ultimaker.com/hc/en-us/articles/360012019239?utm_source=cura&utm_medium=software&utm_campaign=sync-material-wizard-troubleshoot-cloud-printer")
}
}
ListView
{
id: printerList
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
ScrollBar.vertical: UM.ScrollBar
{
id: printerListScrollBar
}
spacing: UM.Theme.getSize("default_margin").height
model: cloudPrinterList
delegate: Rectangle
{
id: delegateContainer
color: "transparent"
border.color: UM.Theme.getColor("lining")
border.width: UM.Theme.getSize("default_lining").width
width: printerList.width - printerListScrollBar.width
height: UM.Theme.getSize("machine_selector_icon").height + 2 * UM.Theme.getSize("default_margin").height
property string syncStatus:
{
var printer_id = model.metadata["host_guid"]
if(syncModel.printerStatus[printer_id] === undefined) //No status information available. Could be added after we started syncing.
{
return "idle";
}
return syncModel.printerStatus[printer_id];
}
Cura.IconWithText
{
anchors
{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: Math.round(parent.height - height) / 2 //Equal margin on the left as above and below.
right: parent.right
rightMargin: Math.round(parent.height - height) / 2
}
text: model.name
font: UM.Theme.getFont("medium")
source: UM.Theme.getIcon("Printer", "medium")
iconColor: UM.Theme.getColor("machine_selector_printer_icon")
iconSize: UM.Theme.getSize("machine_selector_icon").width
//Printer status badge (always cloud, but whether it's online or offline).
UM.ColorImage
{
width: UM.Theme.getSize("printer_status_icon").width
height: UM.Theme.getSize("printer_status_icon").height
anchors
{
bottom: parent.bottom
bottomMargin: -Math.round(height / 6)
left: parent.left
leftMargin: parent.iconSize - Math.round(width * 5 / 6)
}
source: UM.Theme.getIcon("CloudBadge", "low")
color: UM.Theme.getColor("primary")
//Make a themeable circle in the background so we can change it in other themes.
Rectangle
{
anchors.centerIn: parent
width: parent.width - 1.5 //1.5 pixels smaller (at least sqrt(2), regardless of 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
color: UM.Theme.getColor("connection_badge_background")
z: parent.z - 1
}
}
}
UM.ColorImage
{
id: printerSpinner
width: UM.Theme.getSize("section_icon").width
height: width
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Math.round((parent.height - height) / 2) //Same margin on the right as above and below.
visible: delegateContainer.syncStatus === "uploading"
source: UM.Theme.getIcon("ArrowDoubleCircleRight")
color: UM.Theme.getColor("primary")
RotationAnimator
{
target: printerSpinner
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: true
}
}
UM.StatusIcon
{
width: UM.Theme.getSize("section_icon").width
height: width
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: Math.round((parent.height - height) / 2) //Same margin on the right as above and below.
visible: delegateContainer.syncStatus === "failed" || delegateContainer.syncStatus === "success"
status: delegateContainer.syncStatus === "success" ? UM.StatusIcon.Status.POSITIVE : UM.StatusIcon.Status.ERROR
}
}
footer: Item
{
width: printerList.width - printerListScrollBar.width
height: childrenRect.height + UM.Theme.getSize("default_margin").height
visible: includeOfflinePrinterList.count - cloudPrinterList.count > 0 && typeof syncModel !== "undefined" && syncModel.exportUploadStatus === "idle"
Rectangle
{
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
border.color: UM.Theme.getColor("lining")
border.width: UM.Theme.getSize("default_lining").width
anchors.topMargin: UM.Theme.getSize("default_margin").height
height: childrenRect.height + 2 * UM.Theme.getSize("thick_margin").height
color: "transparent"
GridLayout
{
columns: 3
rows: 2
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: UM.Theme.getSize("thick_margin").width
anchors.rightMargin: UM.Theme.getSize("thick_margin").width
anchors.topMargin: UM.Theme.getSize("thick_margin").height
anchors.bottomMargin: UM.Theme.getSize("thick_margin").height
columnSpacing: UM.Theme.getSize("default_margin").width
rowSpacing: UM.Theme.getSize("default_margin").height
UM.StatusIcon
{
Layout.preferredWidth: UM.Theme.getSize("section_icon").width
Layout.preferredHeight: UM.Theme.getSize("section_icon").height
status: UM.StatusIcon.Status.WARNING
}
UM.Label
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignmentFlag.AlignVCenter
text: catalog.i18nc("@text Asking the user whether printers are missing in a list.", "Printers missing?")
+ "\n"
+ catalog.i18nc("@text", "Make sure all your printers are turned ON and connected to Digital Factory.")
font: UM.Theme.getFont("medium")
elide: Text.ElideRight
}
Cura.SecondaryButton
{
id: refreshListButton
Layout.alignment: Qt.AlignmentFlag.AlignVCenter
text: catalog.i18nc("@button", "Refresh List")
iconSource: UM.Theme.getIcon("ArrowDoubleCircleRight")
onClicked: Cura.API.account.sync(true)
}
Cura.TertiaryButton
{
id: printerListTroubleshooting
Layout.column: 1
Layout.row: 1
Layout.fillWidth: true
leftPadding: 0
text: catalog.i18nc("@button", "Troubleshooting")
iconSource: UM.Theme.getIcon("LinkExternal")
onClicked: Qt.openUrlExternally("https://support.ultimaker.com/hc/en-us/articles/360012019239?utm_source=cura&utm_medium=software&utm_campaign=sync-material-wizard-troubleshoot-cloud-printer")
}
}
}
}
}
Item
{
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
Layout.alignment: Qt.AlignBottom
Cura.SecondaryButton
{
anchors.left: parent.left
text: catalog.i18nc("@button", "Sync materials with USB")
onClicked: swipeView.currentIndex = removableDriveSyncPage.SwipeView.index
}
Cura.PrimaryButton
{
id: syncButton
anchors.right: parent.right
text:
{
if(typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "error")
{
return catalog.i18nc("@button", "Try again");
}
if(typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "success")
{
return catalog.i18nc("@button", "Done");
}
return catalog.i18nc("@button", "Sync");
}
onClicked:
{
if(typeof syncModel !== "undefined" && syncModel.exportUploadStatus == "success")
{
materialsSyncDialog.close();
}
else
{
syncModel.exportUpload();
}
}
visible:
{
if(!syncModel) //When the dialog is created, this is not set yet.
{
return true;
}
return syncModel.exportUploadStatus != "uploading";
}
}
Item
{
anchors.right: parent.right
width: childrenRect.width
height: syncButton.height
visible: !syncButton.visible
UM.ColorImage
{
id: syncingIcon
height: UM.Theme.getSize("action_button_icon").height
width: height
anchors.verticalCenter: syncingLabel.verticalCenter
source: UM.Theme.getIcon("ArrowDoubleCircleRight")
color: UM.Theme.getColor("primary")
RotationAnimator
{
target: syncingIcon
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: true
}
}
UM.Label
{
id: syncingLabel
anchors.left: syncingIcon.right
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
text: catalog.i18nc("@button", "Syncing")
color: UM.Theme.getColor("primary")
font: UM.Theme.getFont("medium")
}
}
}
}
// Placeholder for when the user has no cloud printers.
ColumnLayout
{
spacing: UM.Theme.getSize("default_margin").height
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
visible: cloudPrinterList.count == 0
UM.Label
{
text: catalog.i18nc("@title:header", "No printers found")
font: UM.Theme.getFont("large_bold")
Layout.fillWidth: true
}
Item
{
Layout.fillWidth: true
Layout.fillHeight: true
Image
{
anchors.fill: parent
source: UM.Theme.getImage("3d_printer_faded")
sourceSize.width: width
fillMode: Image.PreserveAspectFit
}
}
UM.Label
{
text: catalog.i18nc("@text", "It seems like you don't have any compatible printers connected to Digital Factory. Make sure your printer is connected and it's running the latest firmware.")
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
Item
{
Layout.fillWidth: true
Layout.preferredHeight: parent.height / 4
Cura.TertiaryButton
{
text: catalog.i18nc("@button", "Learn how to connect your printer to Digital Factory")
iconSource: UM.Theme.getIcon("LinkExternal")
onClicked: Qt.openUrlExternally("https://support.ultimaker.com/hc/en-us/articles/360012019239?utm_source=cura&utm_medium=software&utm_campaign=sync-material-wizard-add-cloud-printer")
anchors.horizontalCenter: parent.horizontalCenter
maximumWidth: parent.width
}
}
Item
{
Layout.preferredHeight: childrenRect.height
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Cura.SecondaryButton
{
anchors.left: parent.left
text: catalog.i18nc("@button", "Sync materials with USB")
onClicked: swipeView.currentIndex = removableDriveSyncPage.SwipeView.index
}
RowLayout
{
anchors.right: parent.right
spacing: UM.Theme.getSize("default_margin").width
Cura.SecondaryButton
{
text: catalog.i18nc("@button", "Refresh")
iconSource: UM.Theme.getIcon("ArrowDoubleCircleRight")
outlineColor: "transparent"
onClicked: Cura.API.account.sync(true)
}
Cura.PrimaryButton
{
id: disabledSyncButton
text: catalog.i18nc("@button", "Sync")
enabled: false // If there are no printers, always disable this button.
}
}
}
}
}
Item
{
id: removableDriveSyncPage
ColumnLayout
{
spacing: UM.Theme.getSize("default_margin").height
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_margin").width
UM.Label
{
text: catalog.i18nc("@title:header", "Sync material profiles via USB")
font: UM.Theme.getFont("large_bold")
Layout.fillWidth: true
}
UM.Label
{
text: catalog.i18nc("@text In the UI this is followed by a list of steps the user needs to take.", "Follow the following steps to load the new material profiles to your printer.")
font: UM.Theme.getFont("medium")
wrapMode: Text.Wrap
Layout.fillWidth: true
}
RowLayout
{
Layout.fillWidth: true
Layout.fillHeight: true
spacing: UM.Theme.getSize("default_margin").width
Item
{
Layout.preferredWidth: parent.width / 3
Layout.fillHeight: true
Image
{
anchors.fill: parent
source: UM.Theme.getImage("insert_usb")
verticalAlignment: Image.AlignVCenter
horizontalAlignment: Image.AlignHCenter
fillMode: Image.PreserveAspectFit
sourceSize.width: width
}
}
UM.Label
{
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
text: "1. " + catalog.i18nc("@text", "Click the export material archive button.")
+ "\n2. " + catalog.i18nc("@text", "Save the .umm file on a USB stick.")
+ "\n3. " + catalog.i18nc("@text", "Insert the USB stick into your printer and launch the procedure to load new material profiles.")
font: UM.Theme.getFont("medium")
}
}
Cura.TertiaryButton
{
Layout.fillWidth: true
text: catalog.i18nc("@button", "How to load new material profiles to my printer")
iconSource: UM.Theme.getIcon("LinkExternal")
onClicked: Qt.openUrlExternally("https://support.ultimaker.com/hc/en-us/articles/4403319801106/?utm_source=cura&utm_medium=software&utm_campaign=add-material-profiles-via-usb")
}
Item
{
Layout.preferredHeight: childrenRect.height
Layout.alignment: Qt.AlignBottom
Layout.fillWidth: true
Cura.SecondaryButton
{
anchors.left: parent.left
text: catalog.i18nc("@button", "Back")
onClicked: swipeView.currentIndex = 0 //Reset to first page.
}
Cura.PrimaryButton
{
id: exportUsbButton
anchors.right: parent.right
property bool hasExported: false
text: materialsSyncDialog.hasExportedUsb ? catalog.i18nc("@button", "Done") : catalog.i18nc("@button", "Export material archive")
onClicked:
{
if(!materialsSyncDialog.hasExportedUsb)
{
exportUsbDialog.currentFolder = syncModel.getPreferredExportAllPath();
exportUsbDialog.open();
}
else
{
materialsSyncDialog.close();
}
}
}
}
}
}
}
property variant cloudPrinterList: Cura.GlobalStacksModel
{
filterConnectionType: 3 //Only show cloud connections.
filterOnlineOnly: true //Only show printers that are online.
filterCapabilities: ["import_material"] //Only show printers that can receive the material profiles.
}
property variant includeOfflinePrinterList: Cura.GlobalStacksModel
{
//In order to show a refresh button only when there are offline cloud printers, we need to know if there are any offline printers.
//A global stacks model without the filter for online-only printers allows this.
filterConnectionType: 3 //Still only show cloud connections.
}
property variant exportUsbDialog: FileDialog
{
title: catalog.i18nc("@title:window", "Export All Materials")
nameFilters: ["Material archives (*.umm)", "All files (*)"]
fileMode: FileDialog.SaveFile
onAccepted:
{
syncModel.exportAll(selectedFile);
CuraApplication.setDefaultPath("dialog_material_path", folder);
materialsSyncDialog.hasExportedUsb = true;
}
}
}
|