From 5176ead0e2bb038348f679ed745e18c4fac8a890 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Aug 2018 15:07:31 +0200 Subject: [PATCH] Added print progress to sidebar CL-893 --- .../UM3NetworkPrinting/ClusterControlItem.qml | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml index 261685feda..da9bf1d457 100644 --- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml +++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml @@ -5,12 +5,16 @@ import QtQuick.Controls.Styles 1.3 import UM 1.3 as UM import Cura 1.0 as Cura + + Component { Rectangle { id: base property var lineColor: "#DCDCDC" // TODO: Should be linked to theme. + + property var cornerRadius: 4 * screenScaleFactor // TODO: Should be linked to theme. visible: OutputDevice != null anchors.fill: parent @@ -41,8 +45,6 @@ Component ScrollView { - id: queuedPrintJobs - anchors { top: activePrintersLabel.bottom @@ -60,7 +62,7 @@ Component delegate: Rectangle { width: parent.width - height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height + height: childrenRect.height + UM.Theme.getSize("default_margin").height id: base property var collapsed: true @@ -89,7 +91,7 @@ Component anchors.top: parent.top width: 50 height: 50 - color: "blue" + color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled") } Label @@ -249,6 +251,86 @@ Component } } } + + ProgressBar + { + property var progress: + { + var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal + if(result > 1.0) + { + result = 1.0 + } + return result + } + + id: jobProgressBar + width: parent.width + value: progress + anchors.top: detailedInfo.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + + visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined + + style: ProgressBarStyle + { + property var progressText: + { + if(modelData.activePrintJob == null) + { + return "" + } + + if(modelData.activePrintJob.state == "wait_cleanup") + { + return "Finshed" + } + else if(modelData.activePrintJob.state == "pre_print") + { + return "Preparing" + } + else + { + return OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed) + } + } + + background: Rectangle + { + implicitWidth: 100 + implicitHeight: visible ? 24 : 0 + color: UM.Theme.getColor("viewport_background") + } + + progress: Rectangle + { + color: UM.Theme.getColor("primary") + id: progressItem + function getTextOffset() + { + if(progressItem.width + progressLabel.width < control.width) + { + return progressItem.width + UM.Theme.getSize("default_margin").width + } + else + { + return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width + } + } + + Label + { + id: progressLabel + anchors.left: parent.left + anchors.leftMargin: getTextOffset() + text: progressText + anchors.verticalCenter: parent.verticalCenter + color: progressItem.width + progressLabel.width < control.width ? "black" : "white" + width: contentWidth + } + } + } + } } } }