on xenial help sign in
First pass at new greeter teasing
commitc868dfc8f2967001c6eab0d891c875a1bb4f30c7 authorMichael Terry <michael.terry@canonical.com> dateFri 7 Mar 2014, 21:46 (13 years ago) parent032ca4d
3 files changed+176−126
qml/Greeter/Greeter.qml+99−40 qml/Greeter/GreeterContent.qml−9 qml/Shell.qml+77−77
qml/Greeter/Greeter.qml+99−40
@@ -31,7 +31,7 @@ Showable {
3131 property real showProgress: MathUtils.clamp((width + x) / width, 0, 1)
3232
3333 showAnimation: StandardAnimation { property: "x"; to: 0 }
34− hideAnimation: StandardAnimation { property: "x"; to: -width }
34+ hideAnimation: __leftHideAnimation
3535
3636 property alias dragHandleWidth: dragHandle.width
3737 property alias model: greeterContentLoader.model
@@ -40,20 +40,24 @@ Showable {
4040 readonly property bool narrowMode: !multiUser && height > width
4141 readonly property bool multiUser: LightDM.Users.count > 1
4242
43− readonly property bool leftTeaserPressed: greeterContentLoader.status == Loader.Ready &&
44− greeterContentLoader.item.leftTeaserPressed
45− readonly property bool rightTeaserPressed: greeterContentLoader.status == Loader.Ready &&
46− greeterContentLoader.item.rightTeaserPressed
47−
4843 readonly property int currentIndex: greeterContentLoader.currentIndex
4944
45+ property var __leftHideAnimation: StandardAnimation { property: "x"; to: -width }
46+ property var __rightHideAnimation: StandardAnimation { property: "x"; to: width }
47+
5048 signal selected(int uid)
5149 signal unlocked(int uid)
50+ signal tease()
5251
53− onRightTeaserPressedChanged: {
54− if (rightTeaserPressed && (!locked || narrowMode) && x == 0) {
55− teasingTimer.start();
56− }
52+ function hideRight() {
53+ hideAnimation = __rightHideAnimation
54+ hide()
55+ }
56+
57+ Connections {
58+ target: __rightHideAnimation
59+ // Reset hide animation to default once we're finished with it
60+ onRunningChanged: if (!__rightHideAnimation.running) greeter.hideAnimation = __leftHideAnimation
5761 }
5862
5963 Loader {
@@ -82,45 +86,100 @@ Showable {
8286 }
8387 }
8488
85− Timer {
86− id: teasingTimer
87− interval: 200
89+ onTease: showLabelAnimation.start()
90+
91+ UbuntuShape {
92+ id: swipeHint
93+ color: "#222222"
94+
95+ visible: greeter.shown
96+ width: swipeLabel.width + units.gu(2)
97+ height: swipeLabel.height + units.gu(2)
98+ property real baseOpacity: 0.6
99+ opacity: 0.0
100+
101+ anchors.horizontalCenter: parent.horizontalCenter
102+ anchors.bottom: parent.bottom
103+ anchors.bottomMargin: units.gu(5)
104+
105+ Label {
106+ id: swipeLabel
107+ anchors.centerIn: parent
108+ text: i18n.tr("Swipe to unlock")
109+ color: "white"
110+ }
88111 }
89112
90− states: [
91− State {
92− name: "teasing"
93− when: teasingTimer.running
94− PropertyChanges {
95− target: greeter
96− x: -dragHandle.hintDisplacement
97− }
113+ SequentialAnimation {
114+ id: showLabelAnimation
115+
116+ PropertyAnimation {
117+ target: swipeHint
118+ property: "opacity"
119+ from: 0.0
120+ to: swipeHint.baseOpacity
121+ duration: UbuntuAnimation.SlowDuration
98122 }
99− ]
100− transitions: [
101− Transition {
102− from: "*"
103− to: "*"
104− NumberAnimation {
105− target: greeter
106− property: "x"
107− duration: 300
108− easing.type: Easing.OutCubic
109− }
123+ PropertyAnimation {
124+ duration: 10000
110125 }
111− ]
126+ PropertyAnimation {
127+ target: swipeHint
128+ property: "opacity"
129+ from: swipeHint.baseOpacity
130+ to: 0.0
131+ duration: UbuntuAnimation.SlowDuration
132+ }
133+ }
112134
113− DragHandle {
135+ // Bi-directional revealer
136+ DraggingArea {
114137 id: dragHandle
138+ anchors.fill: greeterContentLoader
139+ enabled: greeter.narrowMode || !greeter.locked
140+ orientation: Qt.Horizontal
141+ propagateComposedEvents: true
115142
116− anchors.top: parent.top
117− anchors.bottom: parent.bottom
118− anchors.right: parent.right
143+ Component.onCompleted: {
144+ // set evaluators to baseline of dragValue == 0
145+ leftEvaluator.reset()
146+ rightEvaluator.reset()
147+ }
119148
120− hintDisplacement: units.gu(2)
149+ function maybeTease() {
150+ if ((!greeter.locked || greeter.narrowMode) && greeter.x == 0)
151+ greeter.tease();
152+ }
121153
122− enabled: greeter.narrowMode || !greeter.locked
154+ onPressAndHold: maybeTease()
155+ onClicked: maybeTease()
123156
124− direction: Direction.Leftwards
157+ onDragEnd: {
158+ if (rightEvaluator.shouldAutoComplete())
159+ greeter.hideRight()
160+ else if (leftEvaluator.shouldAutoComplete())
161+ greeter.hide();
162+ else
163+ greeter.show(); // undo drag
164+ }
165+
166+ onDragValueChanged: {
167+ // dragValue is kept as a "step" value since we do this x adjusting on the fly
168+ greeter.x += dragValue
169+ }
170+
171+ EdgeDragEvaluator {
172+ id: rightEvaluator
173+ trackedPosition: dragHandle.dragValue + greeter.x
174+ maxDragDistance: parent.width
175+ direction: Direction.Rightwards
176+ }
177+
178+ EdgeDragEvaluator {
179+ id: leftEvaluator
180+ trackedPosition: dragHandle.dragValue + greeter.x
181+ maxDragDistance: parent.width
182+ direction: Direction.Leftwards
183+ }
125184 }
126185}
qml/Greeter/GreeterContent.qml−9
@@ -25,10 +25,6 @@ MouseArea {
2525 anchors.fill: parent
2626
2727 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
28− property bool leftTeaserPressed: teasingMouseArea.pressed &&
29− teasingMouseArea.mouseX < teasingMouseArea.width / 2
30− property bool rightTeaserPressed: teasingMouseArea.pressed &&
31− teasingMouseArea.mouseX > teasingMouseArea.width / 2
3228
3329 signal selected(int uid)
3430 signal unlocked(int uid)
@@ -74,11 +70,6 @@ MouseArea {
7470 opacity: 0.4
7571 }
7672
77− MouseArea {
78− id: teasingMouseArea
79− anchors.fill: parent
80− }
81−
8273 Loader {
8374 id: loginLoader
8475 objectName: "loginLoader"
qml/Shell.qml+77−77
@@ -211,16 +211,10 @@ FocusScope {
211211
212212 contentScale: 1.0 - 0.2 * disappearingAnimationProgress
213213 opacity: 1.0 - disappearingAnimationProgress
214− property real disappearingAnimationProgress: {
215− if (greeter.shown) {
216− return greeter.showProgress;
217− } else {
218− return stagesOuterContainer.showProgress;
219− }
220− }
214+ property real disappearingAnimationProgress: stagesOuterContainer.showProgress
221215
222− // FIXME: only necessary because stagesOuterContainer.showProgress and
223− // greeterRevealer.animatedProgress are not animated
216+ // FIXME: only necessary because stagesOuterContainer.showProgress
217+ // is not animated
224218 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
225219 }
226220 }
@@ -453,90 +447,94 @@ FocusScope {
453447 }
454448 }
455449
456− Greeter {
457− id: greeter
458− objectName: "greeter"
450+ Item {
451+ // Just a tiny wrapper to adjust greeter's x without messing with its own dragging
452+ width: parent.width
453+ height: parent.height
454+ x: launcher.progress
455+ Behavior on x {SmoothedAnimation{velocity: 600}}
459456
460− available: true
461− hides: [launcher, panel.indicators, hud]
462− shown: true
457+ Greeter {
458+ id: greeter
459+ objectName: "greeter"
463460
464− defaultBackground: shell.background
461+ available: true
462+ hides: [launcher, panel.indicators, hud]
463+ shown: true
465464
466− y: panel.panelHeight
467− width: parent.width
468− height: parent.height - panel.panelHeight
465+ defaultBackground: shell.background
469466
470− dragHandleWidth: shell.edgeSize
467+ y: panel.panelHeight
468+ width: parent.width
469+ height: parent.height - panel.panelHeight
471470
472− property var previousMainApp: null
473− property var previousSideApp: null
471+ dragHandleWidth: shell.edgeSize
474472
475− function removeApplicationFocus() {
476− greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
477− greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
478− applicationManager.unfocusCurrentApplication();
479− }
473+ property var previousMainApp: null
474+ property var previousSideApp: null
480475
481− function restoreApplicationFocus() {
482− if (greeter.previousMainApp) {
483− applicationManager.focusApplication(greeter.previousMainApp);
484− greeter.previousMainApp = null;
476+ function removeApplicationFocus() {
477+ greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
478+ greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
479+ applicationManager.unfocusCurrentApplication();
485480 }
486− if (greeter.previousSideApp) {
487− applicationManager.focusApplication(greeter.previousSideApp);
488− greeter.previousSideApp = null;
489− }
490− }
491481
492− onShownChanged: {
493− if (shown) {
494− lockscreen.reset();
495− // If there is only one user, we start authenticating with that one here.
496− // If there are more users, the Greeter will handle that
497− if (LightDM.Users.count == 1) {
498− LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
482+ function restoreApplicationFocus() {
483+ if (greeter.previousMainApp) {
484+ applicationManager.focusApplication(greeter.previousMainApp);
485+ greeter.previousMainApp = null;
486+ }
487+ if (greeter.previousSideApp) {
488+ applicationManager.focusApplication(greeter.previousSideApp);
489+ greeter.previousSideApp = null;
499490 }
500− greeter.forceActiveFocus();
501− removeApplicationFocus();
502− } else {
503− restoreApplicationFocus();
504491 }
505− }
506492
507− onUnlocked: greeter.hide()
508− onSelected: {
509− // Update launcher items for new user
510− var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
511− AccountsService.user = user;
512− LauncherModel.setUser(user);
513− }
493+ onShownChanged: {
494+ if (shown) {
495+ lockscreen.reset();
496+ // If there is only one user, we start authenticating with that one here.
497+ // If there are more users, the Greeter will handle that
498+ if (LightDM.Users.count == 1) {
499+ LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
500+ }
501+ greeter.forceActiveFocus();
502+ removeApplicationFocus();
503+ } else {
504+ restoreApplicationFocus();
505+ }
506+ }
514507
515− onLeftTeaserPressedChanged: {
516− if (leftTeaserPressed) {
517− launcher.tease();
508+ onUnlocked: greeter.hide()
509+ onSelected: {
510+ // Update launcher items for new user
511+ var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
512+ AccountsService.user = user;
513+ LauncherModel.setUser(user);
518514 }
519− }
520515
521− Connections {
522− target: applicationManager
523− ignoreUnknownSignals: true
524− // If any app is focused when greeter is open, it's due to a user action
525− // like a snap decision (say, an incoming call).
526− // TODO: these should be protected to only unlock for certain applications / certain usecases
527− // potentially only in connection with a notification.
528− onMainStageFocusedApplicationChanged: {
529− if (greeter.shown && applicationManager.mainStageFocusedApplication) {
530− greeter.previousMainApp = null // make way for new focused app
531− greeter.previousSideApp = null
532− greeter.hide()
516+ onTease: launcher.tease() //launcher.state = "visible"
517+
518+ Connections {
519+ target: applicationManager
520+ ignoreUnknownSignals: true
521+ // If any app is focused when greeter is open, it's due to a user action
522+ // like a snap decision (say, an incoming call).
523+ // TODO: these should be protected to only unlock for certain applications / certain usecases
524+ // potentially only in connection with a notification.
525+ onMainStageFocusedApplicationChanged: {
526+ if (greeter.shown && applicationManager.mainStageFocusedApplication) {
527+ greeter.previousMainApp = null // make way for new focused app
528+ greeter.previousSideApp = null
529+ greeter.hide()
530+ }
533531 }
534− }
535− onSideStageFocusedApplicationChanged: {
536− if (greeter.shown && applicationManager.sideStageFocusedApplication) {
537− greeter.previousMainApp = null // make way for new focused app
538− greeter.previousSideApp = null
539− greeter.hide()
532+ onSideStageFocusedApplicationChanged: {
533+ if (greeter.shown && applicationManager.sideStageFocusedApplication) {
534+ greeter.previousMainApp = null // make way for new focused app
535+ greeter.previousSideApp = null
536+ greeter.hide()
537+ }
540538 }
541539 }
542540 }
@@ -681,6 +679,8 @@ FocusScope {
681679 stages.hide();
682680 launcher.hide();
683681 }
682+ if (greeter.shown)
683+ greeter.hideRight();
684684 }
685685 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("applications.scope", false, true)
686686 onLauncherApplicationSelected:{