on xenial help sign in
Tweak tutorial delays and start conditions
commit21b3b92c785b3fad7c844bf5902e45dfbe3bcafc authorMichael Terry <michael.terry@canonical.com> dateThu 28 Apr 2016, 12:36 (10 years ago) parent4ab97e8
3 files changed+54−54
qml/Tutorial/InactivityTimer.qml+17−9 qml/Tutorial/TutorialContent.qml+18−41 tests/qmltests/Tutorial/tst_Tutorial.qml+19−4
qml/Tutorial/InactivityTimer.qml+17−9
@@ -18,36 +18,44 @@ import QtQuick 2.4
1818import Ubuntu.Components 1.3
1919
2020Item {
21− readonly property alias running: internalTimer.running
22− property alias interval: internalTimer.interval
21+ id: root
22+
23+ readonly property bool running: delayTimer.running || inactivityTimer.running
24+ property int interval: 3000
2325 property var page
2426 property int lastInputTimestamp
2527
2628 function start() {
27− internalTimer.start();
29+ delayTimer.start();
2830 }
2931
3032 ////
3133
3234 onLastInputTimestampChanged: {
33− if (internalTimer.running) {
34− internalTimer.restart();
35+ if (inactivityTimer.running) {
36+ inactivityTimer.restart();
3537 }
3638 }
3739
3840 Connections {
3941 target: page
4042 onIsReadyChanged: {
41− if (page.isReady && internalTimer.running) {
42− internalTimer.restart();
43+ if (page.isReady && inactivityTimer.running) {
44+ inactivityTimer.restart();
4345 }
4446 }
4547 }
4648
4749 Timer {
48− id: internalTimer
50+ id: delayTimer
51+ interval: Math.max(root.interval - 3000, 0)
52+ onTriggered: inactivityTimer.start()
53+ }
54+
55+ Timer {
56+ id: inactivityTimer
4957
50− interval: 3000
58+ interval: Math.min(root.interval, 3000)
5159
5260 onTriggered: {
5361 if (page.isReady) {
qml/Tutorial/TutorialContent.qml+18−41
@@ -88,12 +88,12 @@ Item {
8888
8989 isReady: !tutorialLeftLoader.skipped && !paused && !keyboardVisible
9090
91− // Use an idle timer here, because when constructed, all our isReady variables will be false.
92− // Qml needs a moment to copy their values from Tutorial.qml. So we idle it and recheck.
93− Timer {
91+ InactivityTimer {
9492 id: tutorialLeftTimer
95− interval: 0
96− onTriggered: if (tutorialLeft.isReady && !tutorialLeft.shown) tutorialLeft.show()
93+ objectName: "tutorialLeftTimer"
94+ interval: 20000
95+ lastInputTimestamp: root.lastInputTimestamp
96+ page: parent
9797 }
9898
9999 onIsReadyChanged: if (isReady && !shown) tutorialLeftTimer.start()
@@ -122,19 +122,12 @@ Item {
122122 skipped: tutorialLeftLongLoader.skipped
123123 isReady: tutorialLeftLoader.skipped && !skipped && !paused && !keyboardVisible
124124
125− Timer {
125+ InactivityTimer {
126126 id: tutorialLeftLongTimer
127127 objectName: "tutorialLeftLongTimer"
128− interval: 5000
129− onTriggered: {
130− if (parent.isReady) {
131− if (!parent.shown) {
132− parent.show();
133− }
134− } else if (!parent.skipped) {
135− restart();
136− }
137− }
128+ interval: 10000
129+ lastInputTimestamp: root.lastInputTimestamp
130+ page: parent
138131 }
139132
140133 onIsReadyChanged: if (isReady && !shown) tutorialLeftLongTimer.start()
@@ -163,19 +156,12 @@ Item {
163156 skipped: tutorialTopLoader.skipped
164157 isReady: tutorialLeftLongLoader.skipped && !skipped && !paused && !keyboardVisible
165158
166− // We fire 30s after left edge tutorial, with at least 3s of inactivity
167−
168159 InactivityTimer {
169− id: tutorialTopInactivityTimer
170− lastInputTimestamp: root.lastInputTimestamp
171− page: parent
172− }
173−
174− Timer {
175160 id: tutorialTopTimer
176161 objectName: "tutorialTopTimer"
177− interval: 27000
178− onTriggered: tutorialTopInactivityTimer.start()
162+ interval: 60000
163+ lastInputTimestamp: root.lastInputTimestamp
164+ page: parent
179165 }
180166
181167 onIsReadyChanged: if (isReady && !shown) tutorialTopTimer.start()
@@ -203,27 +189,18 @@ Item {
203189 paused: root.paused
204190
205191 skipped: tutorialRightLoader.skipped
206− isReady: tutorialTopLoader.skipped && !skipped && !paused && !keyboardVisible
207− ApplicationManager.count >= 3
192+ isReady: tutorialTopLoader.skipped && !skipped && !paused && !keyboardVisible &&
193+ ApplicationManager.count >= 4
208194
209195 InactivityTimer {
210− id: tutorialRightInactivityTimer
211− objectName: "tutorialRightInactivityTimer"
196+ id: tutorialRightTimer
197+ objectName: "tutorialRightTimer"
198+ interval: 10000
212199 lastInputTimestamp: root.lastInputTimestamp
213200 page: parent
214201 }
215202
216− Connections {
217− target: d
218− onFocusedAppChanged: {
219− if (tutorialRight.isReady && !tutorialRight.shown && d.focusedApp
220− && d.focusedApp.state === ApplicationInfoInterface.Starting) {
221− tutorialRight.show();
222− }
223− }
224− }
225−
226− onIsReadyChanged: if (isReady && !shown) tutorialRightInactivityTimer.start()
203+ onIsReadyChanged: if (isReady && !shown) tutorialRightTimer.start()
227204 onFinished: AccountsService.markDemoEdgeCompleted("right")
228205 }
229206 }
tests/qmltests/Tutorial/tst_Tutorial.qml+19−4
@@ -231,6 +231,8 @@ Rectangle {
231231 prepareShell();
232232
233233 var tutorialLeft = findChild(shell, "tutorialLeft");
234+ var tutorialLeftTimer = findInvisibleChild(tutorialLeft, "tutorialLeftTimer");
235+ tutorialLeftTimer.interval = 0;
234236 tryCompare(tutorialLeft, "opacity", 1);
235237 }
236238
@@ -310,12 +312,15 @@ Rectangle {
310312 function openTutorialRight() {
311313 var tutorialLeftLoader = findChild(shell, "tutorialLeftLoader");
312314 var tutorialRight = findChild(shell, "tutorialRight");
315+ var tutorialRightTimer = findChild(tutorialRight, "tutorialRightTimer");
313316
314317 AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
315318 ApplicationManager.startApplication("gallery-app");
316319 ApplicationManager.startApplication("facebook-webapp");
320+ ApplicationManager.startApplication("camera-app");
317321
318322 tryCompare(tutorialLeftLoader, "active", false);
323+ tutorialRightTimer.interval = 1;
319324 tryCompare(tutorialRight, "shown", true);
320325 tryCompare(tutorialRight, "opacity", 1);
321326 }
@@ -523,16 +528,17 @@ Rectangle {
523528 // Test that if we exit the top tutorial, we don't immediately
524529 // jump into right tutorial.
525530 var tutorialRight = findChild(shell, "tutorialRight");
526− var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightInactivityTimer");
531+ var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightTimer");
527532
528533 tutorialRightTimer.interval = 1;
529534 openTutorialTop();
530535 ApplicationManager.startApplication("gallery-app");
531536 ApplicationManager.startApplication("facebook-webapp");
532− tryCompare(ApplicationManager, "count", 3);
537+ ApplicationManager.startApplication("camera-app");
538+ tryCompare(ApplicationManager, "count", 4);
533539
534540 AccountsService.demoEdgesCompleted = ["left", "left-long", "top"];
535− verify(tutorialRightTimer.running, true);
541+ verify(tutorialRightTimer.running);
536542 verify(!tutorialRight.shown);
537543 tryCompare(tutorialRight, "shown", true);
538544 }
@@ -614,7 +620,11 @@ Rectangle {
614620
615621 ApplicationManager.startApplication("dialer-app");
616622 ApplicationManager.startApplication("camera-app");
623+ ApplicationManager.startApplication("facebook-webapp");
617624 tryCompare(tutorialRightLoader.item, "isReady", true);
625+
626+ var tutorialRightTimer = findInvisibleChild(tutorialRightLoader, "tutorialRightTimer");
627+ tutorialRightTimer.interval = 1;
618628 tryCompare(tutorialRightLoader, "shown", true);
619629 }
620630
@@ -622,8 +632,11 @@ Rectangle {
622632 loadShell("desktop");
623633
624634 var tutorialRight = findChild(shell, "tutorialRight");
635+ var tutorialRightTimer = findInvisibleChild(tutorialRight, "tutorialRightTimer");
625636 ApplicationManager.startApplication("dialer-app");
626637 ApplicationManager.startApplication("camera-app");
638+ ApplicationManager.startApplication("facebook-webapp");
639+ tutorialRightTimer.interval = 1;
627640 tryCompare(tutorialRight, "shown", true);
628641
629642 var stage = findChild(shell, "stage");
@@ -678,7 +691,9 @@ Rectangle {
678691 AccountsService.demoEdges = true;
679692 tutorialLeft = findChild(shell, "tutorialLeft");
680693 verify(tutorialLeft != null);
681− tryCompare(tutorialLeft, "shown", true);
694+
695+ var tutorialLeftTimer = findChild(tutorialLeft, "tutorialLeftTimer");
696+ verify(tutorialLeftTimer.running);
682697 }
683698 }
684699}