on xenial help sign in
edge hinting tweaks

- change edge hinting behavior to only happen on onPressed and immediately snap back - fix edge hinting to not happen if the Greeter is locked . Approved by PS Jenkins bot, Daniel d'Andrada.

commitd894886766ccca9bce20fe1c9fa0533757956767 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 1 Jul 2013, 21:13 (13 years ago) parent8ba498c10acd0a
5 files changed+91−8
Greeter/Greeter.qml+2−2 Launcher/Launcher.qml+3−4 Shell.qml+6−1 tests/qmltests/Greeter/tst_Phone.qml+40−1 tests/qmltests/Launcher/tst_Launcher.qml+40
Greeter/Greeter.qml+2−2
@@ -48,7 +48,7 @@ Showable {
4848 signal unlocked(int uid)
4949
5050 onRightTeaserPressedChanged: {
51− if (rightTeaserPressed) {
51+ if (rightTeaserPressed && !locked) {
5252 teasingTimer.start();
5353 }
5454 }
@@ -81,7 +81,7 @@ Showable {
8181 states: [
8282 State {
8383 name: "teasing"
84− when: greeter.rightTeaserPressed || teasingTimer.running
84+ when: teasingTimer.running
8585 PropertyChanges {
8686 target: greeter
8787 x: -units.gu(2)
Launcher/Launcher.qml+3−4
@@ -25,7 +25,6 @@ Item {
2525
2626 property bool available: true // can be used to disable all interactions
2727
28− property bool teasing: false
2928 property int panelWidth: units.gu(8.5)
3029 property int dragAreaWidth: units.gu(1)
3130 property real progress: dragArea.dragging && dragArea.touchX > panel.width ? dragArea.touchX : 0
@@ -58,8 +57,8 @@ Item {
5857 animateTimer.start();
5958 }
6059
61− onTeasingChanged: {
62− if (teasing) {
60+ function tease() {
61+ if (available) {
6362 teaseTimer.start();
6463 }
6564 }
@@ -237,7 +236,7 @@ Item {
237236 },
238237 State {
239238 name: "teasing"
240− when: root.teasing || teaseTimer.running
239+ when: teaseTimer.running
241240 PropertyChanges {
242241 target: panel
243242 x: -root.panelWidth + units.gu(2)
Shell.qml+6−1
@@ -439,6 +439,12 @@ FocusScope {
439439 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
440440 shell.background = bgPath ? bgPath : default_background
441441 }
442+
443+ onLeftTeaserPressedChanged: {
444+ if (leftTeaserPressed) {
445+ launcher.tease();
446+ }
447+ }
442448 }
443449
444450 InputFilterArea {
@@ -532,7 +538,6 @@ FocusScope {
532538 width: parent.width
533539 dragAreaWidth: shell.edgeSize
534540 available: !greeter.locked
535− teasing: available && greeter.leftTeaserPressed
536541 onDashItemSelected: {
537542 greeter.hide()
538543 // Animate if moving between application and dash
tests/qmltests/Greeter/tst_Phone.qml+40−1
@@ -28,7 +28,17 @@ Item {
2828
2929 Greeter {
3030 id: greeter
31− anchors.fill: parent
31+ width: parent.width
32+ height: parent.height
33+ x: 0; y: 0
34+
35+ property int minX: 0
36+
37+ onXChanged: {
38+ if (x < minX) {
39+ minX = x;
40+ }
41+ }
3242 }
3343
3444 SignalSpy {
@@ -63,5 +73,34 @@ Item {
6373 tryCompare(greeter, "leftTeaserPressed", false)
6474 tryCompare(greeter, "rightTeaserPressed", false)
6575 }
76+
77+ function test_teaseLockedUnlocked_data() {
78+ return [
79+ {tag: "unlocked", locked: false},
80+ {tag: "locked", locked: true}
81+ ];
82+ }
83+
84+ function test_teaseLockedUnlocked(data) {
85+ tryCompare(greeter, "rightTeaserPressed", false);
86+ tryCompare(greeter, "x", 0);
87+ greeter.locked = data.locked;
88+
89+ mouseClick(greeter, greeter.width - units.gu(5), greeter.height - units.gu(1));
90+ greeter.minX = 0; // This is needed because the transition actually makes x jump once before animating
91+
92+ if (!data.locked) {
93+ // Check if it has been moved over by 2 GUs. Give it a 2 pixel grace area
94+ // because animation duration and teaseTimer are the same duration and
95+ // might cause slight offsets
96+ tryCompareFunction(function() { return greeter.minX <= -units.gu(2) + 2}, true);
97+ } else {
98+ // waiting 100ms to make sure nothing moves
99+ wait(100);
100+ compare(greeter.minX, 0, "Greeter moved even tho its locked");
101+ }
102+ // Wait until we're back to 0
103+ tryCompareFunction(function() { return greeter.x;}, 0);
104+ }
66105 }
67106}
tests/qmltests/Launcher/tst_Launcher.qml+40
@@ -43,6 +43,18 @@ Item {
4343 onDashItemSelected: {
4444 dashItemSelected_count++;
4545 }
46+
47+ property int maxPanelX: 0
48+ }
49+
50+ Connections {
51+ target: testCase.findChild(launcher, "launcherPanel")
52+
53+ onXChanged: {
54+ if (target.x > launcher.maxPanelX) {
55+ launcher.maxPanelX = target.x;
56+ }
57+ }
4658 }
4759
4860 UT.UnityTestCase {
@@ -126,5 +138,33 @@ Item {
126138 var panel = findChild(launcher, "launcherPanel")
127139 tryCompare(panel, "x", -panel.width, 1000)
128140 }
141+
142+
143+ function test_teaseLauncher_data() {
144+ return [
145+ {tag: "available", available: true},
146+ {tag: "not available", available: false}
147+ ];
148+ }
149+
150+ function test_teaseLauncher(data) {
151+ launcher.available = data.available;
152+ launcher.maxPanelX = -launcher.panelWidth;
153+ launcher.tease();
154+
155+ if (data.available) {
156+ // Check if the launcher slides in for units.gu(2). However, as the animation is 200ms
157+ // and the teaseTimer's timeout too, give it a 2 pixels grace distance
158+ tryCompareFunction(
159+ function(){
160+ return launcher.maxPanelX >= -launcher.panelWidth + units.gu(2) - 2;
161+ },
162+ true)
163+ } else {
164+ wait(100)
165+ compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
166+ }
167+ waitUntilLauncherDisappears();
168+ }
129169 }
130170}