From 1abd0b3499a1a6d666f67dab25fb2ed865062c44 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 5 Nov 2018 15:45:17 +0100 Subject: [PATCH 1/3] Show "Pausing...", "Aborting...", and "Resuming..." texts Contributes to CL-1126 --- .../resources/qml/PrintJobContextMenu.qml | 56 +++++++++++++------ .../resources/qml/PrintJobContextMenuItem.qml | 3 +- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml index 473fd87a34..695b69f822 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml @@ -11,7 +11,7 @@ import UM 1.3 as UM Item { id: root; property var printJob: null; - property var running: isRunning(printJob); + property var started: isStarted(printJob); property var assigned: isAssigned(printJob); Button { @@ -34,7 +34,7 @@ Item { hoverEnabled: true; onClicked: parent.switchPopupState(); text: "\u22EE"; //Unicode; Three stacked points. - visible: printJob.state == "queued" || running ? true : false; + visible: printJob.state == "queued" || printJob.state == "aborted" || started ? true : false; width: 35 * screenScaleFactor; // TODO: Theme! } @@ -102,7 +102,12 @@ Item { width: parent.width; PrintJobContextMenuItem { - enabled: { + onClicked: { + sendToTopConfirmationDialog.visible = true; + popup.close(); + } + text: catalog.i18nc("@label", "Move to top"); + visible: { if (printJob && printJob.state == "queued" && !assigned) { if (OutputDevice && OutputDevice.queuedPrintJobs[0]) { return OutputDevice.queuedPrintJobs[0].key != printJob.key; @@ -110,42 +115,57 @@ Item { } return false; } - onClicked: { - sendToTopConfirmationDialog.visible = true; - popup.close(); - } - text: catalog.i18nc("@label", "Move to top"); } PrintJobContextMenuItem { - enabled: printJob && !running; onClicked: { deleteConfirmationDialog.visible = true; popup.close(); } text: catalog.i18nc("@label", "Delete"); + visible: printJob && !started && printJob.state !== "aborted" && printJob.state !== "finished"; } PrintJobContextMenuItem { - enabled: printJob && running; + enabled: !(printJob.state == "pausing" || printJob.state == "resuming"); onClicked: { if (printJob.state == "paused") { printJob.setState("print"); - } else if(printJob.state == "printing") { - printJob.setState("pause"); + popup.close(); + return; + } + if (printJob.state == "printing") { + printJob.setState("pause"); + popup.close(); + return; } - popup.close(); } - text: printJob && printJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause"); + text: { + if (!printJob) { + return ""; + } + switch(printJob.state) { + case "paused": + return catalog.i18nc("@label", "Resume"); + case "pausing": + return catalog.i18nc("@label", "Pausing..."); + case "resuming": + return catalog.i18nc("@label", "Resuming..."); + default: + catalog.i18nc("@label", "Pause"); + } + } + visible: printJob && started && printJob.state; } PrintJobContextMenuItem { - enabled: printJob && running; + enabled: printJob.state !== "aborting"; onClicked: { abortConfirmationDialog.visible = true; popup.close(); } - text: catalog.i18nc("@label", "Abort"); + text: printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort"); + visible: printJob && started; } } enter: Transition { @@ -205,11 +225,11 @@ Item { function switchPopupState() { popup.visible ? popup.close() : popup.open(); } - function isRunning(job) { + function isStarted(job) { if (!job) { return false; } - return ["paused", "printing", "pre_print"].indexOf(job.state) !== -1; + return ["pre_print", "printing", "pausing", "paused", "resuming", "aborting"].indexOf(job.state) !== -1; } function isAssigned(job) { if (!job) { diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml index 1b0777a8c0..18f5e3b305 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml @@ -12,13 +12,12 @@ Button { color: UM.Theme.getColor("monitor_context_menu_highlight"); } contentItem: Label { - color: UM.Theme.getColor("text"); + color: enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("text_inactive"); text: parent.text horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter; } height: 39 * screenScaleFactor; // TODO: Theme! hoverEnabled: true; - visible: enabled; width: parent.width; } \ No newline at end of file From dc4b69c386a8973d77427ffc57fe07d68379fe44 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 6 Nov 2018 16:37:47 +0100 Subject: [PATCH 2/3] Show context menu at the right times Contributes to CL-1126 --- .../resources/qml/PrintJobContextMenu.qml | 47 ++++++++++++++++--- .../resources/qml/PrintJobContextMenuItem.qml | 2 +- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml index 695b69f822..9462475c2f 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml @@ -34,7 +34,13 @@ Item { hoverEnabled: true; onClicked: parent.switchPopupState(); text: "\u22EE"; //Unicode; Three stacked points. - visible: printJob.state == "queued" || printJob.state == "aborted" || started ? true : false; + visible: { + if (!printJob) { + return false; + } + var states = ["queued", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"]; + return states.indexOf(printJob.state) !== -1; + } width: 35 * screenScaleFactor; // TODO: Theme! } @@ -123,11 +129,17 @@ Item { popup.close(); } text: catalog.i18nc("@label", "Delete"); - visible: printJob && !started && printJob.state !== "aborted" && printJob.state !== "finished"; + visible: { + if (!printJob) { + return false; + } + var states = ["queued", "sent_to_printer"]; + return states.indexOf(printJob.state) !== -1; + } } PrintJobContextMenuItem { - enabled: !(printJob.state == "pausing" || printJob.state == "resuming"); + enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming"); onClicked: { if (printJob.state == "paused") { printJob.setState("print"); @@ -155,17 +167,29 @@ Item { catalog.i18nc("@label", "Pause"); } } - visible: printJob && started && printJob.state; + visible: { + if (!printJob) { + return false; + } + var states = ["printing", "pausing", "paused", "resuming"]; + return states.indexOf(printJob.state) !== -1; + } } PrintJobContextMenuItem { - enabled: printJob.state !== "aborting"; + enabled: visible && printJob.state !== "aborting"; onClicked: { abortConfirmationDialog.visible = true; popup.close(); } text: printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort"); - visible: printJob && started; + visible: { + if (!printJob) { + return false; + } + var states = ["pre_print", "printing", "pausing", "paused", "resuming"]; + return states.indexOf(printJob.state) !== -1; + } } } enter: Transition { @@ -224,6 +248,8 @@ Item { // Utils function switchPopupState() { popup.visible ? popup.close() : popup.open(); + console.log("printJob.state is:", printJob.state); + console.log("children.length is:", getMenuLength()); } function isStarted(job) { if (!job) { @@ -237,4 +263,13 @@ Item { } return job.assignedPrinter ? true : false; } + function getMenuLength() { + var visible = 0; + for (var i = 0; i < popupOptions.children.length; i++) { + if (popupOptions.children[i].visible) { + visible++; + } + } + return visible; + } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml index 18f5e3b305..eea8fac3e1 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenuItem.qml @@ -17,7 +17,7 @@ Button { horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter; } - height: 39 * screenScaleFactor; // TODO: Theme! + height: visible ? 39 * screenScaleFactor : 0; // TODO: Theme! hoverEnabled: true; width: parent.width; } \ No newline at end of file From 4c831de06ca6ba186208a2fed28b4fbd08b086de Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 6 Nov 2018 16:41:59 +0100 Subject: [PATCH 3/3] Remove console logs Contributes to CL-1126 --- .../UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml index 9462475c2f..11bc913d06 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml @@ -248,8 +248,6 @@ Item { // Utils function switchPopupState() { popup.visible ? popup.close() : popup.open(); - console.log("printJob.state is:", printJob.state); - console.log("children.length is:", getMenuLength()); } function isStarted(job) { if (!job) {