2 * Copyright 2014-2015 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 implicitWidth: _surfaceContainer.implicitWidth
24 implicitHeight: _surfaceContainer.implicitHeight
25 property QtObject session
26 readonly property var childSessions: session ? session.childSessions : null
27 readonly property alias surface: _surfaceContainer.surface
28 property alias interactive: _surfaceContainer.interactive
29 property alias surfaceOrientationAngle: _surfaceContainer.surfaceOrientationAngle
30 property alias resizeSurface: _surfaceContainer.resizeSurface
32 property int requestedWidth: -1
33 property int requestedHeight: -1
35 readonly property alias surfaceContainer: _surfaceContainer
38 requestedWidth: root.requestedWidth
39 requestedHeight: root.requestedHeight
40 surface: session ? session.lastSurface : null
43 // SurfaceContainer size drives SessionContainer size
45 target: root; property: "width"; value: _surfaceContainer.width
46 when: root.requestedWidth >= 0
49 target: root; property: "height"; value: _surfaceContainer.height
50 when: root.requestedHeight >= 0
53 // SessionContainer size drives SurfaceContainer size
55 target: _surfaceContainer; property: "width"; value: root.width
56 when: root.requestedWidth < 0
59 target: _surfaceContainer; property: "height"; value: root.height
60 when: root.requestedHeight < 0
64 id: childSessionsRepeater
65 model: root.childSessions
68 objectName: "childDelegate" + index
69 anchors.fill: surfaceContainer
71 // Only way to do recursive qml items.
72 source: Qt.resolvedUrl("SessionContainer.qml")
76 // Since a Loader is a FocusScope, propagate its focus to the loaded Item
78 target: item; when: item
79 property: "focus"; value: focus
83 target: item; when: item
84 property: "interactive"; value: index == (childSessionsRepeater.count - 1) && root.interactive
88 target: item; when: item
89 property: "session"; value: modelData
93 target: item; when: item
94 property: "width"; value: root.width
98 target: item; when: item
99 property: "height"; value: root.height
107 when: root.session && !root.session.parentSession
112 when: root.session && root.session.parentSession !== null && root.session.live
113 && !root.session.lastSurface
117 name: "childSessionReady"
118 when: root.session && root.session.parentSession !== null && root.session.live
119 && root.session.lastSurface !== null
123 name: "childSessionZombie"
124 when: root.session && root.session.parentSession !== null && !root.session.live
130 to: "childSessionReady"
131 ScriptAction { script: { if (!surfaceContainer.hadSurface) { animateIn(swipeFromBottom); } } }
134 to: "childSessionZombie"
135 ScriptAction { script: { animateOut(); } }
139 function animateIn(component) {
140 var animation = component.createObject(root, { "container": root, });
143 var tmp = d.animations;
148 function animateOut() {
149 if (d.animations.length > 0) {
150 var tmp = d.animations;
151 var popped = tmp.pop();
152 popped.completed.connect(function() { root.session.release(); } );
156 root.session.release();
162 SwipeFromBottomAnimation {}
167 property var animations: []
169 property var focusedChild: {
170 if (childSessionsRepeater.count == 0) {
171 return _surfaceContainer;
173 return childSessionsRepeater.itemAt(childSessionsRepeater.count - 1);
176 onFocusedChildChanged: {
177 focusedChild.focus = true;