on xenial help sign in
Support selectUserHint
commite2c4923a4c73ca8faecbceadc70a5d0bcc09f3b0 authorMichael Terry <michael.terry@canonical.com> dateWed 8 Jun 2016, 15:36 (10 years ago) parent82a0bc0
3 files changed+23−10
plugins/LightDM/Greeter.cpp+6 plugins/LightDM/Greeter.h+2 qml/Greeter/Greeter.qml+15−10
plugins/LightDM/Greeter.cpp+6
@@ -78,6 +78,12 @@ bool Greeter::promptless() const
7878 return d->promptless;
7979}
8080
81+QString Greeter::selectUser() const
82+{
83+ Q_D(const Greeter);
84+ return d->m_greeter->selectUserHint();
85+}
86+
8187void Greeter::authenticate(const QString &username)
8288{
8389 Q_D(Greeter);
plugins/LightDM/Greeter.h+2
@@ -38,6 +38,7 @@ class Greeter : public QObject
3838 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
3939 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
4040 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41+ Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
4142
4243public:
4344 explicit Greeter(QObject* parent=0);
@@ -46,6 +47,7 @@ public:
4647 bool isAuthenticated() const;
4748 QString authenticationUser() const;
4849 bool promptless() const;
50+ QString selectUser() const;
4951
5052public Q_SLOTS:
5153 void authenticate(const QString &username=QString());
qml/Greeter/Greeter.qml+15−10
@@ -114,7 +114,8 @@ Showable {
114114 id: d
115115
116116 readonly property bool multiUser: LightDMService.users.count > 1
117− property int currentIndex
117+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
118+ property int currentIndex: Math.max(selectUserIndex, 0)
118119 property bool waiting
119120
120121 // We want 'launcherOffset' to animate down to zero. But not to animate
@@ -131,7 +132,19 @@ Showable {
131132 UbuntuNumberAnimation {}
132133 }
133134
135+ function getUserIndex(username) {
136+ // Find index for requested user, if it exists
137+ for (var i = 0; i < LightDMService.users.count; i++) {
138+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
139+ return i;
140+ }
141+ }
142+ return -1;
143+ }
144+
134145 function selectUser(uid, reset) {
146+ if (uid < 0)
147+ return;
135148 d.waiting = true;
136149 if (reset) {
137150 loader.item.reset();
@@ -440,15 +453,7 @@ Showable {
440453 }
441454 }
442455
443− onRequestAuthenticationUser: {
444− // Find index for requested user, if it exists
445− for (var i = 0; i < LightDMService.users.count; i++) {
446− if (user === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
447− d.selectUser(i, true);
448− return;
449− }
450− }
451− }
456+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
452457 }
453458
454459 Connections {