on xenial help sign in
Fix the positioning of the application window screenshot
16d5266Daniel d'Andrada
qml/Stages/OrientationChangeAnimation.qml+9−11
@@ -23,7 +23,7 @@ QtObject {
23 property Item spreadDelegate
23 property Item spreadDelegate
24 property Item background
24 property Item background
25 property Item window
25 property Item window
26− property Image screenshot
26+ property Item screenshot
27
27
28 function start() {
28 function start() {
29 if (window.orientationAngle === 0) {
29 if (window.orientationAngle === 0) {
@@ -77,9 +77,6 @@ QtObject {
77
77
78 property int duration: 450
78 property int duration: 450
79 property int easingType: Easing.InOutCubic
79 property int easingType: Easing.InOutCubic
80− // Those values are good for debugging/development
81− //property int duration: 6000
82− //property int easingType: Easing.Linear
83
80
84 property int shortestDimension: spreadDelegate.width < spreadDelegate.height
81 property int shortestDimension: spreadDelegate.width < spreadDelegate.height
85 ? spreadDelegate.width : spreadDelegate.height
82 ? spreadDelegate.width : spreadDelegate.height
@@ -92,23 +89,24 @@ QtObject {
92 function setup90Animation() {
89 function setup90Animation() {
93 background.visible = true;
90 background.visible = true;
94
91
95− screenshot.width = window.width
92+ screenshot.width = window.width;
96− screenshot.height = window.height
93+ screenshot.height = window.height;
94+ screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
97 screenshot.take();
95 screenshot.take();
98− screenshot.transformOriginX = root.shortestDimension / 2
96+ screenshot.transformOriginX = root.shortestDimension / 2;
99− screenshot.transformOriginY = root.shortestDimension / 2
97+ screenshot.transformOriginY = root.shortestDimension / 2;
100 screenshot.visible = true;
98 screenshot.visible = true;
101
99
102 window.rotation = 0;
100 window.rotation = 0;
103 window.width = spreadDelegate.width;
101 window.width = spreadDelegate.width;
104 window.height = spreadDelegate.height;
102 window.height = spreadDelegate.height;
105− window.transformOriginX = root.shortestDimension / 2
103+ window.transformOriginX = root.shortestDimension / 2;
106− window.transformOriginY = root.shortestDimension / 2
104+ window.transformOriginY = root.shortestDimension / 2;
107 }
105 }
108
106
109 function tearDown90Animation() {
107 function tearDown90Animation() {
110 window.orientationAngle = spreadDelegate.shellOrientationAngle;
108 window.orientationAngle = spreadDelegate.shellOrientationAngle;
111− screenshot.source = "";
109+ screenshot.discard();
112 screenshot.visible = false;
110 screenshot.visible = false;
113 background.visible = false;
111 background.visible = false;
114 }
112 }
qml/Stages/SpreadDelegate.qml+25−10
@@ -68,7 +68,7 @@ FocusScope {
68 spreadDelegate: root
68 spreadDelegate: root
69 background: background
69 background: background
70 window: appWindowWithShadow
70 window: appWindowWithShadow
71− screenshot: appWindowScreenshot
71+ screenshot: appWindowScreenshotWithShadow
72 }
72 }
73
73
74 QtObject {
74 QtObject {
@@ -110,6 +110,8 @@ FocusScope {
110 property real transformOriginX
110 property real transformOriginX
111 property real transformOriginY
111 property real transformOriginY
112
112
113+ property var window: appWindow
114+
113 transform: Rotation {
115 transform: Rotation {
114 origin.x: appWindowWithShadow.transformOriginX
116 origin.x: appWindowWithShadow.transformOriginX
115 origin.y: appWindowWithShadow.transformOriginY
117 origin.y: appWindowWithShadow.transformOriginY
@@ -267,9 +269,10 @@ FocusScope {
267 }
269 }
268 }
270 }
269
271
270− Image {
272+ Item {
271− id: appWindowScreenshot
273+ // mimics appWindowWithShadow. Do the positioning of screenshots of non-fullscreen
272− source: ""
274+ // app windows
275+ id: appWindowScreenshotWithShadow
273 visible: false
276 visible: false
274
277
275 property real transformRotationAngle: 0
278 property real transformRotationAngle: 0
@@ -277,21 +280,33 @@ FocusScope {
277 property real transformOriginY
280 property real transformOriginY
278
281
279 transform: Rotation {
282 transform: Rotation {
280− origin.x: appWindowScreenshot.transformOriginX
283+ origin.x: appWindowScreenshotWithShadow.transformOriginX
281− origin.y: appWindowScreenshot.transformOriginY
284+ origin.y: appWindowScreenshotWithShadow.transformOriginY
282 axis { x: 0; y: 0; z: 1 }
285 axis { x: 0; y: 0; z: 1 }
283− angle: appWindowScreenshot.transformRotationAngle
286+ angle: appWindowScreenshotWithShadow.transformRotationAngle
284 }
287 }
285
288
289+ property var window: appWindowScreenshot
290+
286 function take() {
291 function take() {
287 // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
292 // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
288 // eg: "image://application/calculator-app/123456"
293 // eg: "image://application/calculator-app/123456"
289 var timeMs = new Date().getTime();
294 var timeMs = new Date().getTime();
290− source = "image://application/" + root.application.appId + "/" + timeMs;
295+ appWindowScreenshot.source = "image://application/" + root.application.appId + "/" + timeMs;
296+ }
297+ function discard() {
298+ appWindowScreenshot.source = "";
291 }
299 }
292
300
301+ Image {
302+ id: appWindowScreenshot
303+ source: ""
304+
305+ anchors.fill: parent
306+
293− sourceSize.width: width
307+ sourceSize.width: width
294− sourceSize.height: height
308+ sourceSize.height: height
309+ }
295 }
310 }
296
311
297 DraggingArea {
312 DraggingArea {