diff --git a/declarativeimports/plasmacomponents/qml/TabButton.qml b/declarativeimports/plasmacomponents/qml/TabButton.qml index 6a424bbb8..5a3605501 100644 --- a/declarativeimports/plasmacomponents/qml/TabButton.qml +++ b/declarativeimports/plasmacomponents/qml/TabButton.qml @@ -100,6 +100,7 @@ Item { //TabBar is the granparent root.parent.parent.currentTab = root } + onVisibleChanged: root.parent.childrenChanged() } QtObject { diff --git a/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml b/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml index f22bfdc7d..4837280e0 100644 --- a/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml +++ b/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml @@ -106,16 +106,29 @@ Item { function layoutChildren() { var childCount = root.children.length + var visibleChildCount = childCount var contentWidth = 0 var contentHeight = 0 if (childCount != 0) { - var itemWidth = (root.width - (childCount-1)*10) / childCount + //not too much efficient but the loop over children needs to be done two times to get the proper child width + for (var i = 0; i < childCount; ++i) { + if (!root.children[i].visible) { + --visibleChildCount + } + } + var itemWidth = (root.width - (childCount-1)*10) / visibleChildCount var itemIndex = mirrored ? childCount - 1 : 0 var increment = mirrored ? - 1 : 1 + var visibleIndex = 0 for (var i = 0; i < childCount; ++i, itemIndex += increment) { var child = root.children[itemIndex] - child.x = i * itemWidth + i*10 + if (!child.visible) { + continue + } + + child.x = visibleIndex * itemWidth + visibleIndex*10 + ++visibleIndex child.y = 0 child.width = itemWidth child.height = root.height