42 import
"private/TabGroup.js" as Engine
72 property Item currentTab
74 property list<Item> privateContents
76 default property alias privateContentsDefault: root.privateContents
80 if (children.length > 1)
81 Engine.addTab(children[1])
84 onPrivateContentsChanged: {
85 Engine.ensureContainers()
88 Component.onCompleted: {
90 if (currentTab == null && containerHost.children[0] && containerHost.children[0].children[0])
91 currentTab = containerHost.children[0].children[0]
97 objectName:
"containerHost"
102 id: tabContainerComponent
107 if (children.length == 0)
108 Engine.removeContainer(tabContainerItem)
110 else if (children.length == 1) {
111 children[0].width = width
112 children[0].height = height
115 if (priv.complete && root.currentTab == null)
116 root.currentTab = children[0]
121 if (children.length > 0)
122 children[0].width = width
126 if (children.length > 0)
127 children[0].height = height
130 Component.onDestruction: {
131 if (typeof(root) !=
"undefined" && !root.currentTab) {
133 var removedIndex = -1
134 for (var i = 0; i < containerHost.children.length; i++) {
135 if (containerHost.children[i] == tabContainerItem) {
141 if (removedIndex != -1) {
142 if (removedIndex != containerHost.children.length - 1)
143 newIndex = removedIndex + 1
144 else if (removedIndex != 0)
145 newIndex = removedIndex - 1
149 root.currentTab = containerHost.children[newIndex].children[0]
151 root.currentTab = null
155 function incomingDone() {
157 if (priv.incomingPage) {
158 if (priv.incomingPage.status != undefined) {
161 priv.incomingPage = null
165 function outgoingDone() {
166 if (priv.outgoingPage) {
167 if (priv.outgoingPage.status != undefined) {
170 priv.outgoingPage.visible =
false
171 priv.outgoingPage = null
176 width: parent ? parent.width : 0
177 height: parent ? parent.height : 0
181 State { name:
""; PropertyChanges { target: tabContainerItem; opacity: 1.0; x: 0 } },
182 State { name:
"Incoming"; PropertyChanges { target: tabContainerItem; opacity: 1.0; x: 0 } },
187 target: tabContainerItem
193 name:
"OutgoingRight"
195 target: tabContainerItem
201 State { name:
"HiddenLeft"; PropertyChanges { target: tabContainerItem; opacity: 0.0; x: root.width } },
202 State { name:
"HiddenRight"; PropertyChanges { target: tabContainerItem; opacity: 0.0; x: -root.width } }
208 SequentialAnimation {
209 ScriptAction { script: root.clip =
true }
210 PropertyAnimation { properties:
"opacity,x"; easing.type: Easing.InQuad; duration: 250 }
211 ScriptAction { script: {incomingDone(); root.clip =
false} }
215 to:
"OutgoingLeft,OutgoingRight"
216 SequentialAnimation {
217 PropertyAnimation { properties:
"opacity,x"; easing.type: Easing.InQuad; duration: 250 }
218 ScriptAction { script: outgoingDone() }
227 property bool reparenting:
false
228 property bool complete:
false
229 property Item currentTabContainer: root.currentTab ? root.currentTab.parent : null
230 property int currentIndex: 0
231 property Item incomingPage
232 property Item outgoingPage
233 property bool animate:
true
235 onCurrentTabContainerChanged: {
236 var newCurrentIndex = 0
237 for (var i = 0; i < containerHost.children.length; i++) {
238 if (containerHost.children[i] == currentTabContainer) {
244 currentTabContainer.visible =
true
245 incomingPage = currentTabContainer.children[0]
246 incomingPage.visible =
true
247 if (incomingPage.status != undefined) {
250 if (currentIndex < newCurrentIndex) {
251 currentTabContainer.state =
"HiddenLeft"
253 currentTabContainer.state =
"HiddenRight"
256 currentTabContainer.state =
"Incoming"
258 currentTabContainer.incomingDone()
261 if (newCurrentIndex == currentIndex) {
265 var oldPage = containerHost.children[currentIndex]
266 outgoingPage = oldPage.children[0]
268 if (currentIndex < newCurrentIndex) {
269 oldPage.state =
"OutgoingLeft"
271 oldPage.state =
"OutgoingRight"
274 oldPage.outgoingDone()
276 currentIndex = newCurrentIndex