Cura/resources/qml/Sidebar/PrinterOutput.qml
ChrisTerBeke 51405ca0f7 tmp
2017-12-05 13:29:04 +01:00

66 lines
2.2 KiB
QML

// Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import UM 1.2 as UM
import Cura 1.0 as Cura
Item
{
id: printerOutputSection
UM.I18nCatalog {
id: catalog
name: "cura"
}
color: UM.Theme.getColor("sidebar")
// status
property bool isMonitoring: false
// printer data
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property int backendState: UM.Backend.state
// print job data
property variant printDuration: PrintInformation.currentPrintTime
property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights
property variant printMaterialCosts: PrintInformation.materialCosts
property variant printMaterialNames: PrintInformation.materialNames
// helper function for padding pretty time
function strPadLeft(string, pad, length) {
return (new Array(length + 1).join(pad) + string).slice(-length);
}
// convert a timestamp to a human readable pretty time
function getPrettyTime (time) {
var hours = Math.floor(time / 3600)
time -= hours * 3600
var minutes = Math.floor(time / 60)
time -= minutes * 60
var seconds = Math.floor(time)
var finalTime = strPadLeft(hours, "0", 2) + ":" + strPadLeft(minutes, "0", 2) + ":" + strPadLeft(seconds, "0", 2)
return finalTime
}
// TODO: change name of this component
MonitorButton
{
id: monitorButton
implicitWidth: base.width
anchors.top: footerSeparator.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.bottom: parent.bottom
visible: monitoringPrint
}
}