on xenial help sign in
More tutorial page trigger fixups
commitb018d4e8d3228d86efaa4f9d3de97d8d9e455c06 authorMichael Terry <michael.terry@canonical.com> dateMon 16 Nov 2015, 14:33 (11 years ago) parent1e10d9f
3 files changed+55−61
qml/Shell.qml+3−1 qml/Tutorial/TutorialBottom.qml+9−1 qml/Tutorial/TutorialContent.qml+43−59
qml/Shell.qml+3−1
@@ -172,6 +172,7 @@ Item {
172172 }
173173
174174 WindowInputFilter {
175+ id: inputFilter
175176 Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
176177 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
177178 }
@@ -424,7 +425,7 @@ Item {
424425
425426 onStatusChanged: {
426427 if (Powerd.status === Powerd.Off && reason !== Powerd.Proximity &&
427− !callManager.hasCalls && !tutorial.running) {
428+ !callManager.hasCalls && !wizard.active) {
428429 // We don't want to simply call greeter.showNow() here, because
429430 // that will take too long. Qt will delay button event
430431 // handling until the greeter is done loading and may think the
@@ -540,6 +541,7 @@ Item {
540541 paused: callManager.hasCalls || greeter.shown
541542 keyboardVisible: inputMethod.state === "shown"
542543 usageScenario: shell.usageScenario
544+ lastInputTimestamp: inputFilter.lastInputTimestamp
543545 launcher: launcher
544546 panel: panel
545547 stage: applicationsDisplayLoader.item
qml/Tutorial/TutorialBottom.qml+9−1
@@ -32,12 +32,20 @@ TutorialPage {
3232 // eventually consolidate on a version of DirectionalDragArea that will
3333 // land in the SDK (making our guessing job easier). Though, also in the
3434 // future, this whole bottom tutorial component will also land in the SDK,
35− // rending our version here obsolete.
35+ // rendering our version here obsolete.
3636 //
3737 // Anyway, for the moment, we base our guesses on the copied-and-pasted
3838 // code used in several of the core apps and only bring this component
3939 // up if we are in those core apps.
4040
41+ function canShowForApp(appId) {
42+ return appId === "address-book-app" ||
43+ appId === "com.ubuntu.calculator_calculator" ||
44+ appId === "com.ubuntu.clock_clock" ||
45+ appId === "dialer-app" ||
46+ appId === "messaging-app";
47+ }
48+
4149 readonly property real dragAreaHeight: units.gu(3) // based on PageWithBottomEdge.qml
4250 readonly property real targetDistance: height * 0.2 + dragAreaHeight // based on PageWithBottomEdge.qml
4351
qml/Tutorial/TutorialContent.qml+43−59
@@ -46,6 +46,19 @@ Item {
4646
4747 ////
4848
49+ QtObject {
50+ id: d
51+
52+ // We allow "" because it is briefly empty on startup, and we don't
53+ // want to improperly skip any mobile tutorials.
54+ property bool mobileScenario: root.usageScenario === "" ||
55+ root.usageScenario === "phone" ||
56+ root.usageScenario === "tablet"
57+
58+ property bool endPointsFinished: tutorialRight.skipped && tutorialBottom.skipped
59+ onEndPointsFinishedChanged: if (endPointsFinished) root.finish()
60+ }
61+
4962 TutorialLeft {
5063 id: tutorialLeft
5164 objectName: "tutorialLeft"
@@ -54,9 +67,8 @@ Item {
5467 hides: [launcher, panel.indicators]
5568 paused: root.paused
5669
57− readonly property bool skipped: (root.usageScenario !== "phone"
58− && root.usageScenario !== "tablet")
59− || AccountsService.demoEdgesCompleted.indexOf("left") != -1
70+ readonly property bool skipped: !d.mobileScenario ||
71+ AccountsService.demoEdgesCompleted.indexOf("left") != -1
6072 isReady: !skipped && !paused && !keyboardVisible
6173
6274 onSkippedChanged: if (skipped && shown) hide()
@@ -72,34 +84,17 @@ Item {
7284 hides: [launcher, panel.indicators]
7385 paused: root.paused
7486
75− readonly property bool skipped: (root.usageScenario !== "phone"
76− && root.usageScenario !== "tablet")
77− || AccountsService.demoEdgesCompleted.indexOf("top") != -1
78− isReady: tutorialLeft.skipped && !skipped && !paused && !keyboardVisible && !tutorialBottom.shown
87+ readonly property bool skipped: !d.mobileScenario ||
88+ AccountsService.demoEdgesCompleted.indexOf("top") != -1
89+ isReady: tutorialLeft.skipped && !skipped && !paused && !keyboardVisible &&
90+ !tutorialBottom.shown && !tutorialBottom.mightShow
7991
8092 // We fire 30s after left edge tutorial, with at least 3s of inactivity
8193
82− Timer {
94+ InactivityTimer {
8395 id: tutorialTopInactivityTimer
84− objectName: "tutorialTopInactivityTimer"
85− interval: 3000
86−
87− Connections {
88− target: root
89− onLastInputTimestampChanged: {
90− if (tutorialTopInactivityTimer.running) {
91− tutorialTopInactivityTimer.restart();
92− }
93− }
94− }
95−
96− onTriggered: {
97− if (tutorialTop.isReady) {
98− tutorialTop.show();
99− } else {
100− restart();
101− }
102− }
96+ lastInputTimestamp: root.lastInputTimestamp
97+ page: parent
10398 }
10499
105100 Timer {
@@ -124,31 +119,28 @@ Item {
124119 paused: root.paused
125120
126121 readonly property bool skipped: AccountsService.demoEdgesCompleted.indexOf("right") != -1
127− isReady: tutorialTop.skipped && !skipped && !paused && !keyboardVisible && !tutorialBottom.shown &&
122+ isReady: tutorialTop.skipped && !skipped && !paused && !keyboardVisible &&
123+ !tutorialBottom.shown && !tutorialBottom.mightShow &&
128124 ApplicationManager.count >= 3
129125
130− Timer {
131− id: tutorialRightTimer
132− objectName: "tutorialRightTimer"
133− interval: 3000
134− onTriggered: {
135− if (tutorialRight.isReady) {
136− if (!tutorialRight.shown) {
137− tutorialRight.show();
138− }
139− } else {
140− restart();
141− }
142− }
126+ InactivityTimer {
127+ id: tutorialRightInactivityTimer
128+ lastInputTimestamp: root.lastInputTimestamp
129+ page: parent
143130 }
144131
145132 Connections {
146− target: ApplicationManager
147− onApplicationAdded: if (tutorialRight.isReady && !tutorialRight.shown) tutorialRight.show()
133+ target: stage
134+ onMainAppChanged: {
135+ if (tutorialRight.isReady && !tutorialRight.shown && stage.mainApp
136+ && stage.mainApp.state === ApplicationInfoInterface.Starting) {
137+ tutorialRight.show();
138+ }
139+ }
148140 }
149141
150142 onSkippedChanged: if (skipped && shown) hide()
151− onIsReadyChanged: if (isReady && !shown) tutorialRightTimer.start()
143+ onIsReadyChanged: if (isReady && !shown) tutorialRightInactivityTimer.start()
152144 onFinished: AccountsService.markDemoEdgeCompleted("right")
153145 }
154146
@@ -159,23 +151,15 @@ Item {
159151 hides: [launcher, panel.indicators]
160152 paused: root.paused
161153
162− readonly property bool skipped: (root.usageScenario !== "phone"
163− && root.usageScenario !== "tablet")
164− || AccountsService.demoEdgesCompleted.indexOf("bottom") != -1
165− isReady: !skipped && !paused && !keyboardVisible && !tutorialTop.shown && !tutorialRight.shown &&
166− // focused app is an app known to have a bottom edge
167− (ApplicationManager.focusedApplicationId == "dialer-app" ||
168− ApplicationManager.focusedApplicationId == "messaging-app" ||
169− ApplicationManager.focusedApplicationId == "address-book-app" ||
170− ApplicationManager.focusedApplicationId == "ubuntu-calculator-app" ||
171− ApplicationManager.focusedApplicationId == "ubuntu-clock-app") &&
172− (stage.mainApp && stage.mainApp.state === ApplicationInfoInterface.Running)
154+ readonly property bool skipped: !d.mobileScenario ||
155+ AccountsService.demoEdgesCompleted.indexOf("bottom") != -1
156+ readonly property bool mightShow: !skipped && stage.mainApp && canShowForApp(stage.mainApp.appId)
157+ isReady: !skipped && !paused && !keyboardVisible &&
158+ !tutorialTop.shown && !tutorialRight.shown &&
159+ mightShow && stage.mainApp.state === ApplicationInfoInterface.Running
173160
174161 onSkippedChanged: if (skipped && shown) hide()
175162 onIsReadyChanged: if (isReady && !shown) show()
176− onFinished: {
177− AccountsService.markDemoEdgeCompleted("bottom");
178− root.finish();
179− }
163+ onFinished: AccountsService.markDemoEdgeCompleted("bottom")
180164 }
181165}