@@ -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,10 +15,11 @@
1515 */
1616
1717import QtQuick 2.4
18+import QtGraphicalEffects 1.0
1819import Ubuntu.Components 1.3
1920import "../Components"
2021
21−Item {
22+StyledItem {
2223 id: root
2324
2425 property alias model: userList.model
@@ -28,7 +29,7 @@ Item {
2829
2930 readonly property int numAboveBelow: 4
3031 readonly property int cellHeight: units.gu(5)
31− readonly property int highlightedHeight: units.gu(10)
32+ readonly property int highlightedHeight: units.gu(15)
3233 readonly property int moveDuration: 200
3334 readonly property string currentUser: userList.currentItem.username
3435 property bool wasPrompted: false
@@ -57,10 +58,9 @@ Item {
5758 }
5859
5960 function showPrompt(text, isSecret, isDefaultPrompt) {
60− passwordInput.text = "";
61− passwordInput.promptText = text;
62− passwordInput.enabled = true;
63− passwordInput.echoMode = isSecret ? TextInput.Password : TextInput.Normal;
61+ d.promptText = text;
62+ passwordInput.reset();
63+ passwordInput.isSecret = isSecret;
6464 if (wasPrompted) // stay in text field if second prompt
6565 passwordInput.focus = true;
6666 wasPrompted = true;
@@ -78,6 +78,16 @@ Item {
7878 root.resetAuthentication();
7979 }
8080
81+ QtObject {
82+ id: d
83+
84+ property string promptText
85+ }
86+
87+ theme: ThemeSettings {
88+ name: "Ubuntu.Components.Themes.Ambiance"
89+ }
90+
8191 Keys.onEscapePressed: {
8292 selected(currentIndex);
8393 }
@@ -86,19 +96,30 @@ Item {
8696 userList.currentIndex = currentIndex;
8797 }
8898
89− Rectangle {
99+ BorderImage {
100+ anchors {
101+ fill: highlightItem
102+ topMargin: -units.gu(1)
103+ leftMargin: -units.gu(1.5)
104+ rightMargin: -units.gu(1.5)
105+ bottomMargin: -units.gu(1.5)
106+ }
107+ source: "../Stages/graphics/dropshadow2gu.sci"
108+ opacity: 0.35
109+ }
110+
111+ UbuntuShape {
90112 id: highlightItem
91113 anchors {
92114 left: parent.left
115+ leftMargin: units.gu(2)
93116 right: parent.right
117+ rightMargin: units.gu(2)
94118 verticalCenter: parent.verticalCenter
95119 }
96120 height: root.highlightedHeight
97− color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
98− border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
99− border.width: units.dp(1)
100− radius: units.gu(1.5)
101− antialiasing: true
121+ aspect: UbuntuShape.Flat
122+ backgroundColor: theme.palette.normal.raised
102123 }
103124
104125 ListView {
@@ -106,6 +127,8 @@ Item {
106127 objectName: "userList"
107128
108129 anchors.fill: parent
130+ anchors.leftMargin: units.gu(2)
131+ anchors.rightMargin: units.gu(2)
109132
110133 preferredHighlightBegin: userList.height / 2 - root.highlightedHeight / 2
111134 preferredHighlightEnd: userList.height / 2 - root.highlightedHeight / 2
@@ -151,7 +174,7 @@ Item {
151174 return 1 - Math.min(1, (Math.abs(highlightDist) + root.cellHeight) / ((root.numAboveBelow + 1) * root.cellHeight))
152175 }
153176
154− Label {
177+ FadingLabel {
155178 objectName: "username" + index
156179
157180 anchors {
@@ -159,13 +182,12 @@ Item {
159182 leftMargin: units.gu(2)
160183 right: parent.right
161184 rightMargin: units.gu(2)
162− top: parent.top
163− // Add an offset to topMargin for any items below the highlight
164− topMargin: units.gu(1) + (parent.belowHighlight ? parent.belowOffset : 0)
185+ bottom: parent.top
186+ // Add an offset to bottomMargin for any items below the highlight
187+ bottomMargin: -(units.gu(4) + (parent.belowHighlight ? parent.belowOffset : 0))
165188 }
166189 text: realName
167− color: "white"
168− elide: Text.ElideRight
190+ color: userList.currentIndex !== index ? theme.palette.normal.raised : theme.palette.normal.raisedText
169191
170192 Behavior on anchors.topMargin { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
171193 }
@@ -196,23 +218,22 @@ Item {
196218 }
197219 }
198220
199− Label {
221+ FadingLabel {
200222 id: infoLabel
201223 objectName: "infoLabel"
202224 anchors {
203225 bottom: passwordInput.top
204− left: parent.left
226+ left: highlightItem.left
205227 topMargin: units.gu(1)
206228 bottomMargin: units.gu(1)
207229 leftMargin: units.gu(2)
208230 rightMargin: units.gu(1)
209231 }
210232
211− color: "white"
233+ color: theme.palette.normal.raisedText
212234 width: root.width - anchors.leftMargin - anchors.rightMargin
213235 fontSize: "small"
214236 textFormat: Text.StyledText
215− clip: true
216237
217238 opacity: (userList.movingInternally || text == "") ? 0 : 1
218239 Behavior on opacity {
@@ -220,72 +241,36 @@ Item {
220241 }
221242 }
222243
223− TextField {
244+ GreeterPrompt {
224245 id: passwordInput
225246 objectName: "passwordInput"
226247 anchors {
227248 bottom: highlightItem.bottom
228− horizontalCenter: parent.horizontalCenter
229− margins: units.gu(1)
249+ horizontalCenter: highlightItem.horizontalCenter
250+ margins: units.gu(2)
230251 }
231− height: units.gu(4.5)
232− width: parent.width - anchors.margins * 2
252+ width: highlightItem.width - anchors.margins * 2
233253 opacity: userList.movingInternally ? 0 : 1
234254
235− inputMethodHints: root.alphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
255+ isPrompt: root.wasPrompted
256+ isAlphanumeric: root.alphanumeric
236257
237− property string promptText
238− placeholderText: root.wasPrompted ? promptText
239− : (root.locked ? i18n.tr("Retry")
240− : i18n.tr("Tap to unlock"))
258+ text: root.wasPrompted ? d.promptText
259+ : (root.locked ? i18n.tr("Retry")
260+ : i18n.tr("Log In"))
261+
262+ onClicked: root.tryToUnlock()
263+ onResponded: root.responded(text)
264+ onCanceled: root.selected(currentIndex)
241265
242266 Behavior on opacity {
243267 NumberAnimation { duration: 100 }
244268 }
245269
246− onAccepted: {
247− if (!enabled)
248− return;
249− root.focus = true; // so that it can handle Escape presses for us
250− enabled = false;
251− root.responded(text);
252− }
253− Keys.onEscapePressed: {
254− root.selected(currentIndex);
255− }
256−
257− Image {
258− anchors {
259− right: parent.right
260− rightMargin: units.gu(2)
261− verticalCenter: parent.verticalCenter
262− }
263− visible: !root.wasPrompted
264− source: "graphics/icon_arrow.png"
265− }
266−
267270 WrongPasswordAnimation {
268271 id: wrongPasswordAnimation
269272 target: passwordInput
270273 }
271−
272− Connections {
273− target: Qt.inputMethod
274− onVisibleChanged: {
275− if (!Qt.inputMethod.visible) {
276− passwordInput.focus = false;
277− }
278− }
279− }
280−
281− }
282−
283− MouseArea {
284− id: passwordMouseArea
285− objectName: "passwordMouseArea"
286− anchors.fill: passwordInput
287− enabled: !root.wasPrompted
288− onClicked: root.tryToUnlock()
289274 }
290275
291276 function resetAuthentication() {
@@ -293,10 +278,8 @@ Item {
293278 return;
294279 }
295280 infoLabel.text = "";
296− passwordInput.promptText = "";
297− passwordInput.text = "";
298− passwordInput.focus = false;
299− passwordInput.enabled = true;
281+ d.promptText = "";
282+ passwordInput.reset();
300283 root.wasPrompted = false;
301284 }
302285}