on xenial help sign in
Ensure the greeter password field is not covered by the keyboard
3663846Daniel d'Andrada
qml/Greeter/Greeter.qml+8
@@ -30,6 +30,9 @@ Showable {
30
30
31 property url background
31 property url background
32
32
33+ // so that it can be replaced in tests with a mock object
34+ property var inputMethod: Qt.inputMethod
35+
33 prepareToHide: function () {
36 prepareToHide: function () {
34 hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width;
37 hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width;
35 d.forceRightOnNextHideAnimation = false;
38 d.forceRightOnNextHideAnimation = false;
@@ -102,6 +105,11 @@ Showable {
102 }
105 }
103 onUnlocked: greeter.unlocked(uid);
106 onUnlocked: greeter.unlocked(uid);
104 }
107 }
108+ Binding {
109+ target: greeterContentLoader.item
110+ property: "inputMethod"
111+ value: greeter.inputMethod
112+ }
105 }
113 }
106
114
107 DragHandle {
115 DragHandle {
qml/Greeter/GreeterContent.qml+6−2
@@ -24,6 +24,8 @@ Item {
24 id: root
24 id: root
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27+ property var inputMethod
28+
27 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
29 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
28
30
29 signal selected(int uid)
31 signal selected(int uid)
@@ -74,10 +76,12 @@ Item {
74 anchors {
76 anchors {
75 left: parent.left
77 left: parent.left
76 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
78 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
77− verticalCenter: parent.verticalCenter
79+ top: parent.top
78 }
80 }
79 width: units.gu(29)
81 width: units.gu(29)
80− height: parent.height
82+ height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
83+ : parent.height
84+ Behavior on height { UbuntuNumberAnimation {} }
81
85
82 // TODO: Once we have a system API for determining which mode we are
86 // TODO: Once we have a system API for determining which mode we are
83 // in, tablet/phone/desktop, that should be used instead of narrowMode.
87 // in, tablet/phone/desktop, that should be used instead of narrowMode.
tests/qmltests/Greeter/tst_MultiGreeter.qml+82−2
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import ".."
20import ".."
20import "../../../qml/Greeter"
21import "../../../qml/Greeter"
@@ -23,12 +24,26 @@ import LightDM 0.1 as LightDM
23import Unity.Test 0.1 as UT
24import Unity.Test 0.1 as UT
24
25
25Item {
26Item {
27+ id: root
26− width: units.gu(120)
28+ width: units.gu(140)
27 height: units.gu(80)
29 height: units.gu(80)
28
30
31+ QtObject {
32+ id: fakeInputMethod
33+ property bool visible: fakeKeyboard.visible
34+ property var keyboardRectangle: QtObject {
35+ property real x: fakeKeyboard.x
36+ property real y: fakeKeyboard.y
37+ property real width: fakeKeyboard.width
38+ property real height: fakeKeyboard.height
39+ }
40+ }
41+
29 Greeter {
42 Greeter {
30 id: greeter
43 id: greeter
31− anchors.fill: parent
44+ width: units.gu(120)
45+ height: root.height
46+ inputMethod: fakeInputMethod
32 locked: !LightDM.Greeter.authenticated
47 locked: !LightDM.Greeter.authenticated
33 }
48 }
34
49
@@ -43,6 +58,44 @@ Item {
43 }
58 }
44 }
59 }
45
60
61+ Rectangle {
62+ id: fakeKeyboard
63+ color: "green"
64+ opacity: 0.7
65+ anchors.bottom: root.bottom
66+ width: greeter.width
67+ height: greeter.height * 0.6
68+ visible: keyboardVisibleCheckbox.checked
69+ Text {
70+ text: "Keyboard Rectangle"
71+ color: "yellow"
72+ font.bold: true
73+ fontSizeMode: Text.Fit
74+ minimumPixelSize: 10; font.pixelSize: 200
75+ verticalAlignment: Text.AlignVCenter
76+ x: (parent.width - width) / 2
77+ y: (parent.height - height) / 2
78+ width: parent.width
79+ height: parent.height
80+ }
81+ }
82+
83+ Item {
84+ anchors {
85+ top: root.top
86+ bottom: root.bottom
87+ left: greeter.right
88+ right: root.right
89+ }
90+ RowLayout {
91+ Layout.fillWidth: true
92+ CheckBox {
93+ id: keyboardVisibleCheckbox
94+ }
95+ Label { text: "Keyboard Visible"; anchors.verticalCenter: parent.verticalCenter }
96+ }
97+ }
98+
46 SignalSpy {
99 SignalSpy {
47 id: unlockSpy
100 id: unlockSpy
48 target: greeter
101 target: greeter
@@ -65,6 +118,10 @@ Item {
65 name: "MultiGreeter"
118 name: "MultiGreeter"
66 when: windowShown
119 when: windowShown
67
120
121+ function cleanup() {
122+ keyboardVisibleCheckbox.checked = false;
123+ }
124+
68 function select_index(i) {
125 function select_index(i) {
69 // We could be anywhere in list; find target index to know which direction
126 // We could be anywhere in list; find target index to know which direction
70 var userlist = findChild(greeter, "userList")
127 var userlist = findChild(greeter, "userList")
@@ -382,5 +439,28 @@ Item {
382 tryCompare(spy, "count", 1)
439 tryCompare(spy, "count", 1)
383 greeterObj.destroy()
440 greeterObj.destroy()
384 }
441 }
442+
443+ function test_login_list_not_covered_by_keyboard() {
444+ var loginList = findChild(greeter, "loginLoader").item;
445+ compare(loginList.height, greeter.height);
446+
447+ // when the vkb shows up, loginList is moved up to remain fully uncovered
448+
449+ keyboardVisibleCheckbox.checked = true;
450+
451+ tryCompare(loginList, "height", greeter.height - fakeInputMethod.keyboardRectangle.height);
452+ tryCompareFunction( function() {
453+ var loginListRect = loginList.mapToItem(greeter, 0, 0, loginList.width, loginList.height);
454+ console.log("loginListRect.y " + loginListRect.y);
455+ console.log("loginListRect.height " + loginListRect.height);
456+ return loginListRect.y + loginListRect.height <= fakeInputMethod.keyboardRectangle.y;
457+ }, true);
458+
459+ // once the vkb goes away, loginList goes back to its full height
460+
461+ keyboardVisibleCheckbox.checked = false;
462+
463+ tryCompare(loginList, "height", greeter.height);
464+ }
385 }
465 }
386}
466}