@@ -1,5 +1,5 @@
11/*
2− * Copyright 2015 Canonical Ltd.
2+ * Copyright 2015, 2016 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,12 +68,22 @@ QtObject {
6868 }
6969 }
7070
71− if (chosenAnimation)
72− chosenAnimation.start();
71+ if (chosenAnimation) {
72+ chosenAnimation.setup();
73+ }
74+ }
75+
76+ property Connections chosenAnimationConns: Connections {
77+ target: root.chosenAnimation
78+ onReadyChanged: {
79+ if (root.chosenAnimation.ready) {
80+ root.chosenAnimation.start();
81+ }
82+ }
7383 }
7484
7585 // to be read from outside
76− property bool running: chosenAnimation ? chosenAnimation.running : false
86+ property bool running: chosenAnimation !== null
7787
7888 property int duration: 450
7989 property int easingType: Easing.InOutCubic
@@ -84,7 +94,7 @@ QtObject {
8494 ? spreadDelegate.width : spreadDelegate.height
8595 property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
8696
87− property QtObject chosenAnimation
97+ property QtObject chosenAnimation: null
8898
8999 function setup90Animation() {
90100 background.visible = true;
@@ -92,7 +102,6 @@ QtObject {
92102 screenshot.width = window.width;
93103 screenshot.height = window.height;
94104 screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
95− screenshot.take();
96105 screenshot.transformOriginX = root.shortestDimension / 2;
97106 screenshot.transformOriginY = root.shortestDimension / 2;
98107 screenshot.visible = true;
@@ -109,11 +118,17 @@ QtObject {
109118 screenshot.discard();
110119 screenshot.visible = false;
111120 background.visible = false;
121+ chosenAnimation.ranSetup = false;
122+ chosenAnimation = null;
112123 }
113124
114125 property QtObject simple90Animation: SequentialAnimation {
115126 id: simple90Animation
116127
128+ function setup() { screenshot.take(); ranSetup = true; }
129+ property bool ranSetup: false
130+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
131+
117132 ScriptAction { script: setup90Animation() }
118133 ParallelAnimation {
119134 RotationAnimation {
@@ -155,6 +170,10 @@ QtObject {
155170 property QtObject moving90Animation: SequentialAnimation {
156171 id: moving90Animation
157172
173+ function setup() { screenshot.take(); ranSetup = true; }
174+ property bool ranSetup: false
175+ readonly property bool ready: ranSetup && root.screenshot && root.screenshot.ready
176+
158177 ScriptAction { script: setup90Animation() }
159178 ParallelAnimation {
160179 RotationAnimation {
@@ -214,6 +233,9 @@ QtObject {
214233 property QtObject halfLoopAnimation: SequentialAnimation {
215234 id: halfLoopAnimation
216235
236+ function setup() { ready = true; }
237+ property bool ready: false
238+
217239 ScriptAction { script: {
218240 background.visible = true;
219241
@@ -236,6 +258,8 @@ QtObject {
236258 ScriptAction { script: {
237259 window.orientationAngle = spreadDelegate.shellOrientationAngle;
238260 background.visible = false;
261+ chosenAnimation = null;
262+ halfLoopAnimation.ready = false;
239263 } }
240264 }
241265}