2 * Copyright 2014-2016 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/>.
18import Ubuntu.Components 1.3
19import Unity.Application 0.1
23 implicitWidth: requestedWidth
24 implicitHeight: requestedHeight
26 // to be read from outside
27 property alias interactive: surfaceContainer.interactive
28 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
29 readonly property string title: surface && surface.name !== "" ? surface.name : d.name
30 readonly property QtObject focusedSurface: d.focusedSurface.surface
32 // to be set from outside
33 property QtObject surface
34 property QtObject application
35 property int surfaceOrientationAngle
36 property alias resizeSurface: surfaceContainer.resizeSurface
37 property int requestedWidth: -1
38 property int requestedHeight: -1
39 property real splashRotation: 0
41 readonly property int minimumWidth: surface ? surface.minimumWidth : 0
42 readonly property int minimumHeight: surface ? surface.minimumHeight : 0
43 readonly property int maximumWidth: surface ? surface.maximumWidth : 0
44 readonly property int maximumHeight: surface ? surface.maximumHeight : 0
45 readonly property int widthIncrement: surface ? surface.widthIncrement : 0
46 readonly property int heightIncrement: surface ? surface.heightIncrement : 0
49 // The order in which the instructions are executed here matters, to that the correct state
50 // transitions in stateGroup take place.
51 // More specifically, the moment surfaceContainer.surface gets updated relative to the
52 // other instructions.
54 surfaceContainer.surface = surface;
55 d.liveSurface = surface.live;
57 surfaceInitTimer.start();
59 if (d.surfaceInitialized) {
62 d.surfaceInitialized = false;
63 surfaceContainer.surface = null;
70 property bool liveSurface: false;
71 property var con: Connections {
73 onLiveChanged: d.liveSurface = root.surface.live
75 // using liveSurface instead of root.surface.live because with the latter
76 // this expression is not reevaluated when root.surface changes
77 readonly property bool needToTakeScreenshot: root.surface && d.surfaceInitialized && !d.liveSurface
78 && applicationState !== ApplicationInfoInterface.Running
79 onNeedToTakeScreenshotChanged: {
80 if (needToTakeScreenshot && screenshotImage.status === Image.Null) {
81 screenshotImage.take();
85 // helpers so that we don't have to check for the existence of an application everywhere
86 // (in order to avoid breaking qml binding due to a javascript exception)
87 readonly property string name: root.application ? root.application.name : ""
88 readonly property url icon: root.application ? root.application.icon : ""
89 readonly property int applicationState: root.application ? root.application.state : -1
90 readonly property string splashTitle: root.application ? root.application.splashTitle : ""
91 readonly property url splashImage: root.application ? root.application.splashImage : ""
92 readonly property bool splashShowHeader: root.application ? root.application.splashShowHeader : true
93 readonly property color splashColor: root.application ? root.application.splashColor : "#00000000"
94 readonly property color splashColorHeader: root.application ? root.application.splashColorHeader : "#00000000"
95 readonly property color splashColorFooter: root.application ? root.application.splashColorFooter : "#00000000"
97 // Whether the Application had a surface before but lost it.
98 property bool hadSurface: false
100 //FIXME - this is a hack to avoid the first few rendered frames as they
101 // might show the UI accommodating due to surface resizes on startup.
102 // Remove this when possible
103 property bool surfaceInitialized: false
105 readonly property bool supportsSurfaceResize:
107 ((application.supportedOrientations & Qt.PortraitOrientation)
108 || (application.supportedOrientations & Qt.InvertedPortraitOrientation))
110 ((application.supportedOrientations & Qt.LandscapeOrientation)
111 || (application.supportedOrientations & Qt.InvertedLandscapeOrientation))
113 property bool surfaceOldEnoughToBeResized: false
115 property Item focusedSurface: promptSurfacesRepeater.count === 0 ? surfaceContainer
116 : promptSurfacesRepeater.first
117 onFocusedSurfaceChanged: {
118 if (focusedSurface) {
119 focusedSurface.focus = true;
125 target: root.application
126 property: "initialSurfaceSize"
127 value: Qt.size(root.requestedWidth, root.requestedHeight)
134 if (root.surface && root.surface.live) {d.surfaceInitialized = true;}
139 id: surfaceIsOldTimer
141 onTriggered: { if (stateGroup.state === "surface") { d.surfaceOldEnoughToBeResized = true; } }
146 objectName: "screenshotImage"
148 antialiasing: !root.interactive
152 // Save memory by using a half-resolution (thus quarter size) screenshot.
153 // Do not make this a binding, we can only take the screenshot once!
154 surfaceContainer.grabToImage(
156 screenshotImage.source = result.url;
158 Qt.size(root.width / 2, root.height / 2));
167 z: screenshotImage.z + 1
168 sourceComponent: Component {
171 title: d.splashTitle ? d.splashTitle : d.name
172 imageSource: d.splashImage
174 showHeader: d.splashShowHeader
175 backgroundColor: d.splashColor
176 headerColor: d.splashColorHeader
177 footerColor: d.splashColorFooter
179 rotation: root.splashRotation
180 anchors.centerIn: parent
181 width: rotation == 0 || rotation == 180 ? root.width : root.height
182 height: rotation == 0 || rotation == 180 ? root.height : root.width
190 z: splashLoader.z + 1
191 requestedWidth: root.requestedWidth
192 requestedHeight: root.requestedHeight
193 surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
197 id: promptSurfacesRepeater
198 objectName: "promptSurfacesRepeater"
199 // show only along with the top-most application surface
201 if (root.application && root.surface === root.application.surfaceList.first) {
202 return root.application.promptSurfaceList;
207 delegate: SurfaceContainer {
208 id: promptSurfaceContainer
209 interactive: index === 0 && root.interactive
210 surface: model.surface
213 requestedWidth: root.requestedWidth
214 requestedHeight: root.requestedHeight
215 isPromptSurface: true
216 z: surfaceContainer.z + (promptSurfacesRepeater.count - index)
217 property int index: model.index
218 onIndexChanged: updateFirst()
219 Component.onCompleted: updateFirst()
220 function updateFirst() {
222 promptSurfacesRepeater.first = promptSurfaceContainer;
231 property Item first: null
234// // SurfaceContainer size drives ApplicationWindow size
236// target: root; property: "implicitWidth"
237// value: stateGroup.state === "surface" ? surfaceContainer.implicitWidth : root.requestedWidth
238// when: root.requestedWidth >= 0
241// target: root; property: "implicitHeight"
242// value: stateGroup.state === "surface" ? surfaceContainer.implicitHeight : root.requestedHeight
243// when: root.requestedHeight >= 0
246// // ApplicationWindow size drives SurfaceContainer size
248// target: surfaceContainer; property: "width"; value: root.width
249// when: root.requestedWidth < 0
252// target: surfaceContainer; property: "height"; value: root.height
253// when: root.requestedHeight < 0
258 objectName: "applicationWindowStateGroup"
263 d.hadSurface && (!root.surface || !d.surfaceInitialized)
265 screenshotImage.status !== Image.Ready
270 !d.hadSurface && (!root.surface || !d.surfaceInitialized)
272 screenshotImage.status !== Image.Ready
277 (root.surface && d.surfaceInitialized)
280 (d.applicationState !== ApplicationInfoInterface.Running
281 && screenshotImage.status !== Image.Ready))
284 implicitWidth: surfaceContainer.implicitWidth
285 implicitHeight: surfaceContainer.implicitHeight
291 screenshotImage.status === Image.Ready
293 (d.applicationState !== ApplicationInfoInterface.Running
294 || !root.surface || !d.surfaceInitialized)
297 // This is a dead end. From here we expect the surface to be removed from the model
298 // shortly after we stop referencing to it in our SurfaceContainer.
301 // The surface died while the application is running. It must have been closed
302 // by the shell or the application decided to destroy it by itself
303 root.surface && d.surfaceInitialized && !d.liveSurface
304 && d.applicationState === ApplicationInfoInterface.Running
310 from: ""; to: "splashScreen"
311 PropertyAction { target: splashLoader; property: "active"; value: true }
312 PropertyAction { target: surfaceContainer
313 property: "visible"; value: false }
316 from: "splashScreen"; to: "surface"
317 SequentialAnimation {
318 PropertyAction { target: surfaceContainer
319 property: "opacity"; value: 0.0 }
320 PropertyAction { target: surfaceContainer
321 property: "visible"; value: true }
322 UbuntuNumberAnimation { target: surfaceContainer; property: "opacity";
324 duration: UbuntuAnimation.BriskDuration }
325 ScriptAction { script: {
326 splashLoader.active = false;
327 surfaceIsOldTimer.start();
332 from: "surface"; to: "splashScreen"
333 SequentialAnimation {
334 ScriptAction { script: {
335 surfaceIsOldTimer.stop();
336 d.surfaceOldEnoughToBeResized = false;
337 splashLoader.active = true;
338 surfaceContainer.visible = true;
340 UbuntuNumberAnimation { target: splashLoader; property: "opacity";
342 duration: UbuntuAnimation.BriskDuration }
343 PropertyAction { target: surfaceContainer
344 property: "visible"; value: false }
348 from: "surface"; to: "screenshot"
349 SequentialAnimation {
350 ScriptAction { script: {
351 surfaceIsOldTimer.stop();
352 d.surfaceOldEnoughToBeResized = false;
353 screenshotImage.visible = true;
355 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
357 duration: UbuntuAnimation.BriskDuration }
358 ScriptAction { script: {
359 surfaceContainer.visible = false;
360 surfaceContainer.surface = null;
366 from: "screenshot"; to: "surface"
367 SequentialAnimation {
368 PropertyAction { target: surfaceContainer
369 property: "visible"; value: true }
370 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
372 duration: UbuntuAnimation.BriskDuration }
373 ScriptAction { script: {
374 screenshotImage.visible = false;
375 screenshotImage.source = "";
376 surfaceIsOldTimer.start();
381 from: "splashScreen"; to: "screenshot"
382 SequentialAnimation {
383 PropertyAction { target: screenshotImage
384 property: "visible"; value: true }
385 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
387 duration: UbuntuAnimation.BriskDuration }
388 PropertyAction { target: splashLoader; property: "active"; value: false }
392 from: "surface"; to: "void"
393 ScriptAction { script: {
394 surfaceIsOldTimer.stop();
395 d.surfaceOldEnoughToBeResized = false;
396 surfaceContainer.visible = false;
400 from: "void"; to: "surface"
401 SequentialAnimation {
402 PropertyAction { target: surfaceContainer; property: "opacity"; value: 0.0 }
403 PropertyAction { target: surfaceContainer; property: "visible"; value: true }
404 UbuntuNumberAnimation { target: surfaceContainer; property: "opacity";
406 duration: UbuntuAnimation.BriskDuration }
407 ScriptAction { script: {
408 surfaceIsOldTimer.start();
414 SequentialAnimation {
415 ScriptAction { script: {
416 surfaceContainer.visible = false;
417 surfaceContainer.surface = null;
426// anchors.fill: parent
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list