Use array for extruder configurations

Contributes to CL-1148
This commit is contained in:
Ian Paschal 2018-11-22 13:55:43 +01:00
parent da834d6a1f
commit 55554c62a9
2 changed files with 20 additions and 25 deletions

View file

@ -141,8 +141,11 @@ Item
id: printerConfiguration id: printerConfiguration
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
buildplate: "Glass" buildplate: "Glass"
config0: base.printJob.configuration.extruderConfigurations[0] configurations:
config1: base.printJob.configuration.extruderConfigurations[1] [
base.printJob.configuration.extruderConfigurations[0],
base.printJob.configuration.extruderConfigurations[1]
]
height: 72 * screenScaleFactor // TODO: Theme! height: 72 * screenScaleFactor // TODO: Theme!
} }
Label { Label {

View file

@ -18,11 +18,8 @@ Item
// Extracted buildplate configuration // Extracted buildplate configuration
property alias buildplate: buildplateConfig.buildplate property alias buildplate: buildplateConfig.buildplate
// Extracted extruder configuration for position 0 // Array of extracted extruder configurations
property var config0: null property var configurations: null
// Extracted extruder configuration for position 1
property var config1: null
// Default size, but should be stretched to fill parent // Default size, but should be stretched to fill parent
height: 72 * parent.height height: 72 * parent.height
@ -30,30 +27,25 @@ Item
Row Row
{ {
id: extruderConfigurationRow
spacing: 18 * screenScaleFactor // TODO: Theme! spacing: 18 * screenScaleFactor // TODO: Theme!
Repeater
{
id: extruderConfigurationRepeater
model: configurations
MonitorExtruderConfiguration MonitorExtruderConfiguration
{ {
color: config0 && config0.activeMaterial ? config0.activeMaterial.color : "#eeeeee" // TODO: Theme! color: modelData.activeMaterial ? modelData.activeMaterial.color : "#eeeeee" // TODO: Theme!
material: config0 && config0.activeMaterial ? config0.activeMaterial.name : "" material: modelData.activeMaterial ? modelData.activeMaterial.name : ""
position: config0.position position: modelData.position
printCore: config0 ? config0.hotendID : "" printCore: modelData.hotendID
visible: config0
// Keep things responsive! // Keep things responsive!
width: Math.floor((base.width - parent.spacing) / 2) width: Math.floor((base.width - (configurations.length - 1) * extruderConfigurationRow.spacing) / configurations.length)
} }
MonitorExtruderConfiguration
{
color: config1 && config1.activeMaterial ? config1.activeMaterial.color : "#eeeeee" // TODO: Theme!
material: config1 && config1.activeMaterial ? config1.activeMaterial.name : ""
position: config1.position
printCore: config1 ? config1.hotendID : ""
visible: config1
// Keep things responsive!
width: Math.floor((base.width - parent.spacing) / 2)
} }
} }