First printer tile no longer has shadow cut off from top

CL-894
This commit is contained in:
Jaime van Kessel 2018-08-24 13:50:52 +02:00
parent c13f252193
commit bc651fea92

View file

@ -70,312 +70,317 @@ Component
leftMargin: 2 * UM.Theme.getSize("default_margin").width leftMargin: 2 * UM.Theme.getSize("default_margin").width
rightMargin: 2 * UM.Theme.getSize("default_margin").width rightMargin: 2 * UM.Theme.getSize("default_margin").width
} }
spacing: UM.Theme.getSize("default_margin").height spacing: UM.Theme.getSize("default_margin").height -10
model: OutputDevice.printers model: OutputDevice.printers
delegate: Rectangle delegate: Item
{ {
width: parent.width - 2 * shadowRadius width: parent.width
height: childrenRect.height + UM.Theme.getSize("default_margin").height height: base.height + 2 * base.shadowRadius // To ensure that the shadow doesn't get cut off.
anchors.horizontalCenter: parent.horizontalCenter Rectangle
id: base
property var shadowRadius: 5
property var collapsed: true
layer.enabled: true
layer.effect: DropShadow
{ {
radius: base.shadowRadius width: parent.width - 2 * shadowRadius
verticalOffset: 2 height: childrenRect.height + UM.Theme.getSize("default_margin").height
color: "#3F000000" // 25% shadow anchors.horizontalCenter: parent.horizontalCenter
} anchors.verticalCenter: parent.verticalCenter
id: base
property var shadowRadius: 5
property var collapsed: true
Item layer.enabled: true
{ layer.effect: DropShadow
id: printerInfo
height: machineIcon.height
anchors
{ {
top: parent.top radius: base.shadowRadius
left: parent.left verticalOffset: 2
right: parent.right color: "#3F000000" // 25% shadow
margins: UM.Theme.getSize("default_margin").width
} }
MouseArea Item
{ {
anchors.fill: parent id: printerInfo
onClicked: base.collapsed = !base.collapsed height: machineIcon.height
}
Rectangle
{
id: machineIcon
anchors.top: parent.top
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.left: parent.left
width: 50
height: 50
color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled")
}
Label
{
id: machineNameLabel
text: modelData.name
anchors.top: machineIcon.top
anchors.left: machineIcon.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.right: collapseIcon.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
elide: Text.ElideRight
}
UM.RecolorImage
{
id: collapseIcon
width: 15
height: 15
sourceSize.width: width
sourceSize.height: height
source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
color: "black"
}
Label
{
id: activeJobLabel
text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting"
anchors.top: machineNameLabel.bottom
anchors.left: machineNameLabel.left
anchors.right: collapseIcon.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
elide: Text.ElideRight
}
}
Item
{
id: detailedInfo
property var printJob: modelData.activePrintJob
visible: height == childrenRect.height
anchors.top: printerInfo.bottom
width: parent.width
height: !base.collapsed ? childrenRect.height : 0
opacity: visible ? 1 : 0
Behavior on height { NumberAnimation { duration: 100 } }
Behavior on opacity { NumberAnimation { duration: 100 } }
Rectangle
{
id: topSpacer
color: UM.Theme.getColor("viewport_background")
height: 2
anchors anchors
{ {
left: parent.left
right: parent.right
margins: UM.Theme.getSize("default_margin").width
top: parent.top top: parent.top
topMargin: UM.Theme.getSize("default_margin").width
}
}
Row
{
id: extrudersInfo
anchors.top: topSpacer.bottom
anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
anchors.left: parent.left
anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width
anchors.right: parent.right
anchors.rightMargin: 2 * UM.Theme.getSize("default_margin").width
height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width
PrintCoreConfiguration
{
id: leftExtruderInfo
width: Math.round(parent.width / 2)
printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[0]
}
PrintCoreConfiguration
{
id: rightExtruderInfo
width: Math.round(parent.width / 2)
printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[1]
}
}
Rectangle
{
id: jobSpacer
color: UM.Theme.getColor("viewport_background")
height: 2
anchors
{
left: parent.left left: parent.left
right: parent.right right: parent.right
margins: UM.Theme.getSize("default_margin").width margins: UM.Theme.getSize("default_margin").width
top: extrudersInfo.bottom }
topMargin: 2 * UM.Theme.getSize("default_margin").height
MouseArea
{
anchors.fill: parent
onClicked: base.collapsed = !base.collapsed
}
Rectangle
{
id: machineIcon
anchors.top: parent.top
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.left: parent.left
width: 50
height: 50
color: modelData.activePrintJob != undefined ? UM.Theme.getColor("primary") : UM.Theme.getColor("setting_control_disabled")
}
Label
{
id: machineNameLabel
text: modelData.name
anchors.top: machineIcon.top
anchors.left: machineIcon.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.right: collapseIcon.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
elide: Text.ElideRight
}
UM.RecolorImage
{
id: collapseIcon
width: 15
height: 15
sourceSize.width: width
sourceSize.height: height
source: base.collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
color: "black"
}
Label
{
id: activeJobLabel
text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "waiting"
anchors.top: machineNameLabel.bottom
anchors.left: machineNameLabel.left
anchors.right: collapseIcon.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
elide: Text.ElideRight
} }
} }
Item Item
{ {
id: jobInfo id: detailedInfo
property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued" property var printJob: modelData.activePrintJob
visible: height == childrenRect.height
anchors.top: jobSpacer.bottom anchors.top: printerInfo.bottom
anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height width: parent.width
anchors.left: parent.left height: !base.collapsed ? childrenRect.height : 0
anchors.right: parent.right opacity: visible ? 1 : 0
anchors.margins: UM.Theme.getSize("default_margin").width Behavior on height { NumberAnimation { duration: 100 } }
anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width Behavior on opacity { NumberAnimation { duration: 100 } }
height: showJobInfo ? childrenRect.height + 2 * UM.Theme.getSize("default_margin").height: 0 Rectangle
visible: showJobInfo
Label
{ {
id: printJobName id: topSpacer
text: modelData.activePrintJob != null ? modelData.activePrintJob.name : "" color: UM.Theme.getColor("viewport_background")
font: UM.Theme.getFont("default_bold") height: 2
} anchors
Label {
{ left: parent.left
id: ownerName right: parent.right
anchors.top: printJobName.bottom margins: UM.Theme.getSize("default_margin").width
text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : "" top: parent.top
topMargin: UM.Theme.getSize("default_margin").width
}
} }
Image Row
{ {
id: printJobPreview id: extrudersInfo
source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : "" anchors.top: topSpacer.bottom
anchors.top: ownerName.bottom anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
anchors.horizontalCenter: parent.horizontalCenter anchors.left: parent.left
width: parent.width / 2 anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width
height: width anchors.right: parent.right
anchors.rightMargin: 2 * UM.Theme.getSize("default_margin").width
height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width
PrintCoreConfiguration
{
id: leftExtruderInfo
width: Math.round(parent.width / 2)
printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[0]
}
PrintCoreConfiguration
{
id: rightExtruderInfo
width: Math.round(parent.width / 2)
printCoreConfiguration: modelData.printerConfiguration.extruderConfigurations[1]
}
} }
Rectangle Rectangle
{ {
id: showCameraIcon id: jobSpacer
width: 35 * screenScaleFactor color: UM.Theme.getColor("viewport_background")
height: width height: 2
radius: 0.5 * width anchors
{
left: parent.left
right: parent.right
margins: UM.Theme.getSize("default_margin").width
top: extrudersInfo.bottom
topMargin: 2 * UM.Theme.getSize("default_margin").height
}
}
Item
{
id: jobInfo
property var showJobInfo: modelData.activePrintJob != null && modelData.activePrintJob.state != "queued"
anchors.top: jobSpacer.bottom
anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: printJobPreview.bottom anchors.right: parent.right
color: UM.Theme.getColor("setting_control_border_highlight") anchors.margins: UM.Theme.getSize("default_margin").width
anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width
height: showJobInfo ? childrenRect.height + 2 * UM.Theme.getSize("default_margin").height: 0
visible: showJobInfo
Label
{
id: printJobName
text: modelData.activePrintJob != null ? modelData.activePrintJob.name : ""
font: UM.Theme.getFont("default_bold")
}
Label
{
id: ownerName
anchors.top: printJobName.bottom
text: modelData.activePrintJob != null ? modelData.activePrintJob.owner : ""
}
Image Image
{ {
width: parent.width id: printJobPreview
source: modelData.activePrintJob != null ? modelData.activePrintJob.preview_image_url : ""
anchors.top: ownerName.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 2
height: width height: width
anchors.right: parent.right
anchors.rightMargin: parent.rightMargin
source: "camera-icon.svg"
} }
MouseArea
Rectangle
{ {
anchors.fill:parent id: showCameraIcon
onClicked: width: 35 * screenScaleFactor
height: width
radius: 0.5 * width
anchors.left: parent.left
anchors.bottom: printJobPreview.bottom
color: UM.Theme.getColor("setting_control_border_highlight")
Image
{ {
OutputDevice.setActiveCamera(modelData.camera) width: parent.width
height: width
anchors.right: parent.right
anchors.rightMargin: parent.rightMargin
source: "camera-icon.svg"
}
MouseArea
{
anchors.fill:parent
onClicked:
{
OutputDevice.setActiveCamera(modelData.camera)
}
} }
} }
} }
} }
}
ProgressBar ProgressBar
{
property var progress:
{ {
if(modelData.activePrintJob == null) property var progress:
{
return 0
}
var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal
if(result > 1.0)
{
result = 1.0
}
return result
}
id: jobProgressBar
width: parent.width
value: progress
anchors.top: detailedInfo.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined
style: ProgressBarStyle
{
property var progressText:
{ {
if(modelData.activePrintJob == null) if(modelData.activePrintJob == null)
{ {
return "" return 0
} }
var result = modelData.activePrintJob.timeElapsed / modelData.activePrintJob.timeTotal
switch(modelData.activePrintJob.state) if(result > 1.0)
{ {
case "wait_cleanup": result = 1.0
return catalog.i18nc("@label:status", "Finshed")
case "pre_print":
case "sent_to_printer":
return catalog.i18nc("@label:status", "Preparing")
case "aborted":
case "wait_user_action":
return catalog.i18nc("@label:status", "Aborted")
case "pausing":
case "paused":
return catalog.i18nc("@label:status", "Paused")
case "resuming":
return catalog.i18nc("@label:status", "Resuming")
default:
OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed)
} }
return result
} }
background: Rectangle id: jobProgressBar
{ width: parent.width
implicitWidth: 100 value: progress
implicitHeight: visible ? 24 : 0 anchors.top: detailedInfo.bottom
color: UM.Theme.getColor("viewport_background") anchors.topMargin: UM.Theme.getSize("default_margin").height
}
progress: Rectangle visible: modelData.activePrintJob != null && modelData.activePrintJob != undefined
style: ProgressBarStyle
{ {
color: UM.Theme.getColor("primary") property var progressText:
id: progressItem
function getTextOffset()
{ {
if(progressItem.width + progressLabel.width < control.width) if(modelData.activePrintJob == null)
{ {
return progressItem.width + UM.Theme.getSize("default_margin").width return ""
} }
else
switch(modelData.activePrintJob.state)
{ {
return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width case "wait_cleanup":
return catalog.i18nc("@label:status", "Finshed")
case "pre_print":
case "sent_to_printer":
return catalog.i18nc("@label:status", "Preparing")
case "aborted":
case "wait_user_action":
return catalog.i18nc("@label:status", "Aborted")
case "pausing":
case "paused":
return catalog.i18nc("@label:status", "Paused")
case "resuming":
return catalog.i18nc("@label:status", "Resuming")
default:
OutputDevice.formatDuration(modelData.activePrintJob.timeTotal - modelData.activePrintJob.timeElapsed)
} }
} }
Label background: Rectangle
{ {
id: progressLabel implicitWidth: 100
anchors.left: parent.left implicitHeight: visible ? 24 : 0
anchors.leftMargin: getTextOffset() color: UM.Theme.getColor("viewport_background")
text: progressText }
anchors.verticalCenter: parent.verticalCenter
color: progressItem.width + progressLabel.width < control.width ? "black" : "white" progress: Rectangle
width: contentWidth {
color: UM.Theme.getColor("primary")
id: progressItem
function getTextOffset()
{
if(progressItem.width + progressLabel.width < control.width)
{
return progressItem.width + UM.Theme.getSize("default_margin").width
}
else
{
return progressItem.width - progressLabel.width - UM.Theme.getSize("default_margin").width
}
}
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
}
} }
} }
} }