Fixed view selector header not updating correctly

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-21 09:35:35 +01:00
parent 0cdcd61ff2
commit d74393498b

View file

@ -54,22 +54,27 @@ Item
{ {
for (var i = 0; i < viewModel.rowCount(); i++) for (var i = 0; i < viewModel.rowCount(); i++)
{ {
if (viewModel.getItem(i).active) if (viewModel.items[i].active)
{ {
return viewModel.getItem(i) return viewModel.items[i]
} }
} }
// Nothing was active, so just return the first one (the list is sorted by priority, so the most return null
// important one should be returned)
return viewModel.getItem(0)
} }
// Ensure that the controller is synced with whatever happend here. Component.onCompleted:
onActiveViewChanged: UM.Controller.setActiveView(activeView.id) {
// Nothing was active, so just return the first one (the list is sorted by priority, so the most
// important one should be returned)
if(activeView == null)
{
UM.Controller.setActiveView(viewModel.getItem(0).id)
}
}
headerItem: Label headerItem: Label
{ {
text: viewSelector.activeView.name text: viewSelector.activeView ? viewSelector.activeView.name : ""
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
height: parent.height height: parent.height
elide: Text.ElideRight elide: Text.ElideRight
@ -98,7 +103,7 @@ Item
text: name text: name
radius: UM.Theme.getSize("default_radius").width radius: UM.Theme.getSize("default_radius").width
checkable: true checkable: true
checked: active checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false
onClicked: onClicked:
{ {
viewSelector.togglePopup() viewSelector.togglePopup()