diff --git a/plugins/UM3NetworkPrinting/resources/qml/ConfigurationChangeBlock.qml b/plugins/UM3NetworkPrinting/resources/qml/ConfigurationChangeBlock.qml index 250449a763..63815b58bf 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/ConfigurationChangeBlock.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/ConfigurationChangeBlock.qml @@ -136,6 +136,9 @@ Item { elide: Text.ElideRight; font: UM.Theme.getFont("large_nonbold"); text: { + if (root.job === null) { + return ""; + } if (root.job.configurationChanges.length === 0) { return ""; } @@ -182,11 +185,13 @@ Item { } text: catalog.i18nc("@label", "Override"); visible: { - var length = root.job.configurationChanges.length; - for (var i = 0; i < length; i++) { - var typeOfChange = root.job.configurationChanges[i].typeOfChange; - if (typeOfChange === "material_insert" || typeOfChange === "buildplate_change") { - return false; + if (root.job & root.job.configurationChanges) { + var length = root.job.configurationChanges.length; + for (var i = 0; i < length; i++) { + var typeOfChange = root.job.configurationChanges[i].typeOfChange; + if (typeOfChange === "material_insert" || typeOfChange === "buildplate_change") { + return false; + } } } return true; @@ -203,6 +208,9 @@ Item { onYes: OutputDevice.forceSendJob(root.job.key); standardButtons: StandardButton.Yes | StandardButton.No; text: { + if (!root.job) { + return ""; + } var printJobName = formatPrintJobName(root.job.name); var confirmText = catalog.i18nc("@label", "Starting a print job with an incompatible configuration could damage your 3D printer. Are you sure you want to override the configuration and print %1?").arg(printJobName); return confirmText; diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintCoreConfiguration.qml index bede597287..e8abb8109e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintCoreConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintCoreConfiguration.qml @@ -73,7 +73,7 @@ Item { elide: Text.ElideRight; font: UM.Theme.getFont("default"); text: { - if (printCoreConfiguration != undefined && printCoreConfiguration.activeMaterial != undefined) { + if (printCoreConfiguration && printCoreConfiguration.activeMaterial != undefined) { return printCoreConfiguration.activeMaterial.name; } return ""; diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml index 41d28c89f1..7b956a2101 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml @@ -101,7 +101,14 @@ Item { width: parent.width; PrintJobContextMenuItem { - enabled: printJob && !running ? OutputDevice.queuedPrintJobs[0].key != printJob.key : false; + enabled: { + if (printJob && !running) { + if (OutputDevice && OutputDevice.queuedPrintJobs[0]) { + return OutputDevice.queuedPrintJobs[0].key != printJob.key; + } + } + return false; + } onClicked: { sendToTopConfirmationDialog.visible = true; popup.close(); @@ -169,7 +176,7 @@ Item { icon: StandardIcon.Warning; onYes: OutputDevice.sendJobToTop(printJob.key); standardButtons: StandardButton.Yes | StandardButton.No; - text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to move %1 to the top of the queue?").arg(printJob.name) : ""; + text: printJob && printJob.name ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to move %1 to the top of the queue?").arg(printJob.name) : ""; title: catalog.i18nc("@window:title", "Move print job to top"); } @@ -179,7 +186,7 @@ Item { icon: StandardIcon.Warning; onYes: OutputDevice.deleteJobFromQueue(printJob.key); standardButtons: StandardButton.Yes | StandardButton.No; - text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to delete %1?").arg(printJob.name) : ""; + text: printJob && printJob.name ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to delete %1?").arg(printJob.name) : ""; title: catalog.i18nc("@window:title", "Delete print job"); } @@ -189,7 +196,7 @@ Item { icon: StandardIcon.Warning; onYes: printJob.setState("abort"); standardButtons: StandardButton.Yes | StandardButton.No; - text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to abort %1?").arg(printJob.name) : ""; + text: printJob && printJob.name ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to abort %1?").arg(printJob.name) : ""; title: catalog.i18nc("@window:title", "Abort print"); } diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobInfoBlock.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobInfoBlock.qml index 335ee2ba47..fcdf3ba955 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobInfoBlock.qml @@ -78,7 +78,7 @@ Item { anchors.fill: parent; elide: Text.ElideRight; font: UM.Theme.getFont("default_bold"); - text: printJob ? printJob.name : ""; // Supress QML warnings + text: printJob && printJob.name ? printJob.name : ""; // Supress QML warnings visible: printJob; } } @@ -204,7 +204,7 @@ Item { elide: Text.ElideRight; font: UM.Theme.getFont("default_bold"); text: { - if (printJob) { + if (printJob !== null) { if (printJob.assignedPrinter == null) { if (printJob.state == "error") { return catalog.i18nc("@label", "Waiting for: Unavailable printer"); @@ -222,7 +222,7 @@ Item { PrinterInfoBlock { anchors.bottom: parent.bottom; - printer: root.printJob.assignedPrinter; + printer: root.printJon && root.printJob.assignedPrinter; printJob: root.printJob; } } @@ -398,11 +398,13 @@ Item { } text: catalog.i18nc("@label", "Override"); visible: { - var length = printJob.configurationChanges.length; - for (var i = 0; i < length; i++) { - var typeOfChange = printJob.configurationChanges[i].typeOfChange; - if (typeOfChange === "material_insert" || typeOfChange === "buildplate_change") { - return false; + if (printJob && printJob.configurationChanges) { + var length = printJob.configurationChanges.length; + for (var i = 0; i < length; i++) { + var typeOfChange = printJob.configurationChanges[i].typeOfChange; + if (typeOfChange === "material_insert" || typeOfChange === "buildplate_change") { + return false; + } } } return true; @@ -418,6 +420,9 @@ Item { onYes: OutputDevice.forceSendJob(printJob.key); standardButtons: StandardButton.Yes | StandardButton.No; text: { + if (!root.job) { + return ""; + } var printJobName = formatPrintJobName(printJob.name); var confirmText = catalog.i18nc("@label", "Starting a print job with an incompatible configuration could damage your 3D printer. Are you sure you want to override the configuration and print %1?").arg(printJobName); return confirmText; diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobTitle.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobTitle.qml index 9dc7dff62e..bfbddb7dce 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobTitle.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobTitle.qml @@ -27,7 +27,7 @@ Column { anchors.fill: parent; elide: Text.ElideRight; font: UM.Theme.getFont("default_bold"); - text: job ? job.name : ""; + text: job && job.name ? job.name : ""; visible: job; } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/PrinterCard.qml index ebfe160e06..1dcf5fd3ad 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrinterCard.qml @@ -161,12 +161,15 @@ Item { elide: Text.ElideRight; font: UM.Theme.getFont("default"); text: { + if (!printer) { + return ""; + } if (printer.state == "disabled") { return catalog.i18nc("@label", "Not available"); } else if (printer.state == "unreachable") { return catalog.i18nc("@label", "Unreachable"); } - if (printer.activePrintJob != null) { + if (printer.activePrintJob != null && printer.activePrintJob.name) { return printer.activePrintJob.name; } return catalog.i18nc("@label", "Available"); diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrinterCardDetails.qml b/plugins/UM3NetworkPrinting/resources/qml/PrinterCardDetails.qml index 0971776cc6..35a9372713 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrinterCardDetails.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrinterCardDetails.qml @@ -60,7 +60,7 @@ Item { PrintJobPreview { - job: root.printer.activePrintJob; + job: root.printer && root.printer.activePrintJob ? root.printer.activePrintJob : null; anchors.horizontalCenter: parent.horizontalCenter; } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrinterCardProgressBar.qml b/plugins/UM3NetworkPrinting/resources/qml/PrinterCardProgressBar.qml index 4fac99f7a2..81ad95bea9 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrinterCardProgressBar.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrinterCardProgressBar.qml @@ -8,7 +8,7 @@ import UM 1.3 as UM ProgressBar { property var progress: { - if (printer.activePrintJob == null) { + if (!printer || printer.activePrintJob == null) { return 0; } var result = printer.activePrintJob.timeElapsed / printer.activePrintJob.timeTotal; @@ -25,11 +25,10 @@ ProgressBar { /* Sometimes total minus elapsed is less than 0. Use Math.max() to prevent remaining time from ever being less than 0. Negative durations cause strange behavior such as displaying "-1h -1m". */ - var activeJob = printer.activePrintJob; - return Math.max(activeJob.timeTotal - activeJob.timeElapsed, 0); + return Math.max(printer.activePrintJob.timeTotal - printer.activePrintJob.timeElapsed, 0); } property var progressText: { - if (printer.activePrintJob == null) { + if (!printer.activePrintJob || !printer.activePrintJob.state ) { return ""; } switch (printer.activePrintJob.state) { @@ -65,6 +64,9 @@ ProgressBar { progress: Rectangle { id: progressItem; color: { + if (!printer.activePrintJob) { + return "black"; + } var state = printer.activePrintJob.state var inactiveStates = [ "pausing", diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrinterInfoBlock.qml b/plugins/UM3NetworkPrinting/resources/qml/PrinterInfoBlock.qml index b054eb458f..1b20593f9a 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrinterInfoBlock.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrinterInfoBlock.qml @@ -41,7 +41,7 @@ Item { } PrinterFamilyPill { - text: printer.type; + text: printer ? printer.type : ""; visible: !compatiblePills.visible && printer; } }