Fix updating monitored values

Though the PrintMonitorModel was a nicer solution, it broke the binding of values coming from the PrinterOutputDevices

CURA-1036
This commit is contained in:
fieldOfView 2016-06-24 14:35:31 +02:00
parent 00ad7b23ff
commit f6e31cd97a

View File

@ -278,8 +278,8 @@ Rectangle
} }
} }
// ListView that shows the print monitor properties // Item that shows the print monitor properties
ListView Column
{ {
id: printMonitor id: printMonitor
@ -291,40 +291,103 @@ Rectangle
anchors.right: base.right anchors.right: base.right
visible: monitoringPrint visible: monitoringPrint
model: printMonitorModel Loader
delegate: Row
{ {
Label sourceComponent: monitorSection
property string label: catalog.i18nc("@label", "Temperatures")
}
Repeater
{
model: machineExtruderCount.properties.value
delegate: Loader
{ {
text: label sourceComponent: monitorItem
color: UM.Theme.getColor("setting_control_text"); property string label: machineExtruderCount.properties.value > 1 ? catalog.i18nc("@label", "Hotend Temperature %1").arg(index + 1) : catalog.i18nc("@label", "Hotend Temperature")
font: UM.Theme.getFont("default"); property string value: printerConnected ? Math.round(Cura.MachineManager.printerOutputDevices[0].hotendTemperatures[index]) + "°C" : ""
width: base.width * .4
elide: Text.ElideRight;
}
Label
{
text: value
color: UM.Theme.getColor("setting_control_text");
font: UM.Theme.getFont("default");
} }
} }
section.property: "category" Repeater
section.criteria: ViewSection.FullString
section.delegate: Rectangle
{ {
color: UM.Theme.getColor("setting_category") model: machineHeatedBed.properties.value == "True" ? 1 : 0
width: parent.width - UM.Theme.getSize("default_margin").width delegate: Loader
height: UM.Theme.getSize("section").height
Label
{ {
anchors.verticalCenter: parent.verticalCenter sourceComponent: monitorItem
anchors.left: parent.left property string label: catalog.i18nc("@label", "Bed Temperature")
anchors.leftMargin: UM.Theme.getSize("default_margin").width property string value: printerConnected ? Math.round(Cura.MachineManager.printerOutputDevices[0].bedTemperature) + "°C" : ""
text: section }
font: UM.Theme.getFont("setting_category") }
color: UM.Theme.getColor("setting_category_text")
Loader
{
sourceComponent: monitorSection
property string label: catalog.i18nc("@label", "Active print")
}
Loader
{
sourceComponent: monitorItem
property string label: catalog.i18nc("@label", "Job Name")
property string value: printerConnected ? Cura.MachineManager.printerOutputDevices[0].jobName : ""
}
Loader
{
sourceComponent: monitorItem
property string label: catalog.i18nc("@label", "Printing Time")
property string value: printerConnected ? getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal) : ""
}
Loader
{
sourceComponent: monitorItem
property string label: catalog.i18nc("@label", "Estimated time left")
property string value: printerConnected ? getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal - Cura.MachineManager.printerOutputDevices[0].timeElapsed) : ""
}
Loader
{
sourceComponent: monitorItem
property string label: catalog.i18nc("@label", "Current Layer")
property string value: printerConnected ? "0" : ""
}
Component
{
id: monitorItem
Row
{
Label
{
text: label
color: UM.Theme.getColor("setting_control_text");
font: UM.Theme.getFont("default");
width: base.width * 0.4
elide: Text.ElideRight;
}
Label
{
text: value
color: UM.Theme.getColor("setting_control_text");
font: UM.Theme.getFont("default");
}
}
}
Component
{
id: monitorSection
Rectangle
{
color: UM.Theme.getColor("setting_category")
width: base.width - 2 * UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("section").height
Label
{
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width
text: label
font: UM.Theme.getFont("setting_category")
color: UM.Theme.getColor("setting_category_text")
}
} }
} }
} }
@ -354,7 +417,7 @@ Rectangle
implicitWidth: base.width implicitWidth: base.width
implicitHeight: totalHeight implicitHeight: totalHeight
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: monitoringPrint && printerConnected visible: monitoringPrint
} }
@ -403,57 +466,13 @@ Rectangle
storeIndex: 0 storeIndex: 0
} }
ListModel { UM.SettingPropertyProvider
id: printMonitorModel
Component.onCompleted: populatePrintMonitorModel()
}
Connections
{ {
target: Cura.MachineManager id: machineHeatedBed
onGlobalContainerChanged: populatePrintMonitorModel()
}
function populatePrintMonitorModel() containerStackId: Cura.MachineManager.activeMachineId
{ key: "machine_heated_bed"
printMonitorModel.clear(); watchedProperties: [ "value" ]
storeIndex: 0
if (!printerConnected)
return
var extruderCount = machineExtruderCount.properties.value
for(var extruderNumber = 0; extruderNumber < extruderCount ; extruderNumber++) {
printMonitorModel.append({
label: extruderCount > 1 ? catalog.i18nc("@label", "Hotend Temperature %1").arg(extruderNumber + 1) : catalog.i18nc("@label", "Hotend Temperature"),
value: Math.round(Cura.MachineManager.printerOutputDevices[0].hotendTemperatures[extruderNumber]) + "°C",
category: catalog.i18nc("@label", "Temperatures")
})
}
printMonitorModel.append({
label: catalog.i18nc("@label", "Bed Temperature"),
value: Math.round(Cura.MachineManager.printerOutputDevices[0].bedTemperature) + "°C",
category: catalog.i18nc("@label", "Temperatures")
})
printMonitorModel.append({
label: catalog.i18nc("@label", "Job name"),
value: Cura.MachineManager.printerOutputDevices[0].jobName,
category: catalog.i18nc("@label", "Active print")
})
printMonitorModel.append({
label: catalog.i18nc("@label", "Printing Time"),
value: getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal),
category: catalog.i18nc("@label", "Active print")
})
printMonitorModel.append({
label: catalog.i18nc("@label", "Estimated time left"),
value: getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal - Cura.MachineManager.printerOutputDevices[0].timeElapsed),
category: catalog.i18nc("@label", "Active print")
})
printMonitorModel.append({
label: catalog.i18nc("@label", "Current Layer"),
value: 0,
category: catalog.i18nc("@label", "Active print")
})
} }
} }