mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Clean up some QML warnings
Contributes to CL-1051
This commit is contained in:
parent
3ef6359930
commit
1fa7a8880b
9 changed files with 51 additions and 26 deletions
|
@ -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,6 +185,7 @@ Item {
|
|||
}
|
||||
text: catalog.i18nc("@label", "Override");
|
||||
visible: {
|
||||
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;
|
||||
|
@ -189,6 +193,7 @@ Item {
|
|||
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;
|
||||
|
|
|
@ -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 "";
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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,6 +398,7 @@ Item {
|
|||
}
|
||||
text: catalog.i18nc("@label", "Override");
|
||||
visible: {
|
||||
if (printJob && printJob.configurationChanges) {
|
||||
var length = printJob.configurationChanges.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
var typeOfChange = printJob.configurationChanges[i].typeOfChange;
|
||||
|
@ -405,6 +406,7 @@ Item {
|
|||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -60,7 +60,7 @@ Item {
|
|||
|
||||
|
||||
PrintJobPreview {
|
||||
job: root.printer.activePrintJob;
|
||||
job: root.printer && root.printer.activePrintJob ? root.printer.activePrintJob : null;
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -41,7 +41,7 @@ Item {
|
|||
}
|
||||
|
||||
PrinterFamilyPill {
|
||||
text: printer.type;
|
||||
text: printer ? printer.type : "";
|
||||
visible: !compatiblePills.visible && printer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue