Reset tab index when repeater's model is rebuilt

We can't prevent the model from being rebuilt. At least, not without a major refactor.

Contributes to issue CURA-5876.
This commit is contained in:
Ghostkeeper 2018-11-30 15:40:59 +01:00
parent e93bbf07a4
commit 1d9a13cac2
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -39,6 +39,7 @@ Item
Repeater
{
id: repeater
model: extrudersModel
delegate: UM.TabRowButton
{
@ -59,6 +60,18 @@ Item
}
}
}
//When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt.
//This causes the currentIndex of the tab to be in an invalid position which resets it to 0.
//Therefore we need to change it back to what it was: The active extruder index.
Connections
{
target: repeater.model
onModelChanged:
{
tabBar.currentIndex = Math.max(Cura.ExtruderManager.activeExtruderIndex, 0)
}
}
}
Rectangle