base on tabbar minimum width to show scrollbuttons

be more deterministic and now usually kickoff never shows the
scroll buttons

BUG:335392
This commit is contained in:
Marco Martin 2014-06-24 16:35:50 +02:00
parent 41722f7fb5
commit 655e7fcc0d
2 changed files with 7 additions and 5 deletions

View File

@ -82,7 +82,6 @@ FocusScope {
implicitWidth: layout.implicitWidth implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight implicitHeight: layout.implicitHeight
Item { Item {
id: buttonCutter id: buttonCutter
anchors { anchors {
@ -267,15 +266,13 @@ FocusScope {
rows: 1 rows: 1
columns: 1 columns: 1
flow: layout.isHorizontal ? GridLayout.TopToBottom : GridLayout.LeftToRight flow: layout.isHorizontal ? GridLayout.TopToBottom : GridLayout.LeftToRight
visible: layout.isHorizontal ? tabBarLayout.width > root.width : tabBarLayout.height > root.height visible: layout.isHorizontal ? tabBarLayout.minimumWidth >= root.width : tabBarLayout.height >= root.minimumHeight
anchors { anchors {
right: layout.isHorizontal ? parent.right : undefined right: layout.isHorizontal ? parent.right : undefined
verticalCenter: layout.isHorizontal ? parent.verticalCenter : undefined verticalCenter: layout.isHorizontal ? parent.verticalCenter : undefined
bottom: !layout.isHorizontal ? parent.bottom : undefined bottom: !layout.isHorizontal ? parent.bottom : undefined
horizontalCenter: !layout.isHorizontal ? parent.horizontalCenter : undefined horizontalCenter: !layout.isHorizontal ? parent.horizontalCenter : undefined
rightMargin: y
bottomMargin: y
} }
ToolButton { ToolButton {
height: Math.min(parent.height, parent.width) height: Math.min(parent.height, parent.width)

View File

@ -65,6 +65,9 @@ Item {
property bool isHorizontal: (tabPosition != Qt.LeftEdge && tabPosition != Qt.RightEdge) property bool isHorizontal: (tabPosition != Qt.LeftEdge && tabPosition != Qt.RightEdge)
property int minimumWidth: 0
property int minimumHeight: 0
Component.onCompleted: layoutTimer.restart() Component.onCompleted: layoutTimer.restart()
onChildrenChanged: layoutTimer.restart() onChildrenChanged: layoutTimer.restart()
onWidthChanged: layoutTimer.restart() onWidthChanged: layoutTimer.restart()
@ -164,7 +167,7 @@ Item {
if (tabGroup) { if (tabGroup) {
tabGroup.currentTab = root.children[index].tab tabGroup.currentTab = root.children[index].tab
} }
priv.tabBar.currentTab = root.children[index] priv.tabBar.currentTab = root.children[index]
} }
@ -231,6 +234,8 @@ Item {
} }
root.implicitWidth = contentWidth root.implicitWidth = contentWidth
root.implicitHeight = contentHeight root.implicitHeight = contentHeight
root.minimumWidth = itemWidth * visibleChildCount
root.minimumHeight = itemHeight * visibleChildCount
if ( priv.tabBar.currentTab === null) { if ( priv.tabBar.currentTab === null) {
//99% of the cases this loop will be length 1 but a tabbar can also have other children, such as Repeater //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) { for (var i = 0; i < tabBarLayout.children.length; ++i) {