From 8d76bd86786e701131970960a75b0426040ec830 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 16:04:57 +0100 Subject: [PATCH] Small clean-up of log warnings Contributes to CL-1165 --- .../resources/qml/GenericPopUp.qml | 2 -- .../resources/qml/MonitorContextMenu.qml | 19 +++++++++---------- .../resources/qml/MonitorPrintJobCard.qml | 7 +++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml index 4430a6a30a..74d9377f3e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -197,9 +197,7 @@ Popup } function recalculateOrientation() { - // Flip direction if there is not enough screen space var availableSpace - var targetPosition = target.mapToItem(monitorFrame, 0, 0) // Stupid pop-up logic causes the pop-up to resize, so let's compute what it SHOULD be diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml index fecb5e3162..00b575173e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml @@ -21,15 +21,8 @@ Item { id: popUp - // If the pop-up won't fit in the window, flip it - direction: - { - var availableSpace = monitorFrame.height - var targetPosition = target.mapToItem(null, 0, 0) - var requiredSpace = targetPosition.y + target.height + contentWrapper.implicitHeight - console.log("available space", availableSpace - targetPosition.y + target.height) - return requiredSpace < availableSpace ? "top" : "bottom" - } + // Which way should the pop-up point? Default is up, but will flip when required + direction: "up" // Use dark grey for info blurbs and white for context menus color: "#ffffff" // TODO: Theme! @@ -60,7 +53,7 @@ Item } text: catalog.i18nc("@label", "Move to top"); visible: { - if (printJob && printJob.state == "queued" && !assigned) { + if (printJob && printJob.state == "queued" && !isAssigned(printJob)) { if (OutputDevice && OutputDevice.queuedPrintJobs[0]) { return OutputDevice.queuedPrintJobs[0].key != printJob.key; } @@ -180,4 +173,10 @@ Item function close() { popUp.close() } + function isAssigned(job) { + if (!job) { + return false; + } + return job.assignedPrinter ? true : false; + } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 9493ed33e6..14817d7dfb 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -27,7 +27,7 @@ Item ExpandableCard { enabled: printJob != null - borderColor: printJob.configurationChanges.length !== 0 ? "#f5a623" : "#CCCCCC" // TODO: Theme! + borderColor: printJob && printJob.configurationChanges.length !== 0 ? "#f5a623" : "#CCCCCC" // TODO: Theme! headerItem: Row { height: 48 * screenScaleFactor // TODO: Theme! @@ -177,8 +177,7 @@ Item id: printerConfiguration anchors.verticalCenter: parent.verticalCenter buildplate: "Glass" - configurations: - [ + configurations: !base.printJob ? [null, null] : [ base.printJob.configuration.extruderConfigurations[0], base.printJob.configuration.extruderConfigurations[1] ] @@ -241,7 +240,7 @@ Item MonitorContextMenu { id: contextMenu - printJob: printer ? printer.activePrintJob : null + printJob: base.printJob ? base.printJob : null target: contextMenuButton }