ensure a tab is selected

This commit is contained in:
Marco Martin 2012-09-13 13:19:29 +02:00
parent 322bf6ab6c
commit faccd995e2
2 changed files with 11 additions and 5 deletions

View File

@ -90,6 +90,7 @@ FocusScope {
PlasmaCore.FrameSvgItem {
id: buttonFrame
visible: currentTab !== null
x: currentTab.x + backgroundFrame.margins.left
y: backgroundFrame.margins.top
width: currentTab.width + buttonFrame.margins.left + buttonFrame.margins.right
@ -113,10 +114,5 @@ FocusScope {
rightMargin: backgroundFrame.margins.right + buttonFrame.margins.right
bottomMargin: backgroundFrame.margins.bottom + buttonFrame.margins.bottom
}
Component.onCompleted: {
if (!root.currentTab) {
root.currentTab = tabBarLayout.children[0]
}
}
}
}

View File

@ -146,6 +146,16 @@ Item {
}
root.implicitWidth = contentWidth
root.implicitHeight = contentHeight
if (root.parent.currentTab === null) {
//99% of the cases this loop will be length 1 but a tabbar can also have other children, such as Repeater
for (var i = 0; i < tabBarLayout.children.length; ++i) {
//anything with a checked property may act as tabbutton
if (tabBarLayout.children[i].checked !== undefined) {
root.parent.currentTab = tabBarLayout.children[i]
break;
}
}
}
}
}
}