mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 08:14:22 +08:00
Code cleanup
CURA-1990
This commit is contained in:
parent
0faa7f4abb
commit
5f3c051ec6
@ -15,25 +15,32 @@ Rectangle
|
||||
UM.I18nCatalog { id: catalog; name:"cura"}
|
||||
|
||||
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
|
||||
property real progress: printerConnected ? Cura.MachineManager.printerOutputDevices[0].progress : 0;
|
||||
property int backendState: UM.Backend.state;
|
||||
property real progress: printerConnected ? Cura.MachineManager.printerOutputDevices[0].progress : 0
|
||||
property int backendState: UM.Backend.state
|
||||
|
||||
property variant statusColor:
|
||||
{
|
||||
if(!printerConnected)
|
||||
return UM.Theme.getColor("status_offline")
|
||||
else if(Cura.MachineManager.printerOutputDevices[0].jobState == "printing" || Cura.MachineManager.printerOutputDevices[0].jobState == "pre_print" || Cura.MachineManager.printerOutputDevices[0].jobState == "wait_cleanup" )
|
||||
return UM.Theme.getColor("status_busy")
|
||||
else if(Cura.MachineManager.printerOutputDevices[0].jobState == "ready" || Cura.MachineManager.printerOutputDevices[0].jobState == "")
|
||||
return UM.Theme.getColor("status_ready")
|
||||
else if(Cura.MachineManager.printerOutputDevices[0].jobState == "paused")
|
||||
return UM.Theme.getColor("status_paused")
|
||||
else if (Cura.MachineManager.printerOutputDevices[0].jobState == "error")
|
||||
return UM.Theme.getColor("status_stopped")
|
||||
else if (Cura.MachineManager.printerOutputDevices[0].jobState == "offline")
|
||||
return UM.Theme.getColor("status_offline")
|
||||
else
|
||||
return UM.Theme.getColor("text")
|
||||
return UM.Theme.getColor("status_offline");
|
||||
|
||||
switch(Cura.MachineManager.printerOutputDevices[0].jobState)
|
||||
{
|
||||
case "printing":
|
||||
case "pre_print":
|
||||
case "wait_cleanup":
|
||||
return UM.Theme.getColor("status_busy");
|
||||
case "ready":
|
||||
case "":
|
||||
return UM.Theme.getColor("status_ready");
|
||||
case "paused":
|
||||
return UM.Theme.getColor("status_paused");
|
||||
case "error":
|
||||
return UM.Theme.getColor("status_stopped");
|
||||
case "offline":
|
||||
return UM.Theme.getColor("status_offline");
|
||||
default:
|
||||
return UM.Theme.getColor("text");
|
||||
}
|
||||
}
|
||||
|
||||
property bool activity: Printer.getPlatformActivity;
|
||||
@ -42,37 +49,26 @@ Rectangle
|
||||
property string statusText:
|
||||
{
|
||||
if(!printerConnected)
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Not connected to a printer")
|
||||
}
|
||||
var printerOutputDevice = Cura.MachineManager.printerOutputDevices[0]
|
||||
if(printerOutputDevice.jobState == "offline")
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Lost connection with the printer")
|
||||
} else if(printerOutputDevice.jobState == "printing")
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Printing...")
|
||||
} else if(printerOutputDevice.jobState == "paused")
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Paused")
|
||||
}
|
||||
else if(printerOutputDevice.jobState == "pre_print")
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Preparing...")
|
||||
}
|
||||
else if(printerOutputDevice.jobState == "wait_cleanup")
|
||||
{
|
||||
return catalog.i18nc("@label:MonitorStatus", "Please remove the print")
|
||||
}
|
||||
else if(printerOutputDevice.jobState == "error")
|
||||
{
|
||||
return printerOutputDevice.errorText
|
||||
}
|
||||
else
|
||||
{
|
||||
return " "
|
||||
}
|
||||
|
||||
var printerOutputDevice = Cura.MachineManager.printerOutputDevices[0]
|
||||
switch(printerOutputDevice.jobState)
|
||||
{
|
||||
case "offline":
|
||||
return catalog.i18nc("@label:MonitorStatus", "Lost connection with the printer");
|
||||
case "printing":
|
||||
return catalog.i18nc("@label:MonitorStatus", "Printing...");
|
||||
case "paused":
|
||||
return catalog.i18nc("@label:MonitorStatus", "Paused");
|
||||
case "pre_print":
|
||||
return catalog.i18nc("@label:MonitorStatus", "Preparing...");
|
||||
case "wait_cleanup":
|
||||
return catalog.i18nc("@label:MonitorStatus", "Please remove the print");
|
||||
case "error":
|
||||
return printerOutputDevice.errorText;
|
||||
default:
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
Label
|
||||
@ -85,7 +81,7 @@ Rectangle
|
||||
|
||||
color: base.statusColor
|
||||
font: UM.Theme.getFont("large")
|
||||
text: statusText;
|
||||
text: statusText
|
||||
}
|
||||
|
||||
Label
|
||||
@ -96,7 +92,7 @@ Rectangle
|
||||
|
||||
color: base.statusColor
|
||||
font: UM.Theme.getFont("large")
|
||||
text: Math.round(progress) + "%";
|
||||
text: Math.round(progress) + "%"
|
||||
visible: printerConnected
|
||||
}
|
||||
|
||||
@ -136,7 +132,7 @@ Rectangle
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
|
||||
text: catalog.i18nc("@label:", "Abort Print")
|
||||
onClicked: { Cura.MachineManager.printerOutputDevices[0].setJobState("abort") }
|
||||
onClicked: Cura.MachineManager.printerOutputDevices[0].setJobState("abort")
|
||||
|
||||
|
||||
style: ButtonStyle
|
||||
@ -144,12 +140,28 @@ Rectangle
|
||||
background: Rectangle
|
||||
{
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active_border") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
|
||||
color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
|
||||
border.color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled_border");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active_border");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered_border");
|
||||
else
|
||||
return UM.Theme.getColor("action_button_border");
|
||||
}
|
||||
color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered");
|
||||
else
|
||||
return UM.Theme.getColor("action_button");
|
||||
}
|
||||
Behavior on color { ColorAnimation { duration: 50; } }
|
||||
|
||||
implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
|
||||
@ -158,9 +170,17 @@ Rectangle
|
||||
{
|
||||
id: actualLabel
|
||||
anchors.centerIn: parent
|
||||
color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active_text") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text")
|
||||
color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled_text");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active_text");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered_text");
|
||||
else
|
||||
return UM.Theme.getColor("action_button_text");
|
||||
}
|
||||
font: UM.Theme.getFont("action_button")
|
||||
text: control.text;
|
||||
}
|
||||
@ -184,19 +204,35 @@ Rectangle
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
|
||||
text: printerConnected ? Cura.MachineManager.printerOutputDevices[0].jobState == "paused" ? catalog.i18nc("@label:", "Resume") : catalog.i18nc("@label:", "Pause") : ""
|
||||
onClicked: { Cura.MachineManager.printerOutputDevices[0].jobState == "paused" ? Cura.MachineManager.printerOutputDevices[0].setJobState("print") : Cura.MachineManager.printerOutputDevices[0].setJobState("pause") }
|
||||
onClicked: Cura.MachineManager.printerOutputDevices[0].setJobState(Cura.MachineManager.printerOutputDevices[0].jobState == "paused" ? "print" : "pause")
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active_border") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
|
||||
color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
|
||||
border.color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled_border");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active_border");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered_border");
|
||||
else
|
||||
return UM.Theme.getColor("action_button_border");
|
||||
}
|
||||
color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered");
|
||||
else
|
||||
return UM.Theme.getColor("action_button");
|
||||
}
|
||||
Behavior on color { ColorAnimation { duration: 50; } }
|
||||
|
||||
implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
|
||||
@ -205,9 +241,17 @@ Rectangle
|
||||
{
|
||||
id: actualLabel
|
||||
anchors.centerIn: parent
|
||||
color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
|
||||
control.pressed ? UM.Theme.getColor("action_button_active_text") :
|
||||
control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text")
|
||||
color:
|
||||
{
|
||||
if(!control.enabled)
|
||||
return UM.Theme.getColor("action_button_disabled_text");
|
||||
else if(control.pressed)
|
||||
return UM.Theme.getColor("action_button_active_text");
|
||||
else if(control.hovered)
|
||||
return UM.Theme.getColor("action_button_hovered_text");
|
||||
else
|
||||
return UM.Theme.getColor("action_button_text");
|
||||
}
|
||||
font: UM.Theme.getFont("action_button")
|
||||
text: control.text;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user