on xenial help sign in
Add Showable.showNow() method and use it in Shell to immediately show greeter when we blank the screen rather than animating it
commitea550303616d11ffda97b16d78971dd70d988f11 authorMichael Terry <michael.terry@canonical.com> dateTue 1 Oct 2013, 14:18 (13 years ago) parenta5a966b
3 files changed+39−1
Components/Showable.qml+11 Shell.qml+1−1 tests/qmltests/Components/tst_Showable.qml+27
Components/Showable.qml+11
@@ -30,6 +30,7 @@ Item {
3030 property bool created: true
3131 property bool required
3232 property bool __shouldShow: false
33+ property bool __skipShowAnimation: false
3334
3435 property list<QtObject> hides
3536 property var showAnimation
@@ -58,6 +59,11 @@ Item {
5859 }
5960 }
6061
62+ function showNow() {
63+ __skipShowAnimation = true;
64+ show();
65+ }
66+
6167 onCreatedChanged: {
6268 if (created && __shouldShow) {
6369 __reallyShow();
@@ -67,6 +73,7 @@ Item {
6773
6874 function __reallyShow() {
6975 if (!available) {
76+ __skipShowAnimation = false;
7077 return false;
7178 }
7279
@@ -80,11 +87,15 @@ Item {
8087 if (!showAnimation.running) {
8188 showAnimation.restart()
8289 }
90+ if (__skipShowAnimation) {
91+ showAnimation.complete();
92+ }
8393 } else {
8494 visible = true;
8595 }
8696
8797 shown = true;
98+ __skipShowAnimation = false;
8899 return true;
89100 }
90101
Shell.qml+1−1
@@ -535,7 +535,7 @@ FocusScope {
535535 // is active. This usually indicates something like a phone call.
536536 if (status == Powerd.Off && (flags & Powerd.UseProximity) == 0) {
537537 powerConnection.setFocused(false);
538− greeter.show();
538+ greeter.showNow();
539539 } else if (status == Powerd.On) {
540540 powerConnection.setFocused(true);
541541 }
tests/qmltests/Components/tst_Showable.qml+27
@@ -155,5 +155,32 @@ Item {
155155 show1.created = true;
156156 compare(show1.shown, true, "Showable should automatically show when created changes to true if attempted to show before.");
157157 }
158+
159+ // Test that showNow immediately shows showable
160+ function test_showNow() {
161+ init_test();
162+
163+ show1.opacity = 0.2;
164+
165+ show1.showNow();
166+ compare(show1.shown, true, "Showable should be shown after showNow");
167+ compare(show1.showAnimation.running, false, "Showable should be done running after showNow");
168+ compare(show1.opacity, 1.0, "Showable should be at end of animation after showNow");
169+ }
170+
171+ // Test the lazy showNow mechanism while waiting for the created flag.
172+ function test_showNow_when_not_created() {
173+ init_test();
174+
175+ show1.opacity = 0.2;
176+ show1.created = false;
177+
178+ show1.showNow();
179+ compare(show1.shown, false, "Showable should not showNow when created == false");
180+ show1.created = true;
181+ compare(show1.shown, true, "Showable should automatically show when created changes to true if attempted to showNow before.");
182+ compare(show1.showAnimation.running, false, "Showable should be done running after delayed showNow");
183+ compare(show1.opacity, 1.0, "Showable should be at end of animation after delayed showNow");
184+ }
158185 }
159186}