2 * Copyright 2014 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 objectName: "sessionContainer"
23 property QtObject session
24 readonly property var childSessions: session ? session.childSessions : null
25 readonly property alias surface: _surfaceContainer.surface
26 property alias interactive: _surfaceContainer.interactive
27 property int orientation
29 readonly property alias surfaceContainer: _surfaceContainer
33 surface: session ? session.surface : null
34 orientation: root.orientation
38 id: childSessionsRepeater
39 model: root.childSessions
42 objectName: "childDelegate" + index
43 anchors.fill: surfaceContainer
45 // Only way to do recursive qml items.
46 source: Qt.resolvedUrl("SessionContainer.qml")
50 // Since a Loader is a FocusScope, propagate its focus to the loaded Item
52 target: item; when: item
53 property: "focus"; value: focus
57 target: item; when: item
58 property: "interactive"; value: index == (childSessionsRepeater.count - 1) && root.interactive
62 target: item; when: item
63 property: "session"; value: modelData
67 target: item; when: item
68 property: "width"; value: root.width
72 target: item; when: item
73 property: "height"; value: root.height
77 target: item; when: item
78 property: "orientation"; value: root.orientation
86 when: root.session && !root.session.parentSession
91 when: root.session && root.session.parentSession !== null && root.session.live
92 && !root.session.surface
96 name: "childSessionReady"
97 when: root.session && root.session.parentSession !== null && root.session.live
98 && root.session.surface !== null
102 name: "childSessionZombie"
103 when: root.session && root.session.parentSession !== null && !root.session.live
109 to: "childSessionReady"
110 ScriptAction { script: { if (!surfaceContainer.hadSurface) { animateIn(swipeFromBottom); } } }
113 to: "childSessionZombie"
114 ScriptAction { script: { animateOut(); } }
118 function animateIn(component) {
119 var animation = component.createObject(root, { "container": root, });
122 var tmp = d.animations;
127 function animateOut() {
128 if (d.animations.length > 0) {
129 var tmp = d.animations;
130 var popped = tmp.pop();
131 popped.completed.connect(function() { root.session.release(); } );
139 SwipeFromBottomAnimation {}
144 property var animations: []
146 property var focusedChild: {
147 if (childSessionsRepeater.count == 0) {
148 return _surfaceContainer;
150 return childSessionsRepeater.itemAt(childSessionsRepeater.count - 1);
153 onFocusedChildChanged: {
154 focusedChild.focus = true;