@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -15,11 +15,12 @@
1515 */
1616
1717import QtQuick 2.4
18+import QtGraphicalEffects 1.0
1819import Ubuntu.Components 1.3
1920import "../Components"
2021import "." 0.1
2122
22−Item {
23+StyledItem {
2324 id: root
2425
2526 property alias model: userList.model
@@ -29,7 +30,7 @@ Item {
2930
3031 readonly property int numAboveBelow: 4
3132 readonly property int cellHeight: units.gu(5)
32− readonly property int highlightedHeight: units.gu(10)
33+ readonly property int highlightedHeight: units.gu(15)
3334 readonly property int moveDuration: 200
3435 property string selectedSession
3536 property string currentSession: selectedSession ?
@@ -66,10 +67,9 @@ Item {
6667 }
6768
6869 function showPrompt(text, isSecret, isDefaultPrompt) {
69− passwordInput.text = "";
70− passwordInput.promptText = text;
71− passwordInput.enabled = true;
72− passwordInput.echoMode = isSecret ? TextInput.Password : TextInput.Normal;
70+ d.promptText = text;
71+ passwordInput.reset();
72+ passwordInput.isSecret = isSecret;
7373 if (wasPrompted) // stay in text field if second prompt
7474 passwordInput.focus = true;
7575 wasPrompted = true;
@@ -87,6 +87,16 @@ Item {
8787 root.resetAuthentication();
8888 }
8989
90+ QtObject {
91+ id: d
92+
93+ property string promptText
94+ }
95+
96+ theme: ThemeSettings {
97+ name: "Ubuntu.Components.Themes.Ambiance"
98+ }
99+
90100 Keys.onEscapePressed: {
91101 selected(currentIndex);
92102 }
@@ -99,10 +109,14 @@ Item {
99109 id: highlightItem
100110 anchors {
101111 left: parent.left
112+ leftMargin: units.gu(2)
102113 right: parent.right
114+ rightMargin: units.gu(2)
103115 verticalCenter: parent.verticalCenter
104116 }
105117
118+ height: root.highlightedHeight
119+
106120 z: sessionChooser.visible ? userList.z + 1 : z
107121
108122 // Use an AbstractButton due to icon limitations with Button
@@ -152,6 +166,8 @@ Item {
152166 objectName: "userList"
153167
154168 anchors.fill: parent
169+ anchors.leftMargin: units.gu(2)
170+ anchors.rightMargin: units.gu(2)
155171
156172 preferredHighlightBegin: userList.height / 2 - root.highlightedHeight / 2
157173 preferredHighlightEnd: userList.height / 2 - root.highlightedHeight / 2
@@ -198,7 +214,7 @@ Item {
198214 return 1 - Math.min(1, (Math.abs(highlightDist) + root.cellHeight) / ((root.numAboveBelow + 1) * root.cellHeight))
199215 }
200216
201− Label {
217+ FadingLabel {
202218 objectName: "username" + index
203219
204220 anchors {
@@ -206,13 +222,12 @@ Item {
206222 leftMargin: units.gu(2)
207223 right: parent.right
208224 rightMargin: units.gu(2)
209− top: parent.top
210− // Add an offset to topMargin for any items below the highlight
211− topMargin: units.gu(1) + (parent.belowHighlight ? parent.belowOffset : 0)
225+ bottom: parent.top
226+ // Add an offset to bottomMargin for any items below the highlight
227+ bottomMargin: -(units.gu(4) + (parent.belowHighlight ? parent.belowOffset : 0))
212228 }
213229 text: realName
214− color: "white"
215− elide: Text.ElideRight
230+ color: userList.currentIndex !== index ? theme.palette.normal.raised : theme.palette.normal.raisedText
216231
217232 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
218233 }
@@ -243,23 +258,22 @@ Item {
243258 }
244259 }
245260
246− Label {
261+ FadingLabel {
247262 id: infoLabel
248263 objectName: "infoLabel"
249264 anchors {
250265 bottom: passwordInput.top
251− left: parent.left
266+ left: highlightItem.left
252267 topMargin: units.gu(1)
253268 bottomMargin: units.gu(1)
254269 leftMargin: units.gu(2)
255270 rightMargin: units.gu(1)
256271 }
257272
258− color: "white"
273+ color: theme.palette.normal.raisedText
259274 width: root.width - anchors.leftMargin - anchors.rightMargin
260275 fontSize: "small"
261276 textFormat: Text.StyledText
262− clip: true
263277
264278 opacity: (userList.movingInternally || text == "") ? 0 : 1
265279 Behavior on opacity {
@@ -267,72 +281,36 @@ Item {
267281 }
268282 }
269283
270− TextField {
284+ GreeterPrompt {
271285 id: passwordInput
272286 objectName: "passwordInput"
273287 anchors {
274288 bottom: highlightItem.bottom
275− horizontalCenter: parent.horizontalCenter
276− margins: units.gu(1)
289+ horizontalCenter: highlightItem.horizontalCenter
290+ margins: units.gu(2)
277291 }
278− height: units.gu(4.5)
279− width: parent.width - anchors.margins * 2
292+ width: highlightItem.width - anchors.margins * 2
280293 opacity: userList.movingInternally ? 0 : 1
281294
282− inputMethodHints: root.alphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
295+ isPrompt: root.wasPrompted
296+ isAlphanumeric: root.alphanumeric
283297
284− property string promptText
285− placeholderText: root.wasPrompted ? promptText
286− : (root.locked ? i18n.tr("Retry")
287− : i18n.tr("Tap to unlock"))
298+ text: root.wasPrompted ? d.promptText
299+ : (root.locked ? i18n.tr("Retry")
300+ : i18n.tr("Log In"))
301+
302+ onClicked: root.tryToUnlock()
303+ onResponded: root.responded(text)
304+ onCanceled: root.selected(currentIndex)
288305
289306 Behavior on opacity {
290307 NumberAnimation { duration: 100 }
291308 }
292309
293− onAccepted: {
294− if (!enabled)
295− return;
296− root.focus = true; // so that it can handle Escape presses for us
297− enabled = false;
298− root.responded(text);
299− }
300− Keys.onEscapePressed: {
301− root.selected(currentIndex);
302− }
303−
304− Image {
305− anchors {
306− right: parent.right
307− rightMargin: units.gu(2)
308− verticalCenter: parent.verticalCenter
309− }
310− visible: !root.wasPrompted
311− source: "graphics/icon_arrow.png"
312− }
313−
314310 WrongPasswordAnimation {
315311 id: wrongPasswordAnimation
316312 target: passwordInput
317313 }
318−
319− Connections {
320− target: Qt.inputMethod
321− onVisibleChanged: {
322− if (!Qt.inputMethod.visible) {
323− passwordInput.focus = false;
324− }
325− }
326− }
327−
328− }
329−
330− MouseArea {
331− id: passwordMouseArea
332− objectName: "passwordMouseArea"
333− anchors.fill: passwordInput
334− enabled: !root.wasPrompted
335− onClicked: root.tryToUnlock()
336314 }
337315
338316 function resetAuthentication() {
@@ -340,10 +318,8 @@ Item {
340318 return;
341319 }
342320 infoLabel.text = "";
343− passwordInput.promptText = "";
344− passwordInput.text = "";
345− passwordInput.focus = false;
346− passwordInput.enabled = true;
321+ d.promptText = "";
322+ passwordInput.reset();
347323 root.wasPrompted = false;
348324 }
349325}