on xenial help sign in
Simplify and correctify focus for GreeterPrompt
6ecd8b8Michael Terry
qml/Greeter/GreeterPrompt.qml+3−11
@@ -20,6 +20,7 @@ import Ubuntu.Components 1.3
20FocusScope {
20FocusScope {
21 id: root
21 id: root
22 implicitHeight: units.gu(5)
22 implicitHeight: units.gu(5)
23+ focus: true
23
24
24 property bool isPrompt
25 property bool isPrompt
25 property bool isAlphanumeric
26 property bool isAlphanumeric
@@ -32,7 +33,6 @@ FocusScope {
32
33
33 function reset() {
34 function reset() {
34 passwordInput.text = "";
35 passwordInput.text = "";
35− focus = false;
36 d.enabled = true;
36 d.enabled = true;
37 }
37 }
38
38
@@ -63,6 +63,7 @@ FocusScope {
63 anchors.fill: parent
63 anchors.fill: parent
64 visible: !root.isPrompt
64 visible: !root.isPrompt
65 enabled: d.enabled
65 enabled: d.enabled
66+ focus: visible
66
67
67 onClicked: root.clicked()
68 onClicked: root.clicked()
68
69
@@ -79,6 +80,7 @@ FocusScope {
79 anchors.fill: parent
80 anchors.fill: parent
80 visible: root.isPrompt
81 visible: root.isPrompt
81 enabled: d.enabled
82 enabled: d.enabled
83+ focus: visible
82
84
83 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
85 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
84 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
86 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
@@ -111,22 +113,12 @@ FocusScope {
111 onAccepted: {
113 onAccepted: {
112 if (!enabled)
114 if (!enabled)
113 return;
115 return;
114− root.focus = true; // so that it can handle Escape presses for us
115 d.enabled = false;
116 d.enabled = false;
116 root.responded(text);
117 root.responded(text);
117 }
118 }
118
119
119 Keys.onEscapePressed: root.canceled()
120 Keys.onEscapePressed: root.canceled()
120
121
121− Connections {
122− target: Qt.inputMethod
123− onVisibleChanged: {
124− if (passwordInput.visible && !Qt.inputMethod.visible) {
125− passwordInput.focus = false;
126− }
127− }
128− }
129−
130 // We use our own custom placeholder label instead of the standard
122 // We use our own custom placeholder label instead of the standard
131 // TextField one because the standard one hardcodes baseText as the
123 // TextField one because the standard one hardcodes baseText as the
132 // palette color, whereas we want raisedSecondaryText.
124 // palette color, whereas we want raisedSecondaryText.