CURA-4870 Adapt the size of the sync dropdown to the height of the

contents or a maximum size defined manually.
Create sections in the list view depending on the machine types that are
in the group.
This commit is contained in:
Diego Prado Gesto 2018-03-07 11:24:02 +01:00
parent 813f4e83e0
commit bb3d706c92

View file

@ -16,61 +16,68 @@ Column
padding: UM.Theme.getSize("default_margin").width padding: UM.Theme.getSize("default_margin").width
spacing: Math.round(UM.Theme.getSize("default_margin").height / 2) spacing: Math.round(UM.Theme.getSize("default_margin").height / 2)
Label { Label
{
text: catalog.i18nc("@label:header configurations", "Available configurations") text: catalog.i18nc("@label:header configurations", "Available configurations")
font: UM.Theme.getFont("large") font: UM.Theme.getFont("large")
width: parent.width - 2 * parent.padding width: parent.width - 2 * parent.padding
} }
ScrollView { Component
{
id: sectionHeading
Rectangle
{
height: childrenRect.height + UM.Theme.getSize("default_margin").height
Label
{
text: section
font: UM.Theme.getFont("default_bold")
}
}
}
ScrollView
{
id: container id: container
width: parent.width - 2 * parent.padding width: parent.width - parent.padding
height: 500 //childrenRect.height height: Math.min(configurationList.contentHeight, 300 * screenScaleFactor)
style: UM.Theme.styles.scrollview style: UM.Theme.styles.scrollview
__wheelAreaScrollSpeed: 75 // Scroll three lines in one scroll event
Repeater { ListView
height: childrenRect.height {
model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : null id: configurationList
delegate: Rectangle spacing: Math.round(UM.Theme.getSize("default_margin").height / 2)
width: container.width
contentHeight: childrenRect.height
section.property: "modelData.printerType"
section.criteria: ViewSection.FullString
section.delegate: sectionHeading
model: outputDevice.uniqueConfigurations
delegate: ConfigurationItem
{ {
height: childrenRect.height width: parent.width - UM.Theme.getSize("default_margin").width
Label configuration: modelData
onActivateConfiguration:
{ {
id: printerTypeHeader Cura.MachineManager.applyRemoteConfiguration(configuration)
text: modelData.machine_type
font: UM.Theme.getFont("default_bold")
}
Connections {
target: outputDevice
onUniqueConfigurationsChanged: {
// FIXME For now the model should be removed and then created again, otherwise changes in the printer don't automatically update the UI
configurationList.model = null
configurationList.model = outputDevice.uniqueConfigurations
}
}
ListView
{
id: configurationList
anchors.top: printerTypeHeader.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
spacing: Math.round(UM.Theme.getSize("default_margin").height / 2)
width: container.width
height: childrenRect.height
model: outputDevice.uniqueConfigurations
delegate: ConfigurationItem
{
width: parent.width
configuration: modelData
onActivateConfiguration:
{
Cura.MachineManager.applyRemoteConfiguration(configuration)
}
}
} }
} }
} }
} }
Connections
{
target: outputDevice
onUniqueConfigurationsChanged:
{
// FIXME For now the model should be removed and then created again, otherwise changes in the printer don't automatically update the UI
configurationList.model = null
configurationList.model = outputDevice.uniqueConfigurations
}
}
} }