mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Review feedback
Now with unified style as agreed upon by Simon & Ian. Rules: - ID before all other props. - All props before children. - All props after ID in alphabetical order. - Empty line between children. - Semi-colons. Note: I didn't touch the DiscoverUM3Action because that's it's whole own UI part.
This commit is contained in:
parent
2c5095befb
commit
5ca0c599e9
18 changed files with 721 additions and 821 deletions
|
@ -17,107 +17,90 @@ ProgressBar {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
value: progress;
|
||||
width: parent.width;
|
||||
|
||||
style: ProgressBarStyle {
|
||||
property var remainingTime:
|
||||
{
|
||||
if(printer.activePrintJob == null)
|
||||
{
|
||||
return 0
|
||||
property var remainingTime: {
|
||||
if (printer.activePrintJob == null) {
|
||||
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". */
|
||||
var activeJob = printer.activePrintJob
|
||||
var activeJob = printer.activePrintJob;
|
||||
return Math.max(activeJob.timeTotal - activeJob.timeElapsed, 0);
|
||||
}
|
||||
property var progressText:
|
||||
{
|
||||
if(printer.activePrintJob == null)
|
||||
{
|
||||
return ""
|
||||
property var progressText: {
|
||||
if (printer.activePrintJob == null) {
|
||||
return "";
|
||||
}
|
||||
switch(printer.activePrintJob.state)
|
||||
{
|
||||
switch (printer.activePrintJob.state) {
|
||||
case "wait_cleanup":
|
||||
if(printer.activePrintJob.timeTotal > printer.activePrintJob.timeElapsed)
|
||||
{
|
||||
return catalog.i18nc("@label:status", "Aborted")
|
||||
if (printer.activePrintJob.timeTotal > printer.activePrintJob.timeElapsed) {
|
||||
return catalog.i18nc("@label:status", "Aborted");
|
||||
}
|
||||
return catalog.i18nc("@label:status", "Finished")
|
||||
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 "aborted":
|
||||
return catalog.i18nc("@label:status", "Aborted")
|
||||
return catalog.i18nc("@label:status", "Aborted");
|
||||
case "wait_user_action":
|
||||
return catalog.i18nc("@label:status", "Aborted")
|
||||
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 OutputDevice.formatDuration( remainingTime );
|
||||
case "resuming":
|
||||
return catalog.i18nc("@label:status", "Resuming")
|
||||
return catalog.i18nc("@label:status", "Resuming");
|
||||
case "queued":
|
||||
return catalog.i18nc("@label:status", "Action required")
|
||||
return catalog.i18nc("@label:status", "Action required");
|
||||
default:
|
||||
return OutputDevice.formatDuration( remainingTime )
|
||||
return OutputDevice.formatDuration( remainingTime );
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle
|
||||
{
|
||||
implicitWidth: 100
|
||||
implicitHeight: visible ? 24 : 0
|
||||
color: UM.Theme.getColor("viewport_background")
|
||||
background: Rectangle {
|
||||
color: UM.Theme.getColor("viewport_background");
|
||||
implicitHeight: visible ? 24 : 0;
|
||||
implicitWidth: 100;
|
||||
}
|
||||
|
||||
progress: Rectangle
|
||||
{
|
||||
color:
|
||||
{
|
||||
progress: Rectangle {
|
||||
id: progressItem;
|
||||
color: {
|
||||
var state = printer.activePrintJob.state
|
||||
var inactiveStates = [
|
||||
"pausing",
|
||||
"paused",
|
||||
"resuming",
|
||||
"wait_cleanup"
|
||||
]
|
||||
if(inactiveStates.indexOf(state) > -1 && remainingTime > 0)
|
||||
{
|
||||
return UM.Theme.getColor("monitor_tab_text_inactive")
|
||||
}
|
||||
else
|
||||
{
|
||||
return UM.Theme.getColor("primary")
|
||||
}
|
||||
}
|
||||
id: progressItem
|
||||
function getTextOffset()
|
||||
{
|
||||
if(progressItem.width + progressLabel.width + 16 < control.width)
|
||||
{
|
||||
return progressItem.width + UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
else
|
||||
{
|
||||
return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width
|
||||
];
|
||||
if (inactiveStates.indexOf(state) > -1 && remainingTime > 0) {
|
||||
return UM.Theme.getColor("monitor_tab_text_inactive");
|
||||
} else {
|
||||
return UM.Theme.getColor("primary");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
font: UM.Theme.getFont("default")
|
||||
Label {
|
||||
id: progressLabel;
|
||||
anchors {
|
||||
left: parent.left;
|
||||
leftMargin: getTextOffset();
|
||||
}
|
||||
text: progressText;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
color: progressItem.width + progressLabel.width < control.width ? "black" : "white";
|
||||
width: contentWidth;
|
||||
font: UM.Theme.getFont("default");
|
||||
}
|
||||
|
||||
function getTextOffset() {
|
||||
if (progressItem.width + progressLabel.width + 16 < control.width) {
|
||||
return progressItem.width + UM.Theme.getSize("default_margin").width;
|
||||
} else {
|
||||
return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
value: progress;
|
||||
width: parent.width;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue