From e7b60a529059772be8e70e69bc59a2c82038c726 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:29:57 +0100 Subject: [PATCH 01/20] Create GenericPopUp.qml Contributes to CL-1165 --- .../resources/qml/GenericPopUp.qml | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml new file mode 100644 index 0000000000..442de3cd7a --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -0,0 +1,202 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.0 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Dialogs 1.1 +import QtGraphicalEffects 1.0 +import UM 1.3 as UM + +/** + * This is a generic pop-up element which can be supplied with a target and a content + * item. The content item will appear to the left, right, above, or below the target + * depending on the value of the direction property + */ +Popup +{ + id: base + + /** + * The target item is what the pop-up is "tied" to, usually a button + */ + property var target + + /** + * Which side of the target should the contentItem appear on? + * Possible values include: + * - "top" + * - "bottom" + * - "left" + * - "right" + */ + property string direction: "bottom" + + /** + * Should the popup close when you click outside it? For example, this is + * disabled by the InfoBlurb component since it's opened and closed using mouse + * hovers, not clicks. + */ + property bool closeOnClick: true + + /** + * Use white for context menus, dark grey for info blurbs! + */ + property var color: "#ffffff" // TODO: Theme! + + background: Item + { + anchors.fill: parent + + DropShadow + { + anchors.fill: pointedRectangle + color: UM.Theme.getColor("monitor_shadow") + radius: UM.Theme.getSize("monitor_shadow_radius").width + source: pointedRectangle + transparentBorder: true + verticalOffset: 2 * screenScaleFactor + } + + Item + { + id: pointedRectangle + anchors + { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + height: parent.height - 10 * screenScaleFactor // Because of the shadow + width: parent.width - 10 * screenScaleFactor // Because of the shadow + + Rectangle + { + id: point + anchors + { + horizontalCenter: + { + switch(direction) + { + case "left": + return bloop.left + case "right": + return bloop.right + default: + return bloop.horizontalCenter + } + } + verticalCenter: + { + switch(direction) + { + case "top": + return bloop.top + case "bottom": + return bloop.bottom + default: + return bloop.verticalCenter + } + } + } + color: base.color + height: 12 * screenScaleFactor + transform: Rotation + { + angle: 45 + origin.x: point.width / 2 + origin.y: point.height / 2 + } + width: height + } + + Rectangle + { + id: bloop + anchors + { + fill: parent + leftMargin: direction == "left" ? 8 * screenScaleFactor : 0 + rightMargin: direction == "right" ? 8 * screenScaleFactor : 0 + topMargin: direction == "top" ? 8 * screenScaleFactor : 0 + bottomMargin: direction == "bottom" ? 8 * screenScaleFactor : 0 + } + color: base.color + width: parent.width + } + } + } + + onClosed: visible = false + onOpened: visible = true + closePolicy: closeOnClick ? Popup.CloseOnPressOutside : Popup.NoAutoClose + enter: Transition + { + NumberAnimation + { + duration: 75 + property: "visible" + } + } + exit: Transition + { + NumberAnimation + { + duration: 75 + property: "visible" + } + } + + clip: true + + padding: UM.Theme.getSize("monitor_shadow_radius").width + topPadding: direction == "top" ? padding + 8 * screenScaleFactor : padding + bottomPadding: direction == "bottom" ? padding + 8 * screenScaleFactor : padding + leftPadding: direction == "left" ? padding + 8 * screenScaleFactor : padding + rightPadding: direction == "right" ? padding + 8 * screenScaleFactor : padding + + transformOrigin: + { + switch(direction) + { + case "top": + return Popup.Top + case "bottom": + return Popup.Bottom + case "right": + return Popup.Right + case "left": + return Popup.Left + default: + direction = "bottom" + return Popup.Bottom + } + } + + visible: false; + + x: + { + switch(direction) + { + case "left": + return target.x + target.width + 4 * screenScaleFactor + case "right": + return target.x - base.width - 4 * screenScaleFactor + default: + return target.x + target.width / 2 - base.width / 2 + } + } + y: + { + switch(direction) + { + case "top": + return target.y + target.height + 4 * screenScaleFactor + case "bottom": + return target.y - base.height - 4 * screenScaleFactor + default: + return target.y + target.height / 2 - base.height / 2 + } + } +} From 920b7b6706d70760808c374bacd551d0c994ef9d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:30:11 +0100 Subject: [PATCH 02/20] Create MonitorInfoBlurb.qml Contributes to CL-1165 --- .../resources/qml/MonitorInfoBlurb.qml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml new file mode 100644 index 0000000000..f7d37b989a --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml @@ -0,0 +1,54 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.3 +import QtQuick.Controls 2.0 +import QtQuick.Dialogs 1.1 +import UM 1.3 as UM + +/** + * A MonitorInfoBlurb is an extension of the GenericPopUp used to show static information (vs. interactive context + * menus). It accepts some text (text), an item to link to to (target), and a specification of which side of the target + * to appear on (direction). It also sets the GenericPopUp's color to black, to differentiate itself from a menu. + */ +Item +{ + property alias text: innerLabel.text + property alias target: popUp.target + property alias direction: popUp.direction + + GenericPopUp + { + id: popUp + + // If the pop-up won't fit in the window, flip it + direction: target.y + target.height + contentWrapper.implicitHeight < monitorFrame.height ? "top" : "bottom" + + // Use dark grey for info blurbs and white for context menus + color: "#191919" // TODO: Theme! + + contentItem: Item + { + id: contentWrapper + implicitWidth: childrenRect.width + implicitHeight: innerLabel.contentHeight + 2 * innerLabel.padding + Label + { + id: innerLabel + padding: 12 * screenScaleFactor // TODO: Theme! + text: "" + wrapMode: Text.WordWrap + width: 240 * screenScaleFactor // TODO: Theme! + color: "white" // TODO: Theme! + font: UM.Theme.getFont("default") + } + } + } + + function open() { + popUp.open() + } + function close() { + popUp.close() + } +} From 4ce244362c19421552d17a3e31dc3faf306e22f7 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:30:39 +0100 Subject: [PATCH 03/20] Make camera button grey if disabled Contributes to CL-1165 --- plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml b/plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml index 6f054f9c19..afc295858f 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/CameraButton.qml @@ -9,12 +9,14 @@ import Cura 1.0 as Cura Rectangle { id: base + + property var enabled: true + property var iconSource: null; - color: "#0a0850" // TODO: Theme! + color: !enabled ? "#cccccc" : "#0a0850" // TODO: Theme! height: width; radius: Math.round(0.5 * width); width: 24 * screenScaleFactor; - property var enabled: true UM.RecolorImage { id: icon; From f6c754c57f068637139ec818190114b9c2e66637 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:31:26 +0100 Subject: [PATCH 04/20] Remove PropertyAnimation test --- .../UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index facfaaaaaf..909c7f143e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -156,9 +156,6 @@ Item } height: 72 * screenScaleFactor // TODO: Theme!te theRect's x property } - - // TODO: Make this work. - PropertyAnimation { target: printerConfiguration; property: "visible"; to: 0; loops: Animation.Infinite; duration: 500 } } From 4248deeb763ceeb7a7f9f43cbea1b3f66dfab95d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:31:49 +0100 Subject: [PATCH 05/20] Line-length fixes --- .../resources/qml/MonitorPrinterCard.qml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index 909c7f143e..d88230320e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -7,13 +7,11 @@ import QtQuick.Dialogs 1.1 import UM 1.3 as UM /** - * A Printer Card is has two main components: the printer portion and the print - * job portion, the latter being paired in the UI when a print job is paired - * a printer in-cluster. + * A Printer Card is has two main components: the printer portion and the print job portion, the latter being paired in + * the UI when a print job is paired a printer in-cluster. * - * NOTE: For most labels, a fixed height with vertical alignment is used to make - * layouts more deterministic (like the fixed-size textboxes used in original - * mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted + * NOTE: For most labels, a fixed height with vertical alignment is used to make layouts more deterministic (like the + * fixed-size textboxes used in original mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted * with '// FIXED-LINE-HEIGHT:'. */ Item @@ -25,9 +23,8 @@ Item property var borderSize: 1 * screenScaleFactor // TODO: Theme, and remove from here - // If the printer card's controls are enabled. This is used by the carousel - // to prevent opening the context menu or camera while the printer card is not - // "in focus" + // If the printer card's controls are enabled. This is used by the carousel to prevent opening the context menu or + // camera while the printer card is not "in focus" property var enabled: true width: 834 * screenScaleFactor // TODO: Theme! @@ -217,6 +214,7 @@ Item } border { + // TODO: Fix line length color: printer && printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0 ? "#f5a623" : "transparent" // TODO: Theme! width: borderSize // TODO: Remove once themed } From 5a78eb05415d6eedb052e3d01e5780d41aa6df45 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 16:32:26 +0100 Subject: [PATCH 06/20] Temporarily disable context menu and camera button Contributes to CL-1165 --- .../UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index d88230320e..0951cf1c2a 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -170,7 +170,8 @@ Item printJob: printer ? printer.activePrintJob : null width: 36 * screenScaleFactor // TODO: Theme! height: 36 * screenScaleFactor // TODO: Theme! - enabled: base.enabled + // enabled: base.enabled + enabled: false visible: printer } CameraButton @@ -184,7 +185,8 @@ Item bottomMargin: 20 * screenScaleFactor // TODO: Theme! } iconSource: "../svg/icons/camera.svg" - enabled: base.enabled + // enabled: base.enabled + enabled: false visible: printer } } From 5a15ffc09097ab3b175cfa08a63bac9b451bde31 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 17:03:41 +0100 Subject: [PATCH 07/20] Create MonitorContextMenuButton.qml Contributes to CL-1165 --- .../qml/MonitorContextMenuButton.qml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenuButton.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenuButton.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenuButton.qml new file mode 100644 index 0000000000..5cd3404870 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenuButton.qml @@ -0,0 +1,31 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.3 +import QtQuick.Controls 2.0 +import UM 1.3 as UM +import Cura 1.0 as Cura + +Button +{ + id: base + background: Rectangle + { + color: UM.Theme.getColor("viewport_background") // TODO: Theme! + height: base.height + opacity: base.down || base.hovered ? 1 : 0 + radius: Math.round(0.5 * width) + width: base.width + } + contentItem: Label { + color: UM.Theme.getColor("monitor_context_menu_dots") + font.pixelSize: 32 * screenScaleFactor + horizontalAlignment: Text.AlignHCenter + text: base.text + verticalAlignment: Text.AlignVCenter + } + height: width + hoverEnabled: enabled + text: "\u22EE" //Unicode Three stacked points. + width: 36 * screenScaleFactor // TODO: Theme! +} \ No newline at end of file From cdc24081a5f5abedd49818994cf32dd733abe307 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 17:03:56 +0100 Subject: [PATCH 08/20] Create MonitorPrinterContextMenu.qml Contributes to CL-1165 --- .../qml/MonitorPrinterContextMenu.qml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml new file mode 100644 index 0000000000..1015824ea4 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml @@ -0,0 +1,92 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.3 +import QtQuick.Controls 2.0 +import QtQuick.Dialogs 1.1 +import UM 1.3 as UM + +/** + * A MonitorInfoBlurb is an extension of the GenericPopUp used to show static information (vs. interactive context + * menus). It accepts some text (text), an item to link to to (target), and a specification of which side of the target + * to appear on (direction). It also sets the GenericPopUp's color to black, to differentiate itself from a menu. + */ +Item +{ + property alias target: popUp.target + + property var printJob: null + + GenericPopUp + { + 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 + return requiredSpace < availableSpace ? "top" : "bottom" + } + + // Use dark grey for info blurbs and white for context menus + color: "#ffffff" // TODO: Theme! + + contentItem: Item + { + id: contentWrapper + implicitWidth: childrenRect.width + implicitHeight: innerLabel.contentHeight + Label + { + id: innerLabel + text: "The future of context menus starts here!" + wrapMode: Text.WordWrap + width: 182 * screenScaleFactor // TODO: Theme! + color: "white" // TODO: Theme! + font: UM.Theme.getFont("default") + } + } + } + + MessageDialog { + id: sendToTopConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: OutputDevice.sendJobToTop(printJob.key) + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + MessageDialog { + id: deleteConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: OutputDevice.deleteJobFromQueue(printJob.key) + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + MessageDialog { + id: abortConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: printJob.setState("abort") + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + function switchPopupState() { + popUp.visible ? popUp.close() : popUp.open() + } + function open() { + popUp.open() + } + function close() { + popUp.close() + } +} From 548882e398591fae2f5e27312fd7f07530aeea6c Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 17:04:33 +0100 Subject: [PATCH 09/20] Use new context menu Contributes to CL-1165 --- .../resources/qml/MonitorPrinterCard.qml | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index 0951cf1c2a..7e5b42a48e 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -156,10 +156,9 @@ Item } - - PrintJobContextMenu + MonitorContextMenuButton { - id: contextButton + id: contextMenuButton anchors { right: parent.right @@ -167,16 +166,49 @@ Item top: parent.top topMargin: 12 * screenScaleFactor // TODO: Theme! } - printJob: printer ? printer.activePrintJob : null width: 36 * screenScaleFactor // TODO: Theme! height: 36 * screenScaleFactor // TODO: Theme! // enabled: base.enabled enabled: false - visible: printer + onClicked: enabled ? contextMenu.switchPopupState() : {} + visible: + { + if (!printer || !printer.activePrintJob) { + return false + } + var states = ["queued", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"] + return states.indexOf(printer.activePrintJob.state) !== -1 + } } + + MonitorPrinterContextMenu + { + id: contextMenu + printJob: printer ? printer.activePrintJob : null + target: contextMenuButton + } + + // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available + MouseArea + { + id: contextMenuDisabledButtonArea + anchors.fill: contextMenuButton + hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled + onEntered: contextMenuDisabledInfo.open() + onExited: contextMenuDisabledInfo.close() + enabled: !contextMenuButton.enabled + } + + MonitorInfoBlurb + { + id: contextMenuDisabledInfo + text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.") + target: contextMenuButton + } + CameraButton { - id: cameraButton; + id: cameraButton anchors { right: parent.right @@ -189,6 +221,24 @@ Item enabled: false visible: printer } + + // For cloud printing, add this mouse area over the disabled cameraButton to indicate that it's not available + MouseArea + { + id: cameraDisabledButtonArea + anchors.fill: cameraButton + hoverEnabled: cameraButton.visible && !cameraButton.enabled + onEntered: cameraDisabledInfo.open() + onExited: cameraDisabledInfo.close() + enabled: !cameraButton.enabled + } + + MonitorInfoBlurb + { + id: cameraDisabledInfo + text: catalog.i18nc("@info", "The webcam is not available because you are monitoring a cloud printer.") + target: cameraButton + } } From 669f6d8f0cb782a7bcd71943d9ab87fe9846d419 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 9 Jan 2019 17:04:51 +0100 Subject: [PATCH 10/20] Fix available space bug Contributes to CL-1165 --- .../resources/qml/MonitorInfoBlurb.qml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml index f7d37b989a..58b354afcf 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml @@ -3,7 +3,6 @@ import QtQuick 2.3 import QtQuick.Controls 2.0 -import QtQuick.Dialogs 1.1 import UM 1.3 as UM /** @@ -22,7 +21,13 @@ Item id: popUp // If the pop-up won't fit in the window, flip it - direction: target.y + target.height + contentWrapper.implicitHeight < monitorFrame.height ? "top" : "bottom" + direction: + { + var availableSpace = monitorFrame.height + var targetPosition = target.mapToItem(null, 0, 0) + var requiredSpace = targetPosition.y + target.height + contentWrapper.implicitHeight + return requiredSpace < availableSpace ? "top" : "bottom" + } // Use dark grey for info blurbs and white for context menus color: "#191919" // TODO: Theme! From 0622c5cb8b9582cd3e0cd49edcb89a8e98f5b9b2 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 09:22:27 +0100 Subject: [PATCH 11/20] Rename MonitorPrinterContextMenu to MonitorContextMenu --- .../resources/qml/MonitorContextMenu.qml | 183 ++++++++++++++++++ .../resources/qml/MonitorPrinterCard.qml | 3 +- .../qml/MonitorPrinterContextMenu.qml | 92 --------- 3 files changed, 184 insertions(+), 94 deletions(-) create mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml delete mode 100644 plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml new file mode 100644 index 0000000000..fecb5e3162 --- /dev/null +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorContextMenu.qml @@ -0,0 +1,183 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.3 +import QtQuick.Controls 2.0 +import QtQuick.Dialogs 1.1 +import UM 1.3 as UM + +/** + * A MonitorInfoBlurb is an extension of the GenericPopUp used to show static information (vs. interactive context + * menus). It accepts some text (text), an item to link to to (target), and a specification of which side of the target + * to appear on (direction). It also sets the GenericPopUp's color to black, to differentiate itself from a menu. + */ +Item +{ + property alias target: popUp.target + + property var printJob: null + + GenericPopUp + { + 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" + } + + // Use dark grey for info blurbs and white for context menus + color: "#ffffff" // TODO: Theme! + + contentItem: Item + { + id: contentWrapper + implicitWidth: childrenRect.width + implicitHeight: menuItems.height + UM.Theme.getSize("default_margin").height + + Column + { + id: menuItems + width: 144 * screenScaleFactor + + anchors + { + top: parent.top + topMargin: Math.floor(UM.Theme.getSize("default_margin").height / 2) + } + + spacing: Math.floor(UM.Theme.getSize("default_margin").height / 2) + + PrintJobContextMenuItem { + 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; + } + } + return false; + } + } + + PrintJobContextMenuItem { + 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: visible && !(printJob.state == "pausing" || printJob.state == "resuming"); + onClicked: { + if (printJob.state == "paused") { + printJob.setState("print"); + popUp.close(); + return; + } + if (printJob.state == "printing") { + printJob.setState("pause"); + popUp.close(); + return; + } + } + 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: visible && printJob.state !== "aborting"; + onClicked: { + abortConfirmationDialog.visible = true; + popUp.close(); + } + text: printJob && 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; + } + } + } + } + } + + MessageDialog { + id: sendToTopConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: OutputDevice.sendJobToTop(printJob.key) + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + MessageDialog { + id: deleteConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: OutputDevice.deleteJobFromQueue(printJob.key) + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + MessageDialog { + id: abortConfirmationDialog + Component.onCompleted: visible = false + icon: StandardIcon.Warning + onYes: printJob.setState("abort") + standardButtons: StandardButton.Yes | StandardButton.No + 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") + } + + function switchPopupState() { + popUp.visible ? popUp.close() : popUp.open() + } + function open() { + popUp.open() + } + function close() { + popUp.close() + } +} diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index 7e5b42a48e..517b696db8 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -155,7 +155,6 @@ Item } } - MonitorContextMenuButton { id: contextMenuButton @@ -181,7 +180,7 @@ Item } } - MonitorPrinterContextMenu + MonitorContextMenu { id: contextMenu printJob: printer ? printer.activePrintJob : null diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml deleted file mode 100644 index 1015824ea4..0000000000 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterContextMenu.qml +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.3 -import QtQuick.Controls 2.0 -import QtQuick.Dialogs 1.1 -import UM 1.3 as UM - -/** - * A MonitorInfoBlurb is an extension of the GenericPopUp used to show static information (vs. interactive context - * menus). It accepts some text (text), an item to link to to (target), and a specification of which side of the target - * to appear on (direction). It also sets the GenericPopUp's color to black, to differentiate itself from a menu. - */ -Item -{ - property alias target: popUp.target - - property var printJob: null - - GenericPopUp - { - 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 - return requiredSpace < availableSpace ? "top" : "bottom" - } - - // Use dark grey for info blurbs and white for context menus - color: "#ffffff" // TODO: Theme! - - contentItem: Item - { - id: contentWrapper - implicitWidth: childrenRect.width - implicitHeight: innerLabel.contentHeight - Label - { - id: innerLabel - text: "The future of context menus starts here!" - wrapMode: Text.WordWrap - width: 182 * screenScaleFactor // TODO: Theme! - color: "white" // TODO: Theme! - font: UM.Theme.getFont("default") - } - } - } - - MessageDialog { - id: sendToTopConfirmationDialog - Component.onCompleted: visible = false - icon: StandardIcon.Warning - onYes: OutputDevice.sendJobToTop(printJob.key) - standardButtons: StandardButton.Yes | StandardButton.No - 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") - } - - MessageDialog { - id: deleteConfirmationDialog - Component.onCompleted: visible = false - icon: StandardIcon.Warning - onYes: OutputDevice.deleteJobFromQueue(printJob.key) - standardButtons: StandardButton.Yes | StandardButton.No - 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") - } - - MessageDialog { - id: abortConfirmationDialog - Component.onCompleted: visible = false - icon: StandardIcon.Warning - onYes: printJob.setState("abort") - standardButtons: StandardButton.Yes | StandardButton.No - 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") - } - - function switchPopupState() { - popUp.visible ? popUp.close() : popUp.open() - } - function open() { - popUp.open() - } - function close() { - popUp.close() - } -} From 9c711cc8aa3729d7c6d97568b569ddfd14ed0c42 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 15:27:04 +0100 Subject: [PATCH 12/20] Pop-up flips directions Contributes to CL-1165 --- .../resources/qml/GenericPopUp.qml | 127 +++++++++++------- .../resources/qml/MonitorInfoBlurb.qml | 9 +- .../resources/qml/MonitorPrintJobCard.qml | 58 +++++++- 3 files changed, 131 insertions(+), 63 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml index 442de3cd7a..15a88ef3fd 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -44,6 +44,8 @@ Popup */ property var color: "#ffffff" // TODO: Theme! + Component.onCompleted: recalculatePosition() + background: Item { anchors.fill: parent @@ -127,25 +129,61 @@ Popup } } + visible: false onClosed: visible = false - onOpened: visible = true + onOpened: + { + // Flip direction if there is not enough screen space + var availableSpace + + var targetPosition = target.mapToItem(monitorFrame, 0, 0) + + var requiredSpace = contentItem.implicitHeight + 2 * padding + 8 * screenScaleFactor + + switch(direction) + { + case "top": + availableSpace = monitorFrame.height - (targetPosition.y + target.height) + // console.log("Needs", requiredSpace, "has got", availableSpace) + if (availableSpace < requiredSpace) + { + // console.log("putting point on bottom") + direction = "bottom" + } + break + case "bottom": + availableSpace = targetPosition.y + // console.log("Needs", requiredSpace, "has got", availableSpace) + if (availableSpace < requiredSpace) + { + // console.log("putting point on top") + direction = "top" + } + break + } + + recalculatePosition() + + // Show the pop up + visible = true + } closePolicy: closeOnClick ? Popup.CloseOnPressOutside : Popup.NoAutoClose - enter: Transition - { - NumberAnimation - { - duration: 75 - property: "visible" - } - } - exit: Transition - { - NumberAnimation - { - duration: 75 - property: "visible" - } - } + // enter: Transition + // { + // NumberAnimation + // { + // duration: 75 + // property: "visible" + // } + // } + // exit: Transition + // { + // NumberAnimation + // { + // duration: 75 + // property: "visible" + // } + // } clip: true @@ -155,48 +193,35 @@ Popup leftPadding: direction == "left" ? padding + 8 * screenScaleFactor : padding rightPadding: direction == "right" ? padding + 8 * screenScaleFactor : padding - transformOrigin: - { - switch(direction) - { - case "top": - return Popup.Top - case "bottom": - return Popup.Bottom - case "right": - return Popup.Right - case "left": - return Popup.Left - default: - direction = "bottom" - return Popup.Bottom + function recalculatePosition() { + + // Stupid pop-up logic causes the pop-up to resize, so let's compute what it SHOULD be + const realWidth = contentItem.implicitWidth + leftPadding + rightPadding + const realHeight = contentItem.implicitHeight + topPadding + bottomPadding + + var centered = { + x: target.x + target.width / 2 - realWidth / 2, + y: target.y + target.height / 2 - realHeight / 2 } - } - visible: false; - - x: - { switch(direction) { case "left": - return target.x + target.width + 4 * screenScaleFactor + x = target.x + target.width + y = centered.y + break case "right": - return target.x - base.width - 4 * screenScaleFactor - default: - return target.x + target.width / 2 - base.width / 2 - } - } - y: - { - switch(direction) - { + x = target.x - realWidth + y = centered.y + break case "top": - return target.y + target.height + 4 * screenScaleFactor + x = centered.x + y = target.y + target.height + break case "bottom": - return target.y - base.height - 4 * screenScaleFactor - default: - return target.y + target.height / 2 - base.height / 2 + x = centered.x + y = target.y - realHeight + break } } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml index 58b354afcf..7491f6c415 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml @@ -20,14 +20,7 @@ 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 - return requiredSpace < availableSpace ? "top" : "bottom" - } + direction: "top" // Use dark grey for info blurbs and white for context menus color: "#191919" // TODO: Theme! diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index f2b9c3cff7..9493ed33e6 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -198,18 +198,68 @@ Item } } - PrintJobContextMenu + // PrintJobContextMenu + // { + // id: contextButton + // anchors + // { + // right: parent.right; + // rightMargin: 8 * screenScaleFactor // TODO: Theme! + // top: parent.top + // topMargin: 8 * screenScaleFactor // TODO: Theme! + // } + // printJob: base.printJob + // width: 32 * screenScaleFactor // TODO: Theme! + // height: 32 * screenScaleFactor // TODO: Theme! + // } + + MonitorContextMenuButton { - id: contextButton + id: contextMenuButton anchors { - right: parent.right; + right: parent.right rightMargin: 8 * screenScaleFactor // TODO: Theme! top: parent.top topMargin: 8 * screenScaleFactor // TODO: Theme! } - printJob: base.printJob width: 32 * screenScaleFactor // TODO: Theme! height: 32 * screenScaleFactor // TODO: Theme! + // enabled: base.enabled + enabled: false + onClicked: enabled ? contextMenu.switchPopupState() : {} + visible: + { + if (!printJob) { + return false + } + var states = ["queued", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"] + return states.indexOf(printJob.state) !== -1 + } + } + + MonitorContextMenu + { + id: contextMenu + printJob: printer ? printer.activePrintJob : null + target: contextMenuButton + } + + // For cloud printing, add this mouse area over the disabled contextButton to indicate that it's not available + MouseArea + { + id: contextMenuDisabledButtonArea + anchors.fill: contextMenuButton + hoverEnabled: contextMenuButton.visible && !contextMenuButton.enabled + onEntered: contextMenuDisabledInfo.open() + onExited: contextMenuDisabledInfo.close() + enabled: !contextMenuButton.enabled + } + + MonitorInfoBlurb + { + id: contextMenuDisabledInfo + text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.") + target: contextMenuButton } } \ No newline at end of file From 292d04f3eaad4143cdc558f6d14253a42d240843 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 15:27:31 +0100 Subject: [PATCH 13/20] Remove transitions which caused graphical glitches Contributes to CL-1165 --- .../resources/qml/GenericPopUp.qml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml index 15a88ef3fd..7bdec1087c 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -168,22 +168,6 @@ Popup visible = true } closePolicy: closeOnClick ? Popup.CloseOnPressOutside : Popup.NoAutoClose - // enter: Transition - // { - // NumberAnimation - // { - // duration: 75 - // property: "visible" - // } - // } - // exit: Transition - // { - // NumberAnimation - // { - // duration: 75 - // property: "visible" - // } - // } clip: true From 612b0d0165a8775756c58955154d88a19912a4dc Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 15:54:58 +0100 Subject: [PATCH 14/20] Reset pop-up orientation if it moved Contributes to CL-1165 --- .../resources/qml/GenericPopUp.qml | 121 +++++++++++------- .../resources/qml/MonitorInfoBlurb.qml | 3 +- 2 files changed, 75 insertions(+), 49 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml index 7bdec1087c..4bcfade1f5 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -9,9 +9,9 @@ import QtGraphicalEffects 1.0 import UM 1.3 as UM /** - * This is a generic pop-up element which can be supplied with a target and a content - * item. The content item will appear to the left, right, above, or below the target - * depending on the value of the direction property + * This is a generic pop-up element which can be supplied with a target and a content item. The + * content item will appear to the left, right, above, or below the target depending on the value of + * the direction property */ Popup { @@ -23,14 +23,20 @@ Popup property var target /** - * Which side of the target should the contentItem appear on? + * Which direction should the pop-up "point"? * Possible values include: - * - "top" - * - "bottom" + * - "up" + * - "down" * - "left" * - "right" */ - property string direction: "bottom" + property string direction: "down" + + /** + * We save the default direction so that if a pop-up was flipped but later has space (i.e. it + * moved), we can unflip it back to the default direction. + */ + property string originalDirection: "" /** * Should the popup close when you click outside it? For example, this is @@ -44,7 +50,13 @@ Popup */ property var color: "#ffffff" // TODO: Theme! - Component.onCompleted: recalculatePosition() + Component.onCompleted: + { + recalculatePosition() + + // Set the direction here so it's only set once and never mutated + originalDirection = (' ' + direction).slice(1) + } background: Item { @@ -92,9 +104,9 @@ Popup { switch(direction) { - case "top": + case "up": return bloop.top - case "bottom": + case "down": return bloop.bottom default: return bloop.verticalCenter @@ -118,10 +130,10 @@ Popup anchors { fill: parent - leftMargin: direction == "left" ? 8 * screenScaleFactor : 0 - rightMargin: direction == "right" ? 8 * screenScaleFactor : 0 - topMargin: direction == "top" ? 8 * screenScaleFactor : 0 - bottomMargin: direction == "bottom" ? 8 * screenScaleFactor : 0 + leftMargin: direction == "left" ? 8 * screenScaleFactor : 0 + rightMargin: direction == "right" ? 8 * screenScaleFactor : 0 + topMargin: direction == "up" ? 8 * screenScaleFactor : 0 + bottomMargin: direction == "down" ? 8 * screenScaleFactor : 0 } color: base.color width: parent.width @@ -133,35 +145,10 @@ Popup onClosed: visible = false onOpened: { - // Flip direction if there is not enough screen space - var availableSpace - - var targetPosition = target.mapToItem(monitorFrame, 0, 0) - - var requiredSpace = contentItem.implicitHeight + 2 * padding + 8 * screenScaleFactor - - switch(direction) - { - case "top": - availableSpace = monitorFrame.height - (targetPosition.y + target.height) - // console.log("Needs", requiredSpace, "has got", availableSpace) - if (availableSpace < requiredSpace) - { - // console.log("putting point on bottom") - direction = "bottom" - } - break - case "bottom": - availableSpace = targetPosition.y - // console.log("Needs", requiredSpace, "has got", availableSpace) - if (availableSpace < requiredSpace) - { - // console.log("putting point on top") - direction = "top" - } - break - } + // Flip orientation if necessary + recalculateOrientation() + // Fix position if necessary recalculatePosition() // Show the pop up @@ -172,10 +159,10 @@ Popup clip: true padding: UM.Theme.getSize("monitor_shadow_radius").width - topPadding: direction == "top" ? padding + 8 * screenScaleFactor : padding - bottomPadding: direction == "bottom" ? padding + 8 * screenScaleFactor : padding - leftPadding: direction == "left" ? padding + 8 * screenScaleFactor : padding - rightPadding: direction == "right" ? padding + 8 * screenScaleFactor : padding + topPadding: direction == "up" ? padding + 8 * screenScaleFactor : padding + bottomPadding: direction == "down" ? padding + 8 * screenScaleFactor : padding + leftPadding: direction == "left" ? padding + 8 * screenScaleFactor : padding + rightPadding: direction == "right" ? padding + 8 * screenScaleFactor : padding function recalculatePosition() { @@ -198,14 +185,52 @@ Popup x = target.x - realWidth y = centered.y break - case "top": + case "up": x = centered.x y = target.y + target.height break - case "bottom": + case "down": x = centered.x y = target.y - realHeight break } } + + 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 + const realWidth = contentItem.implicitWidth + leftPadding + rightPadding + const realHeight = contentItem.implicitHeight + topPadding + bottomPadding + + switch(originalDirection) + { + case "up": + availableSpace = monitorFrame.height - (targetPosition.y + target.height) + direction = availableSpace < realHeight ? "down" : originalDirection + break + case "down": + availableSpace = targetPosition.y + // if (availableSpace < realHeight) + // { + // if (direction != originalDirection) + // { + + // } + // } + direction = availableSpace < realHeight ? "up" : originalDirection + break + case "right": + availableSpace = targetPosition.x + direction = availableSpace < realWidth ? "left" : originalDirection + break + case "left": + availableSpace = monitorFrame.width - (targetPosition.x + target.width) + direction = availableSpace < realWidth ? "right" : originalDirection + break + } + } } diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml index 7491f6c415..3a6800e999 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml @@ -20,7 +20,8 @@ Item { id: popUp - direction: "top" + // 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: "#191919" // TODO: Theme! From 3377ed0e6e6ee712339d1574e5405605c2145881 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 15:55:25 +0100 Subject: [PATCH 15/20] Remove some unused code Contributes to CL-1165 --- plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml index 4bcfade1f5..4430a6a30a 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/GenericPopUp.qml @@ -214,13 +214,6 @@ Popup break case "down": availableSpace = targetPosition.y - // if (availableSpace < realHeight) - // { - // if (direction != originalDirection) - // { - - // } - // } direction = availableSpace < realHeight ? "up" : originalDirection break case "right": From 8d76bd86786e701131970960a75b0426040ec830 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 10 Jan 2019 16:04:57 +0100 Subject: [PATCH 16/20] 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 } From 616d5a1f438388d2ac03d81fa146035a8b12a5c0 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 11 Jan 2019 10:43:50 +0100 Subject: [PATCH 17/20] Update MonitorPrintJobCard.qml Contributes to CL-1165 --- .../resources/qml/MonitorPrintJobCard.qml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 14817d7dfb..99b27c5ade 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -197,21 +197,6 @@ Item } } - // PrintJobContextMenu - // { - // id: contextButton - // anchors - // { - // right: parent.right; - // rightMargin: 8 * screenScaleFactor // TODO: Theme! - // top: parent.top - // topMargin: 8 * screenScaleFactor // TODO: Theme! - // } - // printJob: base.printJob - // width: 32 * screenScaleFactor // TODO: Theme! - // height: 32 * screenScaleFactor // TODO: Theme! - // } - MonitorContextMenuButton { id: contextMenuButton @@ -224,8 +209,7 @@ Item } width: 32 * screenScaleFactor // TODO: Theme! height: 32 * screenScaleFactor // TODO: Theme! - // enabled: base.enabled - enabled: false + enabled: base.enabled // TODO: Add cloud logic here! onClicked: enabled ? contextMenu.switchPopupState() : {} visible: { From f3d0010b87fdbd7188bb1a544a8ad0bdb4ff503b Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 17 Jan 2019 15:44:37 +0100 Subject: [PATCH 18/20] Add cloud connection condition Contributes to CL-1165 --- .../resources/qml/MonitorPrintJobCard.qml | 7 ++++++- .../resources/qml/MonitorPrinterCard.qml | 12 ++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml index 99b27c5ade..c3d98fcb40 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobCard.qml @@ -4,6 +4,7 @@ import QtQuick 2.2 import QtQuick.Controls 2.0 import UM 1.3 as UM +import Cura 1.0 as Cura /** * A Print Job Card is essentially just a filled-in Expandable Card item. All @@ -21,6 +22,10 @@ Item // The print job which all other data is derived from property var printJob: null + // If the printer is a cloud printer or not. Other items base their enabled state off of this boolean. In the future + // they might not need to though. + property bool cloudConnection: Cura.MachineManager.activeMachineHasActiveCloudConnection + width: parent.width height: childrenRect.height @@ -209,7 +214,7 @@ Item } width: 32 * screenScaleFactor // TODO: Theme! height: 32 * screenScaleFactor // TODO: Theme! - enabled: base.enabled // TODO: Add cloud logic here! + enabled: !cloudConnection onClicked: enabled ? contextMenu.switchPopupState() : {} visible: { diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml index 517b696db8..ec40f3d921 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorPrinterCard.qml @@ -5,6 +5,7 @@ import QtQuick 2.3 import QtQuick.Controls 2.0 import QtQuick.Dialogs 1.1 import UM 1.3 as UM +import Cura 1.0 as Cura /** * A Printer Card is has two main components: the printer portion and the print job portion, the latter being paired in @@ -27,6 +28,10 @@ Item // camera while the printer card is not "in focus" property var enabled: true + // If the printer is a cloud printer or not. Other items base their enabled state off of this boolean. In the future + // they might not need to though. + property bool cloudConnection: Cura.MachineManager.activeMachineHasActiveCloudConnection + width: 834 * screenScaleFactor // TODO: Theme! height: childrenRect.height @@ -167,8 +172,8 @@ Item } width: 36 * screenScaleFactor // TODO: Theme! height: 36 * screenScaleFactor // TODO: Theme! - // enabled: base.enabled - enabled: false + enabled: !cloudConnection + onClicked: enabled ? contextMenu.switchPopupState() : {} visible: { @@ -216,8 +221,7 @@ Item bottomMargin: 20 * screenScaleFactor // TODO: Theme! } iconSource: "../svg/icons/camera.svg" - // enabled: base.enabled - enabled: false + enabled: !cloudConnection visible: printer } From 1097f16011375270be1ca44d10b1ef0af7ffadcc Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 23 Jan 2019 12:08:20 +0100 Subject: [PATCH 19/20] Add theme (and dark mode) Contributes to CL-1165 --- plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml | 4 ++-- resources/themes/cura-light/theme.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml index 3a6800e999..21000b8bff 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorInfoBlurb.qml @@ -24,7 +24,7 @@ Item direction: "up" // Use dark grey for info blurbs and white for context menus - color: "#191919" // TODO: Theme! + color: UM.Theme.getColor("monitor_tooltip") contentItem: Item { @@ -38,7 +38,7 @@ Item text: "" wrapMode: Text.WordWrap width: 240 * screenScaleFactor // TODO: Theme! - color: "white" // TODO: Theme! + color: UM.Theme.getColor("monitor_tooltip_text") font: UM.Theme.getFont("default") } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 607711c2f3..b12385c962 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -422,7 +422,8 @@ "monitor_progress_bar_deactive": [192, 193, 194, 255], "monitor_progress_bar_empty": [245, 245, 245, 255], - "monitor_tooltips": [25, 25, 25, 255], + "monitor_tooltip": [25, 25, 25, 255], + "monitor_tooltip_text": [255, 255, 255, 255], "monitor_context_menu": [255, 255, 255, 255], "monitor_context_menu_hover": [245, 245, 245, 255], From e204696b618c9961db9f46b3de3518292e4782b0 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 23 Jan 2019 12:10:06 +0100 Subject: [PATCH 20/20] Add dark theme Contributes to CL-1165 --- resources/themes/cura-dark/theme.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/themes/cura-dark/theme.json b/resources/themes/cura-dark/theme.json index 56369b9508..6211320f10 100644 --- a/resources/themes/cura-dark/theme.json +++ b/resources/themes/cura-dark/theme.json @@ -238,7 +238,8 @@ "monitor_progress_bar_deactive": [102, 102, 102, 255], "monitor_progress_bar_empty": [67, 67, 67, 255], - "monitor_tooltips": [25, 25, 25, 255], + "monitor_tooltip": [25, 25, 25, 255], + "monitor_tooltip_text": [229, 229, 229, 255], "monitor_context_menu": [67, 67, 67, 255], "monitor_context_menu_hover": [30, 102, 215, 255],