Improve printer status and progress bar

Contributes to CL-1153
This commit is contained in:
Ian Paschal 2018-12-03 14:41:22 +01:00
parent a28cae0a43
commit c9ed044205
3 changed files with 99 additions and 86 deletions

View file

@ -21,7 +21,18 @@ Item
{
id: previewImage
anchors.fill: parent
opacity: printJob && printJob.state == "error" ? 0.5 : 1.0
opacity:
{
if (!printJob)
{
return 0
}
if (printJob.state == "error" || !printJob.isActive)
{
return 0.5
}
return 1.0
}
source: printJob ? printJob.previewImageUrl : ""
visible: printJob
}
@ -47,11 +58,32 @@ Item
UM.RecolorImage
{
id: statusImage
id: overlayIcon
anchors.centerIn: printJobPreview
color: UM.Theme.getColor("monitor_image_overlay")
height: 0.5 * printJobPreview.height
source: printJob && printJob.state == "error" ? "../svg/aborted-icon.svg" : ""
source:
{
switch(printJob.state)
{
case "error":
return "../svg/aborted-icon.svg"
case "wait_cleanup":
if (printJob.state == "wait_cleanup" && printJob.timeTotal > printJob.timeElapsed)
{
return "../svg/aborted-icon.svg"
}
break;
case "pausing":
return "../svg/paused-icon.svg"
case "paused":
return "../svg/paused-icon.svg"
case "resuming":
return "../svg/paused-icon.svg"
default:
return ""
}
}
sourceSize
{
height: height

View file

@ -15,31 +15,66 @@ import UM 1.3 as UM
Item
{
id: base
// The print job which all other information is dervied from
property var printJob: null
property var progress:
width: childrenRect.width
height: 18 * screenScaleFactor // TODO: Theme!
ProgressBar
{
if (!printJob)
id: progressBar
anchors
{
return 0
verticalCenter: parent.verticalCenter
}
var result = printJob.timeElapsed / printJob.timeTotal
if (result > 1.0)
value: printJob ? printJob.progress : 0
style: ProgressBarStyle
{
result = 1.0
}
return result
}
property var remainingTime:
background: Rectangle
{
if (!printJob) {
return 0
color: printJob && printJob.isActive ? "#e4e4f2" : "#f3f3f9" // TODO: Theme!
implicitHeight: visible ? 8 * screenScaleFactor : 0 // TODO: Theme!
implicitWidth: 180 * screenScaleFactor // TODO: Theme!
radius: 4 * screenScaleFactor // TODO: Theme!
}
/* Sometimes total minus elapsed is less than 0. Use Math.max() to prevent remaining
time from ever being less than 0. Negative durations cause strange behavior such
as displaying "-1h -1m". */
return Math.max(printer.activePrintJob.timeTotal - printer.activePrintJob.timeElapsed, 0)
progress: Rectangle
{
id: progressItem;
color: printJob && printJob.isActive ? "#0a0850" : "#9392b2" // TODO: Theme!
radius: 4 * screenScaleFactor // TODO: Theme!
}
property var progressText:
}
}
Label
{
id: percentLabel
anchors
{
left: progressBar.right
leftMargin: 18 * screenScaleFactor // TODO: Theme!
}
text: Math.round(printJob.progress * 100) + "%"
color: printJob && printJob.isActive ? "#374355" : "#babac1" // TODO: Theme!
width: contentWidth
font: UM.Theme.getFont("medium") // 14pt, regular
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Label
{
id: statusLabel
anchors
{
left: percentLabel.right
leftMargin: 18 * screenScaleFactor // TODO: Theme!
}
color: "#374355" // TODO: Theme!
font: UM.Theme.getFont("medium") // 14pt, regular
text:
{
if (!printJob)
{
@ -53,82 +88,25 @@ Item
return catalog.i18nc("@label:status", "Aborted")
}
return catalog.i18nc("@label:status", "Finished")
case "pre_print":
case "sent_to_printer":
return catalog.i18nc("@label:status", "Preparing")
return catalog.i18nc("@label:status", "Preparing...")
case "aborting":
return catalog.i18nc("@label:status", "Aborting...")
case "aborted":
return catalog.i18nc("@label:status", "Aborted")
case "wait_user_action":
return catalog.i18nc("@label:status", "Aborted")
case "pausing":
return catalog.i18nc("@label:status", "Pausing")
return catalog.i18nc("@label:status", "Pausing...")
case "paused":
return OutputDevice.formatDuration( remainingTime )
return catalog.i18nc("@label:status", "Paused")
case "resuming":
return catalog.i18nc("@label:status", "Resuming")
return catalog.i18nc("@label:status", "Resuming...")
case "queued":
return catalog.i18nc("@label:status", "Action required")
default:
return OutputDevice.formatDuration( remainingTime )
return catalog.i18nc("@label:status", "Finishes ") + OutputDevice.getDateCompleted( printJob.timeRemaining ) + " at " + OutputDevice.getTimeCompleted( printJob.timeRemaining )
}
}
width: childrenRect.width
height: 18 * screenScaleFactor // TODO: Theme!
ProgressBar
{
id: progressBar
anchors
{
verticalCenter: parent.verticalCenter
}
value: progress;
style: ProgressBarStyle
{
background: Rectangle
{
color: "#e4e4f2" // TODO: Theme!
implicitHeight: visible ? 8 * screenScaleFactor : 0 // TODO: Theme!
implicitWidth: 180 * screenScaleFactor // TODO: Theme!
radius: 4 * screenScaleFactor // TODO: Theme!
}
progress: Rectangle
{
id: progressItem;
color:
{
if (printJob)
{
var state = printJob.state
var inactiveStates = [
"pausing",
"paused",
"resuming",
"wait_cleanup"
]
if (inactiveStates.indexOf(state) > -1 && remainingTime > 0)
{
return UM.Theme.getColor("monitor_progress_fill_inactive")
}
}
return "#0a0850" // TODO: Theme!
}
radius: 4 * screenScaleFactor // TODO: Theme!
}
}
}
Label
{
id: progressLabel
anchors
{
left: progressBar.right
leftMargin: 18 * screenScaleFactor // TODO: Theme!
}
text: progressText
color: "#374355" // TODO: Theme!
width: contentWidth
font: UM.Theme.getFont("medium") // 14pt, regular
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!

View file

@ -183,6 +183,7 @@ Item
printJob: base.printer.activePrintJob
size: parent.height
}
visible: printer.activePrintJob
}
Item
@ -193,14 +194,15 @@ Item
}
width: 216 * screenScaleFactor // TODO: Theme!
height: printerNameLabel.height + printerFamilyPill.height + 6 * screenScaleFactor // TODO: Theme!
visible: printer.activePrintJob
Label
{
id: printerJobNameLabel
text: base.printer.activePrintJob ? base.printer.activePrintJob.name : "Untitled" // TODO: I18N
color: "#414054" // TODO: Theme!
color: printer.activePrintJob && printer.activePrintJob.isActive ? "#414054" : "#babac1" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("large") // 16pt, bold
text: base.printer.activePrintJob ? base.printer.activePrintJob.name : "Untitled" // TODO: I18N
width: parent.width
// FIXED-LINE-HEIGHT:
@ -217,10 +219,10 @@ Item
topMargin: 6 * screenScaleFactor // TODO: Theme!
left: printerJobNameLabel.left
}
text: printer.activePrintJob ? printer.activePrintJob.owner : "Anonymous" // TODO: I18N
color: "#53657d" // TODO: Theme!
color: printer.activePrintJob && printer.activePrintJob.isActive ? "#53657d" : "#babac1" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("very_small") // 12pt, regular
text: printer.activePrintJob ? printer.activePrintJob.owner : "Anonymous" // TODO: I18N
width: parent.width
// FIXED-LINE-HEIGHT:
@ -236,6 +238,7 @@ Item
verticalCenter: parent.verticalCenter
}
printJob: printer.activePrintJob
visible: printer.activePrintJob
}
}
}