@@ -17,6 +17,7 @@
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 SessionScreenshoter 0.1
21FocusScope {
22FocusScope {
@@ -29,11 +30,16 @@ FocusScope {
29 property QtObject application
30 property QtObject application
30 property int orientation
31 property int orientation
33+ function removeScreenshot() {
34+ screenshoter.removeScreenshot();
32 QtObject {
37 QtObject {
35 // helpers so that we don't have to check for the existence of an application everywhere
40 // helpers so that we don't have to check for the existence of an application everywhere
36 // (in order to avoid breaking qml binding due to a javascript exception)
41 // (in order to avoid breaking qml binding due to a javascript exception)
42+ readonly property string appId: root.application ? root.application.appId : ""
37 readonly property string name: root.application ? root.application.name : ""
43 readonly property string name: root.application ? root.application.name : ""
38 readonly property url icon: root.application ? root.application.icon : ""
44 readonly property url icon: root.application ? root.application.icon : ""
39 readonly property int applicationState: root.application ? root.application.state : -1
45 readonly property int applicationState: root.application ? root.application.state : -1
@@ -49,11 +55,10 @@ FocusScope {
49 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
55 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
51 property bool needToTakeScreenshot:
57 property bool needToTakeScreenshot:
52− sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
53− && d.applicationState === ApplicationInfoInterface.Stopped
58+ sessionContainer.surface && d.surfaceInitialized && (d.applicationState === ApplicationInfoInterface.Stopped || d.applicationState === ApplicationInfoInterface.Suspended)
54 onNeedToTakeScreenshotChanged: {
59 onNeedToTakeScreenshotChanged: {
55 if (needToTakeScreenshot) {
60 if (needToTakeScreenshot) {
56− screenshotImage.take();
61+ screenshoter.take();
@@ -73,22 +78,28 @@ FocusScope {
74 id: screenshotImage
79 id: screenshotImage
75 objectName: "screenshotImage"
80 objectName: "screenshotImage"
76− source: d.defaultScreenshot
81+ source: screenshoter.path != "" ? screenshoter.path : d.defaultScreenshot
77 anchors.fill: parent
82 anchors.fill: parent
78 antialiasing: !root.interactive
83 antialiasing: !root.interactive
80− function take() {
85+ asynchronous: true
81− // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
82− // eg: "image://application/calculator-app/123456"
83− var timeMs = new Date().getTime();
84− source = "image://application/" + root.application.appId + "/" + timeMs;
87 // Save memory by using a half-resolution (thus quarter size) screenshot
87 // Save memory by using a half-resolution (thus quarter size) screenshot
88 sourceSize.width: root.width / 2
88 sourceSize.width: root.width / 2
89 sourceSize.height: root.height / 2
89 sourceSize.height: root.height / 2
92+ SessionScreenshoter {
98+ screenshotImage.source = "";
99+ screenshotImage.source = screenshoter.path;
93 id: splashLoader
104 id: splashLoader
94 visible: active
105 visible: active
@@ -104,6 +115,9 @@ FocusScope {
104 backgroundColor: d.splashColor
115 backgroundColor: d.splashColor
105 headerColor: d.splashColorHeader
116 headerColor: d.splashColorHeader
106 footerColor: d.splashColorFooter
117 footerColor: d.splashColorFooter
118+ // TODO show .desktop file splash screen also if
119+ // we do not have a screenshot but obviously without spinner