diff --git a/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/PrintJobContextMenu.qml index 473fd87a34..11bc913d06 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,13 @@ Item { hoverEnabled: true; onClicked: parent.switchPopupState(); text: "\u22EE"; //Unicode; Three stacked points. - visible: printJob.state == "queued" || running ? 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! } @@ -102,7 +108,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 +121,75 @@ 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: { + if (!printJob) { + return false; + } + var states = ["queued", "sent_to_printer"]; + return states.indexOf(printJob.state) !== -1; + } } PrintJobContextMenuItem { - enabled: printJob && running; + enabled: visible && !(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: { + if (!printJob) { + return false; + } + var states = ["printing", "pausing", "paused", "resuming"]; + return states.indexOf(printJob.state) !== -1; + } } PrintJobContextMenuItem { - enabled: printJob && running; + enabled: visible && 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: { + if (!printJob) { + return false; + } + var states = ["pre_print", "printing", "pausing", "paused", "resuming"]; + return states.indexOf(printJob.state) !== -1; + } } } enter: Transition { @@ -205,11 +249,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) { @@ -217,4 +261,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 1b0777a8c0..eea8fac3e1 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! + height: visible ? 39 * screenScaleFactor : 0; // TODO: Theme! hoverEnabled: true; - visible: enabled; width: parent.width; } \ No newline at end of file