@@ -1,5 +1,5 @@
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015, 2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,12 +68,22 @@ QtObject {
71− if (chosenAnimation)
71+ if (chosenAnimation) {
72+ chosenAnimation.setup();
76+ property Connections chosenAnimationConns: Connections {
77+ target: root.chosenAnimation
79+ if (root.chosenAnimation.ready) {
72− chosenAnimation.start();
80+ root.chosenAnimation.start();
75 // to be read from outside
85 // to be read from outside
76− property bool running: chosenAnimation ? chosenAnimation.running : false
86+ property bool running: chosenAnimation !== null
78 property int duration: 450
88 property int duration: 450
79 property int easingType: Easing.InOutCubic
89 property int easingType: Easing.InOutCubic
@@ -84,7 +94,7 @@ QtObject {
84 ? spreadDelegate.width : spreadDelegate.height
94 ? spreadDelegate.width : spreadDelegate.height
85 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
95 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
87− property QtObject chosenAnimation
97+ property QtObject chosenAnimation: null
89 function setup90Animation() {
99 function setup90Animation() {
90 background.visible = true;
100 background.visible = true;
@@ -92,7 +102,6 @@ QtObject {
92 screenshot.width = window.width;
102 screenshot.width = window.width;
93 screenshot.height = window.height;
103 screenshot.height = window.height;
94 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
104 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
96 screenshot.transformOriginX = root.shortestDimension / 2;
105 screenshot.transformOriginX = root.shortestDimension / 2;
97 screenshot.transformOriginY = root.shortestDimension / 2;
106 screenshot.transformOriginY = root.shortestDimension / 2;
98 screenshot.visible = true;
107 screenshot.visible = true;
@@ -109,11 +118,17 @@ QtObject {
109 screenshot.discard();
118 screenshot.discard();
110 screenshot.visible = false;
119 screenshot.visible = false;
111 background.visible = false;
120 background.visible = false;
121+ chosenAnimation.ranSetup = false;
122+ chosenAnimation = null;
114 property QtObject simple90Animation: SequentialAnimation {
125 property QtObject simple90Animation: SequentialAnimation {
115 id: simple90Animation
126 id: simple90Animation
128+ function setup() { screenshot.take(); ranSetup = true; }
129+ property bool ranSetup: false
130+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
117 ScriptAction { script: setup90Animation() }
132 ScriptAction { script: setup90Animation() }
118 ParallelAnimation {
133 ParallelAnimation {
119 RotationAnimation {
134 RotationAnimation {
@@ -155,6 +170,10 @@ QtObject {
155 property QtObject moving90Animation: SequentialAnimation {
170 property QtObject moving90Animation: SequentialAnimation {
156 id: moving90Animation
171 id: moving90Animation
173+ function setup() { screenshot.take(); ranSetup = true; }
174+ property bool ranSetup: false
175+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
158 ScriptAction { script: setup90Animation() }
177 ScriptAction { script: setup90Animation() }
159 ParallelAnimation {
178 ParallelAnimation {
160 RotationAnimation {
179 RotationAnimation {
@@ -214,6 +233,9 @@ QtObject {
214 property QtObject halfLoopAnimation: SequentialAnimation {
233 property QtObject halfLoopAnimation: SequentialAnimation {
215 id: halfLoopAnimation
234 id: halfLoopAnimation
236+ function setup() { ready = true; }
237+ property bool ready: false
217 ScriptAction { script: {
239 ScriptAction { script: {
218 background.visible = true;
240 background.visible = true;
@@ -236,6 +258,8 @@ QtObject {
236 ScriptAction { script: {
258 ScriptAction { script: {
237 window.orientationAngle = spreadDelegate.shellOrientationAngle;
259 window.orientationAngle = spreadDelegate.shellOrientationAngle;
238 background.visible = false;
260 background.visible = false;
261+ chosenAnimation = null;
262+ halfLoopAnimation.ready = false;