on xenial help sign in
Drop greeterWrapper and instead add a launcherOffset property to the Greeter object
16a8ab4Michael Terry
qml/Greeter/Greeter.qml+32−9
@@ -25,13 +25,18 @@ Showable {
25 enabled: shown
25 enabled: shown
26 created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
26 created: greeterContentLoader.status == Loader.Ready && greeterContentLoader.item.ready
27
27
28+ x: launcherOffsetProxy + dragOffset
29+
28 property url background
30 property url background
29 property bool loadContent: required
31 property bool loadContent: required
30
32
33+ // How far to offset the top greeter layer during a launcher left-drag
34+ property real launcherOffset
35+
31 // 1 when fully shown and 0 when fully hidden
36 // 1 when fully shown and 0 when fully hidden
32 property real showProgress: MathUtils.clamp((width - Math.abs(x)) / width, 0, 1)
37 property real showProgress: MathUtils.clamp((width - Math.abs(x)) / width, 0, 1)
33
38
34− showAnimation: StandardAnimation { property: "x"; to: 0; duration: UbuntuAnimation.FastDuration }
39+ showAnimation: StandardAnimation { property: "dragOffset"; to: 0; duration: UbuntuAnimation.FastDuration }
35 hideAnimation: __leftHideAnimation
40 hideAnimation: __leftHideAnimation
36
41
37 property alias dragHandleWidth: dragHandle.width
42 property alias dragHandleWidth: dragHandle.width
@@ -43,8 +48,26 @@ Showable {
43
48
44 readonly property int currentIndex: greeterContentLoader.currentIndex
49 readonly property int currentIndex: greeterContentLoader.currentIndex
45
50
46− property var __leftHideAnimation: StandardAnimation { property: "x"; to: -width }
51+ property var __leftHideAnimation: StandardAnimation { property: "dragOffset"; to: -width }
47− property var __rightHideAnimation: StandardAnimation { property: "x"; to: width }
52+ property var __rightHideAnimation: StandardAnimation { property: "dragOffset"; to: width }
53+
54+ property real dragOffset
55+
56+ // We define a proxy and "is valid" property for launcherOffset because of
57+ // a quirk in Qml. We only want this animation to fire if we are reset
58+ // back to zero (on a release of the drag). But by defining a Behavior,
59+ // we delay the property from reaching zero until it's too late. So we set
60+ // a proxy bound to launcherOffset, which lets us see the target value of
61+ // zero as we also slowly adjust the value down to zero. But Qml will send
62+ // change notifications in declaration order. So unless we define the
63+ // proxy first, we need a little "is valid" property defined above the
64+ // proxy, so we know when to enable the proxy behavior. Phew!
65+ readonly property bool launcherOffsetValid: launcherOffset > 0
66+ property real launcherOffsetProxy: launcherOffset
67+ Behavior on launcherOffsetProxy {
68+ enabled: !launcherOffsetValid
69+ StandardAnimation {}
70+ }
48
71
49 signal selected(int uid)
72 signal selected(int uid)
50 signal unlocked(int uid)
73 signal unlocked(int uid)
@@ -110,9 +133,9 @@ Showable {
110 onPressAndHold: {} // eat event, but no need to tease, as drag will cover it
133 onPressAndHold: {} // eat event, but no need to tease, as drag will cover it
111
134
112 onDragEnd: {
135 onDragEnd: {
113− if (greeter.x > 0 && rightEvaluator.shouldAutoComplete()) {
136+ if (greeter.dragOffset > 0 && rightEvaluator.shouldAutoComplete()) {
114 greeter.hideRight()
137 greeter.hideRight()
115− } else if (greeter.x < 0 && leftEvaluator.shouldAutoComplete()) {
138+ } else if (greeter.dragOffset < 0 && leftEvaluator.shouldAutoComplete()) {
116 greeter.hide();
139 greeter.hide();
117 } else {
140 } else {
118 greeter.show(); // undo drag
141 greeter.show(); // undo drag
@@ -120,20 +143,20 @@ Showable {
120 }
143 }
121
144
122 onDragValueChanged: {
145 onDragValueChanged: {
123− // dragValue is kept as a "step" value since we do this x adjusting on the fly
146+ // dragValue is kept as a "step" value since we do this adjusting on the fly
124− greeter.x += dragValue
147+ greeter.dragOffset += dragValue;
125 }
148 }
126
149
127 EdgeDragEvaluator {
150 EdgeDragEvaluator {
128 id: rightEvaluator
151 id: rightEvaluator
129− trackedPosition: dragHandle.dragValue + greeter.x
152+ trackedPosition: dragHandle.dragValue + greeter.dragOffset
130 maxDragDistance: parent.width
153 maxDragDistance: parent.width
131 direction: Direction.Rightwards
154 direction: Direction.Rightwards
132 }
155 }
133
156
134 EdgeDragEvaluator {
157 EdgeDragEvaluator {
135 id: leftEvaluator
158 id: leftEvaluator
136− trackedPosition: dragHandle.dragValue + greeter.x
159+ trackedPosition: dragHandle.dragValue + greeter.dragOffset
137 maxDragDistance: parent.width
160 maxDragDistance: parent.width
138 direction: Direction.Leftwards
161 direction: Direction.Leftwards
139 }
162 }
qml/Shell.qml+64−78
@@ -493,118 +493,104 @@ Item {
493 Rectangle {
493 Rectangle {
494 anchors.fill: parent
494 anchors.fill: parent
495 color: "black"
495 color: "black"
496− opacity: greeterWrapper.showProgress * 0.8
496+ opacity: greeter.showProgress * 0.8
497 }
497 }
498
498
499− Item {
499+ Greeter {
500− // Just a tiny wrapper to adjust greeter's x without messing with its own dragging
500+ id: greeter
501− id: greeterWrapper
502− objectName: "greeterWrapper"
501+ objectName: "greeter"
502+
503+ property string lockedApp: ""
504+ property bool hasLockedApp: lockedApp !== ""
505+
506+ available: true
507+ hides: [launcher, panel.indicators]
508+ shown: true
509+ loadContent: required || lockscreen.required // keeps content in memory for quick show()
503− x: greeter.narrowMode ? launcher.progress : 0
510+ launcherOffset: narrowMode ? launcher.progress : 0
511+
512+ locked: shell.locked
513+
514+ background: shell.background
515+
504 y: panel.panelHeight
516 y: panel.panelHeight
505 width: parent.width
517 width: parent.width
506 height: parent.height - panel.panelHeight
518 height: parent.height - panel.panelHeight
507
519
508− Behavior on x {
520+ dragHandleWidth: shell.edgeSize
509− enabled: !launcher.dashSwipe
510− StandardAnimation {}
511− }
512
521
513 property bool fullyShown: showProgress === 1.0
522 property bool fullyShown: showProgress === 1.0
514 onFullyShownChanged: {
523 onFullyShownChanged: {
515 // Wait until the greeter is completely covering lockscreen before resetting it.
524 // Wait until the greeter is completely covering lockscreen before resetting it.
516− if (greeter.narrowMode && fullyShown && !LightDM.Greeter.authenticated) {
525+ if (narrowMode && fullyShown && !LightDM.Greeter.authenticated) {
517 lockscreen.reset();
526 lockscreen.reset();
518 lockscreen.maybeShow();
527 lockscreen.maybeShow();
519 }
528 }
520 }
529 }
521
530
522− readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
523 onShowProgressChanged: {
531 onShowProgressChanged: {
524 if (showProgress === 0) {
532 if (showProgress === 0) {
525 if ((LightDM.Greeter.promptless && LightDM.Greeter.authenticated) || shell.forcedUnlock) {
533 if ((LightDM.Greeter.promptless && LightDM.Greeter.authenticated) || shell.forcedUnlock) {
526 greeter.login()
534 greeter.login()
527− } else if (greeter.narrowMode) {
535+ } else if (narrowMode) {
528 lockscreen.clear(false) // to reset focus if necessary
536 lockscreen.clear(false) // to reset focus if necessary
529 }
537 }
530 }
538 }
531 }
539 }
532
540
533− Greeter {
534− id: greeter
535− objectName: "greeter"
536−
537− property string lockedApp: ""
538− property bool hasLockedApp: lockedApp !== ""
539−
540− available: true
541− hides: [launcher, panel.indicators]
542− shown: true
543− loadContent: required || lockscreen.required // keeps content in memory for quick show()
544−
545− locked: shell.locked
546−
547− background: shell.background
548−
549− width: parent.width
550− height: parent.height
551−
552− dragHandleWidth: shell.edgeSize
553−
554− onSessionStarted: {
541+ onSessionStarted: {
555− hide();
542+ hide();
556− lockscreen.hide();
543+ lockscreen.hide();
557− launcher.hide();
544+ launcher.hide();
558− }
545+ }
559
546
560− function startUnlock() {
547+ function startUnlock() {
561− if (narrowMode) {
548+ if (narrowMode) {
562− if (!LightDM.Greeter.authenticated) {
549+ if (!LightDM.Greeter.authenticated) {
563− lockscreen.maybeShow()
550+ lockscreen.maybeShow()
564− }
565− hide()
566− } else {
567− show()
568− tryToUnlock()
569 }
551 }
552+ hide()
553+ } else {
554+ show()
555+ tryToUnlock()
570 }
556 }
557+ }
571
558
572− onShownChanged: {
559+ onShownChanged: {
573− if (shown) {
560+ if (shown) {
574− // Disable everything so that user can't swipe greeter or
561+ // Disable everything so that user can't swipe greeter or
575− // launcher until we get first prompt/authenticate, which
562+ // launcher until we get first prompt/authenticate, which
576− // will re-enable the shell.
563+ // will re-enable the shell.
577− shell.enabled = false;
564+ shell.enabled = false;
578−
565+
579− if (greeter.narrowMode) {
566+ if (greeter.narrowMode) {
580− LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
567+ LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
581− } else {
568+ } else {
582− reset()
569+ reset()
583− }
584− greeter.lockedApp = "";
585− greeter.forceActiveFocus();
586 }
570 }
571+ greeter.lockedApp = "";
572+ greeter.forceActiveFocus();
587 }
573 }
574+ }
588
575
589− Component.onCompleted: {
576+ Component.onCompleted: {
590− Connectivity.unlockAllModems()
577+ Connectivity.unlockAllModems()
591− }
578+ }
592
579
593− onUnlocked: greeter.hide()
580+ onUnlocked: greeter.hide()
594− onSelected: {
581+ onSelected: {
595− // Update launcher items for new user
582+ // Update launcher items for new user
596− var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
583+ var user = LightDM.Users.data(uid, LightDM.UserRoles.NameRole);
597− AccountsService.user = user;
584+ AccountsService.user = user;
598− LauncherModel.setUser(user);
585+ LauncherModel.setUser(user);
599− }
586+ }
600
587
601− onTease: launcher.tease()
588+ onTease: launcher.tease()
602
589
603− Binding {
590+ Binding {
604− target: ApplicationManager
591+ target: ApplicationManager
605− property: "suspended"
592+ property: "suspended"
606− value: (greeter.shown && greeterWrapper.showProgress == 1) || lockscreen.shown
593+ value: (greeter.shown && greeter.showProgress == 1) || lockscreen.shown
607− }
608 }
594 }
609 }
595 }
610
596
tests/qmltests/tst_TabletShell.qml+2−2
@@ -211,8 +211,8 @@ Row {
211 }
211 }
212
212
213 function confirmLoggedIn(loggedIn) {
213 function confirmLoggedIn(loggedIn) {
214− var greeterWrapper = findChild(shell, "greeterWrapper")
214+ var greeter = findChild(shell, "greeter");
215− tryCompare(greeterWrapper, "showProgress", loggedIn ? 0 : 1)
215+ tryCompare(greeter, "showProgress", loggedIn ? 0 : 1);
216 tryCompare(sessionSpy, "count", loggedIn ? 1 : 0)
216 tryCompare(sessionSpy, "count", loggedIn ? 1 : 0)
217 }
217 }
218
218