diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index 73850ce5aeec44a654ca98e926f0e4ee1d98dab4..b5e98f8043df67fb505a80e4b70a94864e3b34d2 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -240,7 +240,6 @@ Item { property Component tabViewStyle: TabViewStyle { tabOverlap: 16 - tabsLeftPadding: 12 frameOverlap: 4 tabsMovable: true @@ -269,6 +268,7 @@ Item { anchors.centerIn: parent } } + leftCorner: Item { implicitWidth: 12 } } } diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 826a38116c99cccc2507ea257792866d74e531e8..e0a555fdc7a5b343a8b870133af04df39b0592b4 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -48,8 +48,8 @@ import QtQuick.Controls 1.0 */ FocusScope { id: tabbar - height: tabrow.height - width: tabrow.width + height: Math.max(tabrow.height, Math.max(leftCorner.height, rightCorner.height)) + width: tabView.width activeFocusOnTab: true @@ -77,6 +77,8 @@ FocusScope { property int elide: Text.ElideRight + property real availableWidth: tabbar.width - leftCorner.width - rightCorner.width + function tab(index) { for (var i = 0; i < tabrow.children.length; ++i) { if (tabrow.children[i].tabindex == index) { @@ -109,7 +111,7 @@ FocusScope { interactive: false focus: true - width: contentItem ? contentItem.width : 0 + width: Math.min(availableWidth, count ? contentWidth : availableWidth) height: currentItem ? currentItem.height : 0 displaced: Transition { @@ -125,7 +127,7 @@ FocusScope { name: "left" when: tabsAlignment === Qt.AlignLeft AnchorChanges { target:tabrow ; anchors.left: parent.left } - PropertyChanges { target:tabrow ; anchors.leftMargin: styleItem ? styleItem.tabsLeftPadding : 0 } + PropertyChanges { target:tabrow ; anchors.leftMargin: leftCorner.width } }, State { name: "center" @@ -136,7 +138,7 @@ FocusScope { name: "right" when: tabsAlignment === Qt.AlignRight AnchorChanges { target:tabrow ; anchors.right: parent.right } - PropertyChanges { target:tabrow ; anchors.rightMargin: styleItem ? styleItem.tabsRightPadding : 0 } + PropertyChanges { target:tabrow ; anchors.rightMargin: rightCorner.width } } ] @@ -161,7 +163,7 @@ FocusScope { property bool previousSelected: tabView.currentIndex === index - 1 z: selected ? 1 : -index - implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/tabrow.count) + 1 + implicitWidth: Math.min(tabloader.implicitWidth, availableWidth/tabrow.count) + 1 implicitHeight: tabloader.implicitHeight onPressed: { @@ -238,6 +240,24 @@ FocusScope { } } + Loader { + id: leftCorner + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + sourceComponent: styleItem ? styleItem.leftCorner : undefined + width: item ? item.implicitWidth : 0 + height: item ? item.implicitHeight : 0 + } + + Loader { + id: rightCorner + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + sourceComponent: styleItem ? styleItem.rightCorner : undefined + width: item ? item.implicitWidth : 0 + height: item ? item.implicitHeight : 0 + } + DropArea { anchors.fill: tabrow keys: "application/x-tabbartab" diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index 49783dadccf3c9df5b5d37fd700ea17b6b25874f..090a7d038dba4d62fbd7fa21c3043283aa77a6f4 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -97,12 +97,6 @@ Style { */ property int tabsAlignment: Qt.AlignLeft - /*! This property holds the left padding of the tab bar. */ - property int tabsLeftPadding: 0 - - /*! This property holds the right padding of the tab bar. */ - property int tabsRightPadding: 0 - /*! This property holds the amount of overlap there are between individual tab buttons. */ property int tabOverlap: 1 @@ -179,4 +173,10 @@ Style { color: __syspal.text } } + + /*! This defines the left corner. */ + property Component leftCorner: null + + /*! This defines the right corner. */ + property Component rightCorner: null } diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index bc71e49490e1f0b02a43de6241ff438b3f67d76f..ccf7e2b9d5303e24c22f9c27cc21dcdbaffd136b 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -45,8 +45,6 @@ Style { id: root property bool tabsMovable: false - property int tabsLeftPadding: 0 - property int tabsRightPadding: 0 property int tabsAlignment: __barstyle.styleHint("tabbaralignment") === "center" ? Qt.AlignHCenter : Qt.AlignLeft; property int tabOverlap: __barstyle.pixelMetric("taboverlap"); property int frameOverlap: __barstyle.pixelMetric("tabbaseoverlap"); @@ -98,4 +96,7 @@ Style { hasFocus: tabbarItem.activeFocus && selected } } + + property Component leftCorner: null + property Component rightCorner: null }