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