From 76b9204842025c7d84e64a3553e8edcd5239f2f7 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jensb.bache-wiig@nokia.com> Date: Tue, 20 Sep 2011 11:09:57 +0200 Subject: [PATCH] Remove TabBar from TabFrame definition I don't really see a good use case for making this optional. It is private in QTabWidget as well and makes the API somewhat cumbersome. You can still assign focus through the tabBar property. --- components/TabFrame.qml | 32 ++++++++++++++++---------------- examples/Browser.qml | 1 - examples/Gallery.qml | 3 +-- examples/TableViewGallery.qml | 3 +-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/components/TabFrame.qml b/components/TabFrame.qml index 841e9659e..47e1a40d8 100644 --- a/components/TabFrame.qml +++ b/components/TabFrame.qml @@ -5,23 +5,16 @@ Item { id: tabWidget width: 100 height: 100 - focus: true - property TabBar tabbar property int current: 0 property int count: stack.children.length property bool frame:true property bool tabsVisible: true property string position: "North" default property alias tabs : stack.children + property Item tabBar: tabbarItem onCurrentChanged: __setOpacities() Component.onCompleted: __setOpacities() - onTabbarChanged: { - tabbar.tabFrame = tabWidget - tabbar.anchors.top = tabWidget.top - tabbar.anchors.left = tabWidget.left - tabbar.anchors.right = tabWidget.right - } property int __baseOverlap : frameitem.pixelMetric("tabbaseoverlap")// add paintmargins; function __setOpacities() { @@ -48,9 +41,9 @@ Item { z: style == "oxygen" ? 1 : 0 elementType: "tabframe" info: position - value: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).x : 0 - minimum: tabbar && tabsVisible && tabbar.tab(current) ? tabbar.tab(current).width : 0 - maximum: tabbar && tabsVisible ? tabbar.tabWidth : width + value: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).x : 0 + minimum: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).width : 0 + maximum: tabbarItem && tabsVisible ? tabbarItem.tabWidth : width anchors.fill: parent property int frameWidth: pixelMetric("defaultframewidth") @@ -63,27 +56,34 @@ Item { anchors.bottomMargin: anchors.margins + (frameitem.style =="mac" ? 6 : 0) } - anchors.topMargin: tabbar && tabsVisible && position == "North" ? tabbar.height - __baseOverlap : 0 + anchors.topMargin: tabbarItem && tabsVisible && position == "North" ? tabbarItem.height - __baseOverlap : 0 states: [ State { name: "South" - when: position == "South" && tabbar!= undefined + when: position == "South" && tabbarItem!= undefined PropertyChanges { target: frameitem anchors.topMargin: 0 - anchors.bottomMargin: tabbar ? tabbar.height - __baseOverlap: 0 + anchors.bottomMargin: tabbarItem ? tabbarItem.height - __baseOverlap: 0 } PropertyChanges { - target: tabbar + target: tabbarItem anchors.topMargin: -__baseOverlap } AnchorChanges { - target: tabbar + target: tabbarItem anchors.top: frameitem.bottom anchors.bottom: undefined } } ] } + TabBar { + id: tabbarItem + tabFrame: tabWidget + anchors.top: tabWidget.top + anchors.left: tabWidget.left + anchors.right: tabWidget.right + } } diff --git a/examples/Browser.qml b/examples/Browser.qml index 4b2d79442..e4295003e 100644 --- a/examples/Browser.qml +++ b/examples/Browser.qml @@ -172,7 +172,6 @@ Rectangle { TabFrame { id:frame - tabbar: TabBar{parent:frame} anchors.top:toolbar.bottom anchors.bottom:parent.bottom anchors.right:parent.right diff --git a/examples/Gallery.qml b/examples/Gallery.qml index 4eee50e46..604729ab6 100644 --- a/examples/Gallery.qml +++ b/examples/Gallery.qml @@ -208,7 +208,6 @@ Rectangle { TabFrame { id:frame - tabbar: TabBar{parent: frame; KeyNavigation.tab:button1} position: tabPositionGroup.checkedButton == r2 ? "South" : "North" KeyNavigation.tab:button1 KeyNavigation.backtab: button2 @@ -241,7 +240,7 @@ Rectangle { width: 96 tooltip:"This is an interesting tool tip" KeyNavigation.tab: button2 - KeyNavigation.backtab: frame.tabbar + KeyNavigation.backtab: frame.tabBar } Button { id:button2 diff --git a/examples/TableViewGallery.qml b/examples/TableViewGallery.qml index 41a966c3c..21d92687f 100644 --- a/examples/TableViewGallery.qml +++ b/examples/TableViewGallery.qml @@ -6,7 +6,7 @@ Rectangle { width: 538 + frame.margins * 2 height: 360 + frame.margins * 2 - ToolBar{ + ToolBar { id: toolbar width: parent.width height: 40 @@ -75,7 +75,6 @@ Rectangle { id:frame focus:true enabled: toolbar.enabled - tabbar: TabBar{parent: frame} property int margins : styleitem.style == "mac" ? 16 : 0 height: parent.height - 34 -- GitLab