mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
Improve printer status and progress bar
Contributes to CL-1153
This commit is contained in:
parent
a28cae0a43
commit
c9ed044205
3 changed files with 99 additions and 86 deletions
|
@ -15,63 +15,10 @@ 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:
|
||||
{
|
||||
if (!printJob)
|
||||
{
|
||||
return 0
|
||||
}
|
||||
var result = printJob.timeElapsed / printJob.timeTotal
|
||||
if (result > 1.0)
|
||||
{
|
||||
result = 1.0
|
||||
}
|
||||
return result
|
||||
}
|
||||
property var remainingTime:
|
||||
{
|
||||
if (!printJob) {
|
||||
return 0
|
||||
}
|
||||
/* 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)
|
||||
}
|
||||
property var progressText:
|
||||
{
|
||||
if (!printJob)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
switch (printJob.state)
|
||||
{
|
||||
case "wait_cleanup":
|
||||
if (printJob.timeTotal > printJob.timeElapsed)
|
||||
{
|
||||
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")
|
||||
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")
|
||||
case "paused":
|
||||
return OutputDevice.formatDuration( remainingTime )
|
||||
case "resuming":
|
||||
return catalog.i18nc("@label:status", "Resuming")
|
||||
case "queued":
|
||||
return catalog.i18nc("@label:status", "Action required")
|
||||
default:
|
||||
return OutputDevice.formatDuration( remainingTime )
|
||||
}
|
||||
}
|
||||
|
||||
width: childrenRect.width
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
|
||||
|
@ -82,12 +29,12 @@ Item
|
|||
{
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
value: progress;
|
||||
value: printJob ? printJob.progress : 0
|
||||
style: ProgressBarStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
color: "#e4e4f2" // TODO: Theme!
|
||||
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!
|
||||
|
@ -95,41 +42,72 @@ Item
|
|||
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!
|
||||
}
|
||||
color: printJob && printJob.isActive ? "#0a0850" : "#9392b2" // TODO: Theme!
|
||||
radius: 4 * screenScaleFactor // TODO: Theme!
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
id: progressLabel
|
||||
id: percentLabel
|
||||
anchors
|
||||
{
|
||||
left: progressBar.right
|
||||
leftMargin: 18 * screenScaleFactor // TODO: Theme!
|
||||
}
|
||||
text: progressText
|
||||
color: "#374355" // 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)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
switch (printJob.state)
|
||||
{
|
||||
case "wait_cleanup":
|
||||
if (printJob.timeTotal > printJob.timeElapsed)
|
||||
{
|
||||
return catalog.i18nc("@label:status", "Aborted")
|
||||
}
|
||||
return catalog.i18nc("@label:status", "Finished")
|
||||
case "sent_to_printer":
|
||||
return catalog.i18nc("@label:status", "Preparing...")
|
||||
case "aborting":
|
||||
return catalog.i18nc("@label:status", "Aborting...")
|
||||
case "aborted":
|
||||
return catalog.i18nc("@label:status", "Aborted")
|
||||
case "pausing":
|
||||
return catalog.i18nc("@label:status", "Pausing...")
|
||||
case "paused":
|
||||
return catalog.i18nc("@label:status", "Paused")
|
||||
case "resuming":
|
||||
return catalog.i18nc("@label:status", "Resuming...")
|
||||
case "queued":
|
||||
return catalog.i18nc("@label:status", "Action required")
|
||||
default:
|
||||
return catalog.i18nc("@label:status", "Finishes ") + OutputDevice.getDateCompleted( printJob.timeRemaining ) + " at " + OutputDevice.getTimeCompleted( printJob.timeRemaining )
|
||||
}
|
||||
}
|
||||
width: contentWidth
|
||||
|
||||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue