@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919import Unity.Application 0.1
20−import SessionGrabber 0.1
2120
2221FocusScope {
2322 id: root
@@ -31,16 +30,11 @@ FocusScope {
3130 property QtObject application
3231 property int surfaceOrientationAngle
3332
34− function removeScreenshot() {
35− sessionGrabber.removeScreenshot();
36− }
37−
3833 QtObject {
3934 id: d
4035
4136 // helpers so that we don't have to check for the existence of an application everywhere
4237 // (in order to avoid breaking qml binding due to a javascript exception)
43− readonly property string appId: root.application ? root.application.appId : ""
4438 readonly property string name: root.application ? root.application.name : ""
4539 readonly property url icon: root.application ? root.application.icon : ""
4640 readonly property int applicationState: root.application ? root.application.state : -1
@@ -56,11 +50,11 @@ FocusScope {
5650 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
5751
5852 property bool needToTakeScreenshot:
59− sessionContainer.surface && d.surfaceInitialized
60− && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
53+ sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
54+ && d.applicationState === ApplicationInfoInterface.Stopped
6155 onNeedToTakeScreenshotChanged: {
6256 if (needToTakeScreenshot) {
63− sessionGrabber.grab();
57+ screenshotImage.take();
6458 }
6559 }
6660
@@ -92,9 +86,27 @@ FocusScope {
9286 onTriggered: { if (stateGroup.state === "surface") { d.surfaceOldEnoughToBeResized = true; } }
9387 }
9488
89+ Image {
90+ id: screenshotImage
91+ objectName: "screenshotImage"
92+ source: d.defaultScreenshot
93+ anchors.fill: parent
94+ antialiasing: !root.interactive
95+
96+ function take() {
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;
101+ }
102+
103+ // Save memory by using a half-resolution (thus quarter size) screenshot
104+ sourceSize.width: root.width / 2
105+ sourceSize.height: root.height / 2
106+ }
107+
95108 Loader {
96109 id: splashLoader
97− objectName: "splashLoader"
98110 visible: active
99111 active: false
100112 anchors.fill: parent
@@ -108,46 +120,10 @@ FocusScope {
108120 backgroundColor: d.splashColor
109121 headerColor: d.splashColorHeader
110122 footerColor: d.splashColorFooter
111− activeSpinner: d.applicationState === ApplicationInfoInterface.Starting ||
112− d.applicationState === ApplicationInfoInterface.Running
113123 }
114124 }
115125 }
116126
117− Image {
118− id: screenshotImage
119− objectName: "screenshotImage"
120− source: sessionGrabber.path || d.defaultScreenshot
121− anchors.fill: parent
122− antialiasing: !root.interactive
123− cache: false
124− asynchronous: true
125−
126− // Save memory by using a half-resolution (thus quarter size) screenshot
127− sourceSize.width: root.width / 2
128− sourceSize.height: root.height / 2
129−
130− ActivityIndicator {
131− id: activityIndicator
132− anchors.centerIn: parent
133− visible: running
134− running: stateGroup.state == "screenshot" &&
135− (d.applicationState === ApplicationInfoInterface.Starting || d.applicationState === ApplicationInfoInterface.Running)
136− }
137− }
138−
139− SessionGrabber {
140− id: sessionGrabber
141− appId: d.appId
142− target: root
143−
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;
148− }
149− }
150−
151127 SessionContainer {
152128 id: sessionContainer
153129 // A fake application might not even have a session property.