on xenial help sign in
Add error text if user drags too far
commit709e634cc4665370ff90afa4378417f3f60bfae4 authorMichael Terry <michael.terry@canonical.com> dateFri 19 Dec 2014, 12:00 (12 years ago) parenta0dba63
4 files changed+90−16
qml/Shell.qml+1−1 qml/Tutorial/Tutorial.qml+3−13 qml/Tutorial/TutorialLeft.qml+25 qml/Tutorial/TutorialPage.qml+61−2
qml/Shell.qml+1−1
@@ -847,7 +847,7 @@ Item {
847847 id: tutorial
848848 objectName: "tutorial"
849849 visible: AccountsService.demoEdges
850− paused: Powerd.status === Powerd.Off || LightDM.Greeter.active
850+ paused: LightDM.Greeter.active
851851 launcher: launcher
852852 panel: panel
853853 stages: stages
qml/Tutorial/Tutorial.qml+3−13
@@ -26,7 +26,7 @@ Item {
2626 property Item overlay
2727
2828 readonly property bool launcherEnabled: !running ||
29− loader.target === leftComponent
29+ (!paused && loader.target === leftComponent)
3030 readonly property bool stagesEnabled: !running
3131 readonly property bool panelEnabled: !running
3232 readonly property bool panelContentEnabled: !running
@@ -63,18 +63,6 @@ Item {
6363 }
6464 }
6565
66− Connections {
67− target: root.launcher
68−
69− onStateChanged: {
70− if (launcher.state === "visible") {
71− if (loader.target === leftComponent) {
72− loader.load(leftFinishComponent);
73− }
74− }
75− }
76− }
77−
7866 Loader {
7967 id: loader
8068
@@ -125,6 +113,8 @@ Item {
125113 parent: root.stages
126114 anchors.fill: parent
127115 launcher: root.launcher
116+
117+ onFinished: loader.load(leftFinishComponent)
128118 }
129119 }
130120
qml/Tutorial/TutorialLeft.qml+25
@@ -25,9 +25,34 @@ TutorialPage {
2525
2626 title: i18n.tr("Open the launcher")
2727 text: i18n.tr("Short swipe from the left edge.")
28+ errorText: i18n.tr("Too far!") + "\n" + i18n.tr("Try again.")
2829
2930 textXOffset: root.launcher.visibleWidth
3031
32+ Connections {
33+ target: root.launcher
34+
35+ property bool maybeDone
36+
37+ onStateChanged: {
38+ if (launcher.state === "visible") {
39+ maybeDone = true;
40+ }
41+ }
42+
43+ onDash: {
44+ maybeDone = false;
45+ root.showError();
46+ root.launcher.hide();
47+ }
48+
49+ onDragDistanceChanged: {
50+ if (root.launcher.dragDistance === 0 && maybeDone) {
51+ root.hide();
52+ }
53+ }
54+ }
55+
3156 Timer {
3257 id: teaseTimer
3358 interval: UbuntuAnimation.SleepyDuration
qml/Tutorial/TutorialPage.qml+61−2
@@ -27,6 +27,9 @@ Showable {
2727 // This is the block of text displayed below the header
2828 property alias text: textLabel.text
2929
30+ // This is the block of text displayed during an error
31+ property alias errorText: errorLabel.text
32+
3033 // Whether animations are paused
3134 property bool paused
3235
@@ -57,6 +60,10 @@ Showable {
5760
5861 signal finished()
5962
63+ function showError() {
64+ errorTimer.start();
65+ }
66+
6067 ////
6168
6269 shown: false
@@ -99,6 +106,11 @@ Showable {
99106 }
100107 }
101108
109+ Timer {
110+ id: errorTimer
111+ interval: 3500
112+ }
113+
102114 MouseArea { // eat any errant presses
103115 id: mouseArea
104116 anchors.fill: parent
@@ -128,7 +140,6 @@ Showable {
128140 wrapMode: Text.Wrap
129141 font.weight: Font.Light
130142 font.pixelSize: units.gu(3.5)
131− text: root.title
132143 }
133144
134145 Label {
@@ -144,7 +155,22 @@ Showable {
144155 wrapMode: Text.Wrap
145156 font.weight: Font.Light
146157 font.pixelSize: units.gu(2.5)
147− text: root.text
158+ }
159+
160+ Label {
161+ id: errorLabel
162+ anchors {
163+ top: parent.verticalCenter
164+ topMargin: d.verticalOffset + root.textYOffset
165+ left: parent.left
166+ leftMargin: d.sideMargin + d.textXOffset
167+ }
168+ width: parent.width - d.sideMargin * 2
169+ horizontalAlignment: Text.AlignLeft
170+ wrapMode: Text.Wrap
171+ font.weight: Font.Light
172+ font.pixelSize: units.gu(3.5)
173+ opacity: 0
148174 }
149175
150176 // A place for subclasses to add extra widgets
@@ -153,4 +179,37 @@ Showable {
153179 anchors.fill: parent
154180 }
155181 }
182+
183+ states: State {
184+ name: "errorState"
185+ when: errorTimer.running
186+ PropertyChanges { target: titleLabel; opacity: 0 }
187+ PropertyChanges { target: textLabel; opacity: 0 }
188+ PropertyChanges { target: errorLabel; opacity: 1 }
189+ }
190+
191+ transitions: Transition {
192+ to: "errorState"
193+ reversible: true
194+ SequentialAnimation {
195+ id: showErrorAnimation
196+ ParallelAnimation {
197+ StandardAnimation {
198+ target: titleLabel
199+ property: "opacity"
200+ duration: UbuntuAnimation.BriskDuration
201+ }
202+ StandardAnimation {
203+ target: textLabel
204+ property: "opacity"
205+ duration: UbuntuAnimation.BriskDuration
206+ }
207+ }
208+ StandardAnimation {
209+ target: errorLabel
210+ property: "opacity"
211+ duration: UbuntuAnimation.BriskDuration
212+ }
213+ }
214+ }
156215}