Add the label and the icon indicating when Cura is unable to slice.

Contributes to CURA-5786.
This commit is contained in:
Diego Prado Gesto 2018-10-30 11:52:08 +01:00
parent 8fee8eeb5e
commit 79ed15aee1
3 changed files with 80 additions and 11 deletions

View file

@ -12,7 +12,9 @@ Column
{
id: widget
spacing: UM.Theme.getSize("default_margin").height
width: UM.Theme.getSize("action_panel_button").width
spacing: UM.Theme.getSize("thin_margin").height
UM.I18nCatalog
{
@ -23,30 +25,84 @@ Column
property real progress: UM.Backend.progress
property int backendState: UM.Backend.state
Rectangle
Item
{
id: message
width: parent.width
height: childrenRect.height
visible: widget.backendState == 4
UM.RecolorImage
{
id: warningImage
anchors.left: parent.left
source: UM.Theme.getIcon("warning")
width: UM.Theme.getSize("section_icon").width
height: UM.Theme.getSize("section_icon").height
sourceSize.width: width
sourceSize.height: height
color: UM.Theme.getColor("warning")
}
Label
{
id: unableToSliceLabel
anchors.left: warningImage.right
anchors.leftMargin: UM.Theme.getSize("thin_margin").width
text: catalog.i18nc("@label:PrintjobStatus", "Unable to Slice")
color: UM.Theme.getColor("warning")
font: UM.Theme.getFont("very_small")
}
}
// Progress bar, only visible when the backend is in the process of slice the printjob
ProgressBar
{
id: progressBar
width: parent.width
height: UM.Theme.getSize("progressbar").height
value: progress
visible: widget.backendState == 2
radius: UM.Theme.getSize("progressbar_radius").width
color: UM.Theme.getColor("progressbar_background")
Rectangle
background: Rectangle
{
width: Math.max(parent.width * base.progress)
height: parent.height
anchors.fill: parent
radius: UM.Theme.getSize("progressbar_radius").width
color: UM.Theme.getColor("progressbar_control")
color: UM.Theme.getColor("progressbar_background")
}
contentItem: Item
{
anchors.fill: parent
Rectangle
{
width: progressBar.visualPosition * parent.width
height: parent.height
radius: UM.Theme.getSize("progressbar_radius").width
color: UM.Theme.getColor("progressbar_control")
}
}
}
Cura.ActionButton
{
id: prepareButton
width: UM.Theme.getSize("action_panel_button").width
width: parent.width
height: UM.Theme.getSize("action_panel_button").height
text: widget.backendState == 1 ? catalog.i18nc("@button", "Prepare") : catalog.i18nc("@button", "Cancel")
text: autoSlice ? catalog.i18nc("@button", "Auto slicing...") : (widget.backendState == 1 ? catalog.i18nc("@button", "Slice") : catalog.i18nc("@button", "Cancel"))
enabled: !autoSlice
// Get the current value from the preferences
property bool autoSlice: UM.Preferences.getValue("general/auto_slice")
disabledColor: "transparent"
textDisabledColor: UM.Theme.getColor("primary")
outlineDisabledColor: "transparent"
onClicked:
{
if ([1, 5].indexOf(widget.backendState) != -1)
@ -59,4 +115,15 @@ Column
}
}
}
// React when the user changes the preference of having the auto slice enabled
Connections
{
target: UM.Preferences
onPreferenceChanged:
{
var autoSlice = UM.Preferences.getValue("general/auto_slice")
prepareButton.autoSlice = autoSlice
}
}
}