@@ -19,6 +19,7 @@ import Ubuntu.Application 0.1
1919import Ubuntu.Components 0.1
2020import Ubuntu.Gestures 0.1
2121import LightDM 0.1 as LightDM
22+import AccountsService 0.1
2223import Powerd 0.1
2324import "Dash"
2425import "Greeter"
@@ -58,6 +59,19 @@ FocusScope {
5859 }
5960 }
6061
62+ property bool showEdgeDemo: false
63+ property bool showEdgeDemoInGreeter: showEdgeDemo //AccountsService.getUserProperty("lightdm", "demo-edges")
64+
65+ function hideEdgeDemo() {
66+ var user = LightDM.Users.data(greeter.currentIndex, LightDM.UserRoles.NameRole);
67+ AccountsService.setUserProperty(user, "demo-edges", false);
68+ shell.showEdgeDemo = false;
69+ }
70+ function hideEdgeDemoInGreeter() {
71+ //AccountsService.setUserProperty("lightdm", "demo-edges", false);
72+ shell.showEdgeDemoInGreeter = false;
73+ }
74+
6175 property ListModel searchHistory: SearchHistoryModel {}
6276
6377 property var applicationManager: ApplicationManagerWrapper {}
@@ -160,7 +174,7 @@ FocusScope {
160174 available: !greeter.shown && !lockscreen.shown
161175 hides: [stages, launcher, panel.indicators]
162176 shown: disappearingAnimationProgress !== 1.0
163− enabled: disappearingAnimationProgress === 0.0
177+ enabled: disappearingAnimationProgress === 0.0 && !leftEdgeDemo.active && !topEdgeDemo.active && !finalEdgeDemo.active
164178 // FIXME: unfocus all applications when going back to the dash
165179 onEnabledChanged: {
166180 if (enabled) {
@@ -187,6 +201,50 @@ FocusScope {
187201 // greeterRevealer.animatedProgress are not animated
188202 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
189203 }
204+
205+ DemoOverlay {
206+ id: topEdgeDemo
207+
208+ edge: "top"
209+ title: i18n.tr("Top edge")
210+ text: i18n.tr("Try swiping from the top edge to access the indicators")
211+ anchors.fill: dash
212+ visible: false
213+ enabled: shell.showEdgeDemo
214+ onSkip: shell.hideEdgeDemo()
215+
216+ Connections {
217+ target: greeter
218+ onShownChanged: if (!greeter.shown) topEdgeDemo.visible = true
219+ }
220+
221+ Connections {
222+ target: panel.indicators
223+ onFullyOpenedChanged: if (panel.indicators.fullyOpened) topEdgeDemo.enabled = false
224+ }
225+ }
226+
227+ DemoOverlay {
228+ id: leftEdgeDemo
229+
230+ edge: "left"
231+ title: i18n.tr("Left edge")
232+ text: i18n.tr("Swipe from the left to reveal the launcher for quick access to apps")
233+ anchors.fill: dash
234+ visible: false
235+ enabled: shell.showEdgeDemo
236+ onSkip: shell.hideEdgeDemo()
237+
238+ Connections {
239+ target: bottomEdgeDemo
240+ onActiveChanged: if (!bottomEdgeDemo.active) leftEdgeDemo.visible = true
241+ }
242+
243+ Connections {
244+ target: launcher
245+ onProgressChanged: if (launcher.progress >= 1.0) leftEdgeDemo.enabled = false
246+ }
247+ }
190248 }
191249
192250
@@ -381,6 +439,7 @@ FocusScope {
381439 Component.onCompleted: {
382440 if (LightDM.Users.count == 1) {
383441 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
442+ greeter.selected(0)
384443 }
385444 }
386445 }
@@ -423,6 +482,7 @@ FocusScope {
423482 // If there are more users, the Greeter will handle that
424483 if (LightDM.Users.count == 1) {
425484 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
485+ greeter.selected(0);
426486 }
427487 greeter.forceActiveFocus();
428488 }
@@ -430,8 +490,12 @@ FocusScope {
430490
431491 onUnlocked: greeter.hide()
432492 onSelected: {
493+ // Update background
433494 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
434495 shell.background = bgPath ? bgPath : default_background
496+ // Update edge demo hint
497+ var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole)
498+ shell.showEdgeDemo = AccountsService.getUserProperty(user, "demo-edges")
435499 }
436500
437501 onLeftTeaserPressedChanged: {
@@ -439,6 +503,34 @@ FocusScope {
439503 launcher.tease();
440504 }
441505 }
506+
507+ DemoOverlay {
508+ id: rightEdgeDemo
509+
510+ edge: "right"
511+ title: i18n.tr("Right edge")
512+ text: i18n.tr("Try swiping from the right edge to unlock the phone")
513+ anchors.fill: parent
514+ visible: shell.showEdgeDemoInGreeter
515+ onSkip: {
516+ shell.hideEdgeDemoInGreeter()
517+ shell.hideEdgeDemo()
518+ }
519+
520+ Connections {
521+ target: greeter
522+
523+ function hide() {
524+ if (rightEdgeDemo.active) {
525+ rightEdgeDemo.enabled = false
526+ shell.hideEdgeDemoInGreeter()
527+ }
528+ }
529+
530+ onUnlocked: hide()
531+ onShownChanged: if (!greeter.shown) hide()
532+ }
533+ }
442534 }
443535
444536 InputFilterArea {
@@ -493,6 +585,7 @@ FocusScope {
493585 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
494586 indicators {
495587 hides: [launcher]
588+ available: !rightEdgeDemo.active && !leftEdgeDemo.active && !finalEdgeDemo.active
496589 }
497590 fullscreenMode: shell.fullscreenMode
498591 searchVisible: !greeter.shown && !lockscreen.shown
@@ -501,6 +594,24 @@ FocusScope {
501594 anchors.fill: parent
502595 blockInput: panel.indicators.shown
503596 }
597+
598+ DemoOverlay {
599+ id: bottomEdgeDemo
600+
601+ edge: "bottom"
602+ title: i18n.tr("Close")
603+ text: i18n.tr("Swipe up again to close the settings screen")
604+ anchors.fill: panel.indicators
605+ visible: false
606+ enabled: shell.showEdgeDemo
607+ onSkip: shell.hideEdgeDemo()
608+
609+ Connections {
610+ target: panel.indicators
611+ onFullyOpenedChanged: if (panel.indicators.fullyOpened) bottomEdgeDemo.visible = true
612+ onPartiallyOpenedChanged: if (!panel.indicators.partiallyOpened && !panel.indicators.fullyOpened) bottomEdgeDemo.enabled = false
613+ }
614+ }
504615 }
505616
506617 Hud {
@@ -509,7 +620,7 @@ FocusScope {
509620 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
510621 height: parent.height
511622
512− available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown
623+ available: !greeter.shown && !panel.indicators.shown && !lockscreen.shown && !topEdgeDemo.active
513624 shown: false
514625 showAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: 0; easing.type: Easing.Linear }
515626 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
@@ -567,7 +678,7 @@ FocusScope {
567678 anchors.bottom: parent.bottom
568679 width: parent.width
569680 dragAreaWidth: shell.edgeSize
570− available: !greeter.shown || greeter.narrowMode
681+ available: (!greeter.shown || greeter.narrowMode) && !rightEdgeDemo.active && !topEdgeDemo.active && !bottomEdgeDemo.active && !finalEdgeDemo.active
571682 onDashItemSelected: {
572683 greeter.hide()
573684 // Animate if moving between application and dash
@@ -625,6 +736,27 @@ FocusScope {
625736 }
626737 }
627738
739+ DemoOverlay {
740+ id: finalEdgeDemo
741+
742+ edge: "none"
743+ title: i18n.tr("Well done")
744+ text: i18n.tr("You have now mastered the edge gestures and can start using the phone")
745+ skipText: i18n.tr("Finish")
746+ anchors.fill: overlay
747+ visible: false
748+ enabled: shell.showEdgeDemo
749+ onSkip: {
750+ launcher.hide();
751+ shell.hideEdgeDemo();
752+ }
753+
754+ Connections {
755+ target: leftEdgeDemo
756+ onActiveChanged: if (!leftEdgeDemo.active) finalEdgeDemo.visible = true
757+ }
758+ }
759+
628760 focus: true
629761
630762 InputFilterArea {