@@ -16,35 +16,35 @@
17import QtQuick 2.3
17import QtQuick 2.3
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19−import LightDM 0.1 as LightDM
20import "../Components"
19import "../Components"
25− property alias userList: userList
26 property alias model: userList.model
24 property alias model: userList.model
27− property alias currentIndex: userList.currentIndex
25+ property int currentIndex
29 readonly property int numAboveBelow: 4
28 readonly property int numAboveBelow: 4
30 readonly property int cellHeight: units.gu(5)
29 readonly property int cellHeight: units.gu(5)
31 readonly property int highlightedHeight: units.gu(10)
30 readonly property int highlightedHeight: units.gu(10)
32 readonly property int moveDuration: 200
31 readonly property int moveDuration: 200
32+ readonly property string currentUser: userList.currentItem.username
33 property bool wasPrompted: false
33 property bool wasPrompted: false
35− signal selected(int uid)
35+ signal selected(int index)
36− signal unlocked()
36+ signal responded(string response)
38 function tryToUnlock() {
38 function tryToUnlock() {
39− if (LightDM.Greeter.promptless) {
39+ if (wasPrompted) {
40− if (LightDM.Greeter.authenticated) {
40+ passwordInput.forceActiveFocus();
43− root.resetAuthentication()
43+ root.resetAuthentication();
44 root.selected(currentIndex);
44 root.selected(currentIndex);
47− passwordInput.forceActiveFocus()
@@ -106,18 +106,10 @@ Item {
107 readonly property bool movingInternally: moveTimer.running || userList.moving
107 readonly property bool movingInternally: moveTimer.running || userList.moving
109+ currentIndex: root.currentIndex
109 onCurrentIndexChanged: {
110 onCurrentIndexChanged: {
110− if (LightDM.Greeter.authenticationUser != userList.model.data(currentIndex, LightDM.UserRoles.NameRole)) {
111− root.resetAuthentication();
111+ root.resetAuthentication();
112− root.selected(currentIndex);
112+ moveTimer.start();
116− onMovingInternallyChanged: {
117− // Only emit the selected signal once we stop moving to avoid frequent background changes
118− if (!movingInternally) {
119− root.selected(userList.currentIndex);
123 delegate: Item {
115 delegate: Item {
@@ -126,6 +118,7 @@ Item {
127 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
119 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
128 readonly property int belowOffset: root.highlightedHeight - root.cellHeight
120 readonly property int belowOffset: root.highlightedHeight - root.cellHeight
121+ readonly property string username: name
130 opacity: {
123 opacity: {
131 // The goal here is to make names less and less opaque as they
124 // The goal here is to make names less and less opaque as they
@@ -173,11 +166,8 @@ Item {
173 topMargin: parent.belowHighlight ? parent.belowOffset : 0
166 topMargin: parent.belowHighlight ? parent.belowOffset : 0
175 height: parent.height
168 height: parent.height
176− enabled: userList.currentIndex !== index
169+ enabled: userList.currentIndex !== index && parent.opacity > 0
177− onClicked: {
170+ onClicked: root.selected(index)
179− userList.currentIndex = index;
182 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
172 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
@@ -230,9 +220,9 @@ Item {
230 opacity: userList.movingInternally ? 0 : 1
220 opacity: userList.movingInternally ? 0 : 1
232 property string promptText
222 property string promptText
233− placeholderText: LightDM.Greeter.promptless ? (LightDM.Greeter.authenticated ? i18n.tr("Tap to unlock")
223+ placeholderText: root.wasPrompted ? promptText
234− : i18n.tr("Retry"))
224+ : (root.locked ? i18n.tr("Retry")
235− : promptText
225+ : i18n.tr("Tap to unlock"))
237 Behavior on opacity {
227 Behavior on opacity {
238 NumberAnimation { duration: 100 }
228 NumberAnimation { duration: 100 }
@@ -243,7 +233,7 @@ Item {
244 root.focus = true; // so that it can handle Escape presses for us
234 root.focus = true; // so that it can handle Escape presses for us
245 enabled = false;
235 enabled = false;
246− LightDM.Greeter.respond(text);
236+ root.responded(text);
248 Keys.onEscapePressed: {
238 Keys.onEscapePressed: {
249 root.resetAuthentication();
239 root.resetAuthentication();
@@ -256,7 +246,7 @@ Item {
256 rightMargin: units.gu(2)
246 rightMargin: units.gu(2)
257 verticalCenter: parent.verticalCenter
247 verticalCenter: parent.verticalCenter
259− visible: LightDM.Greeter.promptless
249+ visible: !root.wasPrompted
260 source: "graphics/icon_arrow.png"
250 source: "graphics/icon_arrow.png"
@@ -280,7 +270,7 @@ Item {
280 id: passwordMouseArea
270 id: passwordMouseArea
281 objectName: "passwordMouseArea"
271 objectName: "passwordMouseArea"
282 anchors.fill: passwordInput
272 anchors.fill: passwordInput
283− enabled: LightDM.Greeter.promptless
273+ enabled: !root.wasPrompted
284 onClicked: root.tryToUnlock()
274 onClicked: root.tryToUnlock()