48 import
"private/PageStack.js" as Engine
61 width: parent ? parent.width : 0
62 height: parent ? parent.height : 0
65 property int depth: Engine.getDepth()
68 property Item currentPage: null
85 property variant initialPage
88 property bool busy:
internal.ongoingTransitionCount > 0
117 function push(page, properties, immediate)
119 return Engine.push(page, properties,
false, immediate);
131 function pop(page, immediate)
133 return Engine.pop(page, immediate);
151 function replace(page, properties, immediate)
153 return Engine.push(page, properties,
true, immediate);
159 return Engine.clear();
173 return Engine.find(func);
176 implicitWidth: currentPage ? currentPage.implicitWidth : 0
177 implicitHeight: currentPage ? currentPage.implicitHeight : 0
184 currentPage.visible = currentPage.parent.visible =
true;
188 onInitialPageChanged: {
189 if (!
internal.completed) {
195 push(initialPage, null,
true)
196 }
else if (depth == 1) {
197 replace(initialPage, null,
true)
199 console.log(
"Cannot update PageStack.initialPage")
204 Component.onCompleted: {
205 internal.completed =
true
206 if (initialPage && depth == 0)
207 push(initialPage, null,
true)
214 property int ongoingTransitionCount: 0
217 property bool completed:
false
220 function setPageStatus(page, status)
223 if (page.status !== undefined) {
229 page.status = status;
237 id: containerComponent
242 width: parent ? parent.width : 0
243 height: parent ? parent.height : 0
247 property Item pageParent: container
253 property Item page: null
256 property Item owner: null
259 property int stackWidth: Math.max(root.width, root.height)
262 property int transitionDuration: 250
265 property bool cleanupAfterTransition:
false
268 property bool transitionAnimationRunning:
false
271 property string pendingState:
"none"
276 Component.onDestruction: {
277 if (transitionAnimationRunning)
282 onTransitionAnimationRunningChanged: {
283 if (!transitionAnimationRunning && pendingState !=
"none") {
284 state = pendingState;
285 pendingState =
"none";
290 function setState(newState)
292 if (transitionAnimationRunning)
293 pendingState = newState;
299 function pushEnter(immediate, orientationChanges)
302 if (orientationChanges)
303 setState(
"LandscapeRight");
309 if (root.visible && immediate)
314 function pushExit(replace, immediate, orientationChanges)
316 if (orientationChanges)
317 setState(immediate ?
"Hidden" :
"LandscapeLeft");
319 setState(immediate ?
"Hidden" :
"Left");
320 if (root.visible && immediate)
326 cleanupAfterTransition =
true;
331 function popEnter(immediate, orientationChanges)
334 state = orientationChanges ?
"LandscapeLeft" :
"Left";
337 if (root.visible && immediate)
342 function popExit(immediate, orientationChanges)
344 if (orientationChanges)
345 setState(immediate ?
"Hidden" :
"LandscapeRight");
347 setState(immediate ?
"Hidden" :
"Right");
349 if (root.visible && immediate)
354 cleanupAfterTransition =
true;
358 function transitionStarted()
360 transitionAnimationRunning =
true;
361 internal.ongoingTransitionCount++;
368 function transitionEnded()
375 internal.ongoingTransitionCount--;
376 transitionAnimationRunning =
false;
377 if (cleanupAfterTransition)
385 PropertyChanges { target: container; visible:
true; opacity: 1 }
390 PropertyChanges { target: container; x: -width / 2; opacity: 0 }
395 name:
"LandscapeLeft"
396 PropertyChanges { target: container; x: -stackWidth / 2; opacity: 0 }
401 PropertyChanges { target: container; x: width / 2; opacity: 0 }
406 name:
"LandscapeRight"
407 PropertyChanges { target: container; x: stackWidth / 2; opacity: 0 }
412 PropertyChanges { target: container; visible:
false }
420 SequentialAnimation {
421 ScriptAction { script: transitionStarted() }
423 PropertyAnimation { properties:
"x"; easing.type: Easing.InQuad; duration: transitionDuration }
424 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
426 ScriptAction { script: transitionEnded() }
432 SequentialAnimation {
433 ScriptAction { script: transitionStarted() }
435 PropertyAnimation { properties:
"x"; easing.type: Easing.OutQuad; duration: transitionDuration }
436 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
438 ScriptAction { script: transitionEnded() }
443 from:
""; to:
"LandscapeLeft"
444 SequentialAnimation {
445 ScriptAction { script: transitionStarted() }
447 PropertyAnimation { properties:
"x"; easing.type: Easing.InQuad; duration: transitionDuration }
448 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
450 ScriptAction { script: transitionEnded() }
455 from:
"LandscapeLeft"; to:
""
456 SequentialAnimation {
457 ScriptAction { script: transitionStarted() }
459 PropertyAnimation { properties:
"x"; easing.type: Easing.OutQuad; duration: transitionDuration }
460 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
462 ScriptAction { script: transitionEnded() }
467 from:
""; to:
"Right"
468 SequentialAnimation {
469 ScriptAction { script: transitionStarted() }
471 PropertyAnimation { properties:
"x"; easing.type: Easing.InQuad; duration: transitionDuration }
472 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
477 ScriptAction { script: transitionEnded() }
482 from:
"Right"; to:
""
483 SequentialAnimation {
484 ScriptAction { script: transitionStarted() }
486 PropertyAnimation { properties:
"x"; easing.type: Easing.OutQuad; duration: transitionDuration }
487 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
489 ScriptAction { script: transitionEnded() }
494 from:
""; to:
"LandscapeRight"
495 SequentialAnimation {
496 ScriptAction { script: transitionStarted() }
498 PropertyAnimation { properties:
"x"; easing.type: Easing.InQuad; duration: transitionDuration }
499 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
504 ScriptAction { script: transitionEnded() }
509 from:
"LandscapeRight"; to:
""
510 SequentialAnimation {
511 ScriptAction { script: transitionStarted() }
513 PropertyAnimation { properties:
"x"; easing.type: Easing.OutQuad; duration: transitionDuration }
514 PropertyAnimation { properties:
"opacity"; easing.type: Easing.Linear; duration: transitionDuration }
516 ScriptAction { script: transitionEnded() }