@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Unity.Application 0.1
19import Unity.Application 0.1
20−import SessionGrabber 0.1
22FocusScope {
21FocusScope {
@@ -31,16 +30,11 @@ FocusScope {
31 property QtObject application
30 property QtObject application
32 property int surfaceOrientationAngle
31 property int surfaceOrientationAngle
34− function removeScreenshot() {
35− sessionGrabber.removeScreenshot();
38 QtObject {
33 QtObject {
41 // helpers so that we don't have to check for the existence of an application everywhere
36 // helpers so that we don't have to check for the existence of an application everywhere
42 // (in order to avoid breaking qml binding due to a javascript exception)
37 // (in order to avoid breaking qml binding due to a javascript exception)
43− readonly property string appId: root.application ? root.application.appId : ""
44 readonly property string name: root.application ? root.application.name : ""
38 readonly property string name: root.application ? root.application.name : ""
45 readonly property url icon: root.application ? root.application.icon : ""
39 readonly property url icon: root.application ? root.application.icon : ""
46 readonly property int applicationState: root.application ? root.application.state : -1
40 readonly property int applicationState: root.application ? root.application.state : -1
@@ -56,11 +50,11 @@ FocusScope {
56 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
50 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
58 property bool needToTakeScreenshot:
52 property bool needToTakeScreenshot:
59− sessionContainer.surface && d.surfaceInitialized
53+ sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
60− && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
54+ && d.applicationState === ApplicationInfoInterface.Stopped
61 onNeedToTakeScreenshotChanged: {
55 onNeedToTakeScreenshotChanged: {
62 if (needToTakeScreenshot) {
56 if (needToTakeScreenshot) {
63− sessionGrabber.grab();
57+ screenshotImage.take();
@@ -92,9 +86,27 @@ FocusScope {
92 onTriggered: { if (stateGroup.state === "surface") { d.surfaceOldEnoughToBeResized = true; } }
86 onTriggered: { if (stateGroup.state === "surface") { d.surfaceOldEnoughToBeResized = true; } }
91+ objectName: "screenshotImage"
92+ source: d.defaultScreenshot
94+ antialiasing: !root.interactive
97+ // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
98+ // eg: "image://application/calculator-app/123456"
99+ var timeMs = new Date().getTime();
100+ source = "image://application/" + root.application.appId + "/" + timeMs;
103+ // Save memory by using a half-resolution (thus quarter size) screenshot
104+ sourceSize.width: root.width / 2
105+ sourceSize.height: root.height / 2
96 id: splashLoader
109 id: splashLoader
97− objectName: "splashLoader"
98 visible: active
110 visible: active
99 active: false
111 active: false
100 anchors.fill: parent
112 anchors.fill: parent
@@ -108,46 +120,10 @@ FocusScope {
108 backgroundColor: d.splashColor
120 backgroundColor: d.splashColor
109 headerColor: d.splashColorHeader
121 headerColor: d.splashColorHeader
110 footerColor: d.splashColorFooter
122 footerColor: d.splashColorFooter
111− activeSpinner: d.applicationState === ApplicationInfoInterface.Starting ||
112− d.applicationState === ApplicationInfoInterface.Running
119− objectName: "screenshotImage"
120− source: sessionGrabber.path || d.defaultScreenshot
121− anchors.fill: parent
122− antialiasing: !root.interactive
126− // Save memory by using a half-resolution (thus quarter size) screenshot
127− sourceSize.width: root.width / 2
128− sourceSize.height: root.height / 2
131− id: activityIndicator
132− anchors.centerIn: parent
134− running: stateGroup.state == "screenshot" &&
135− (d.applicationState === ApplicationInfoInterface.Starting || d.applicationState === ApplicationInfoInterface.Running)
144− onScreenshotGrabbed: {
145− // Need to reset to "" and back since it may be the same path with new content
146− screenshotImage.source = "";
147− screenshotImage.source = sessionGrabber.path;
151 SessionContainer {
127 SessionContainer {
152 id: sessionContainer
128 id: sessionContainer
153 // A fake application might not even have a session property.
129 // A fake application might not even have a session property.