From 11b87e9bf2025dd029a4f745e7156b959b0ad21d Mon Sep 17 00:00:00 2001 From: J-P Nurmi <jpnurmi@digia.com> Date: Mon, 11 Mar 2013 20:19:42 +0100 Subject: [PATCH] Make TabView::tabPosition use the Qt::Edge enum Change-Id: I8b6af1c4c59cfcad513108e42c0e206320ee2b66 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> --- examples/gallery/content/Controls.qml | 6 +++--- examples/gallery/main.qml | 2 +- src/controls/TabView.qml | 14 +++++++------- src/styles/Desktop/TabViewStyle.qml | 5 +++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/gallery/content/Controls.qml b/examples/gallery/content/Controls.qml index ff4c370a9..2c6b87403 100644 --- a/examples/gallery/content/Controls.qml +++ b/examples/gallery/content/Controls.qml @@ -51,7 +51,7 @@ Item { anchors.fill: parent enabled: enabledCheck.checked - property string tabPosition: tabPositionGroup.current === r2 ? "Bottom" : "Top" + property int tabPosition: tabPositionGroup.current === r2 ? Qt.BottomEdge : Qt.TopEdge Row { id: contentRow @@ -163,7 +163,7 @@ Item { Row { RadioButton { id: r1 - text: "North" + text: "Top" KeyNavigation.tab: r2 checked: true exclusiveGroup: tabPositionGroup @@ -171,7 +171,7 @@ Item { } RadioButton { id: r2 - text: "South" + text: "Bottom" KeyNavigation.tab: area exclusiveGroup: tabPositionGroup } diff --git a/examples/gallery/main.qml b/examples/gallery/main.qml index 911cbe1d8..113772049 100644 --- a/examples/gallery/main.qml +++ b/examples/gallery/main.qml @@ -266,7 +266,7 @@ ApplicationWindow { TabView { id:frame enabled: enabledCheck.checked - tabPosition: controlPage.item ? controlPage.item.tabPosition : "Top" + tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge anchors.top: toolbar.bottom anchors.bottom: parent.bottom anchors.right: parent.right diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index c8e4b7a64..b269c7c77 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -69,14 +69,14 @@ FocusScope { property bool tabsVisible: true /*! - \qmlproperty string TabView::tabPosition + \qmlproperty enumeration TabView::tabPosition \list - \li "Top" (default) - \li "Bottom" + \li Qt.TopEdge (default) + \li Qt.BottomEdge \endlist */ - property string tabPosition: "Top" + property int tabPosition: Qt.TopEdge /*! \internal */ default property alias data: stack.data @@ -169,8 +169,8 @@ FocusScope { z: tabbarItem.z - 1 anchors.fill: parent - anchors.topMargin: tabbarItem && tabsVisible && tabPosition == "Top" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 - anchors.bottomMargin: tabbarItem && tabsVisible && tabPosition == "Bottom" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 + anchors.topMargin: tabbarItem && tabsVisible && tabPosition == Qt.TopEdge ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 + anchors.bottomMargin: tabbarItem && tabsVisible && tabPosition == Qt.BottomEdge ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0 sourceComponent: frameVisible && loader.item ? loader.item.frame : null property var control: root @@ -201,7 +201,7 @@ FocusScope { states: [ State { name: "Bottom" - when: tabPosition == "Bottom" && tabbarItem != undefined + when: tabPosition == Qt.BottomEdge && tabbarItem != undefined PropertyChanges { target: tabbarItem anchors.topMargin: tabbarItem.height diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index 1ec473d81..d2ba2280f 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -51,6 +51,7 @@ Style { property string tabBarAlignment: __barstyle.styleHint("tabbaralignment"); property int tabOverlap: __barstyle.pixelMetric("taboverlap"); property int tabBaseOverlap: __barstyle.pixelMetric("tabbaseoverlap"); + property string tabPosition: control.tabPosition == Qt.TopEdge ? "Top" : "Bottom" property Component frame: StyleItem { id: styleitem @@ -58,7 +59,7 @@ Style { anchors.topMargin: 1//stack.baseOverlap z: style == "oxygen" ? 1 : 0 elementType: "tabframe" - hints: control.tabPosition + hints: tabPosition value: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).x : 0 minimum: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).width : 0 maximum: tabbarItem && tabsVisible ? tabbarItem.width : width @@ -85,7 +86,7 @@ Style { anchors.fill: parent anchors.leftMargin: (selected && style == "mac") ? -1 : 0 - hints: [control.tabsPosition, tabpos, selectedpos] + hints: [tabPosition, tabpos, selectedpos] selected: tab.selected text: title -- GitLab