~lukas-kde/unity8/dashboard

« back to all changes in this revision

Viewing changes to qml/Greeter/LoginList.qml

  • Committer: Lukáš Tinkl
  • Date: 2017-01-26 12:13:17 UTC
  • mfrom: (2749.1.49 unity8)
  • Revision ID: lukas.tinkl@canonical.com-20170126121317-qms39s9pikclidbe
merge trunk, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    focus: true
26
26
 
27
27
    property alias model: userList.model
28
 
    property bool alphanumeric: true
 
28
    property alias alphanumeric: promptList.alphanumeric
29
29
    property int currentIndex
30
30
    property bool locked
31
31
    property bool waiting
32
32
    property alias boxVerticalOffset: highlightItem.y
33
33
 
34
 
    readonly property alias passwordInput: passwordInput
35
34
    readonly property int numAboveBelow: 4
36
35
    readonly property int cellHeight: units.gu(5)
37
 
    readonly property int highlightedHeight: units.gu(15)
 
36
    readonly property int highlightedHeight: highlightItem.height
38
37
    readonly property int moveDuration: UbuntuAnimation.FastDuration
39
 
    property string selectedSession
40
38
    property string currentSession
41
39
    readonly property string currentUser: userList.currentItem.username
42
 
    property bool wasPrompted: false
43
40
 
44
 
    signal loginListSessionChanged(string session)
45
41
    signal responded(string response)
46
42
    signal selected(int index)
47
43
    signal sessionChooserButtonClicked()
48
44
 
49
45
    function tryToUnlock() {
50
 
        if (wasPrompted) {
51
 
            passwordInput.forceActiveFocus();
52
 
        } else {
53
 
            if (root.locked) {
54
 
                root.selected(currentIndex);
55
 
            } else {
56
 
                root.responded("");
57
 
            }
58
 
        }
59
 
    }
60
 
 
61
 
    function showMessage(html) {
62
 
        if (infoLabel.text === "") {
63
 
            infoLabel.text = html;
64
 
        } else {
65
 
            infoLabel.text += "<br>" + html;
66
 
        }
67
 
    }
68
 
 
69
 
    function showPrompt(text, isSecret, isDefaultPrompt) {
70
 
        passwordInput.text = isDefaultPrompt ? alphanumeric ? i18n.tr("Passphrase")
71
 
                                                            : i18n.tr("Passcode")
72
 
                                             : text;
73
 
        passwordInput.isPrompt = true;
74
 
        passwordInput.isSecret = isSecret;
75
 
        passwordInput.reset();
76
 
        wasPrompted = true;
 
46
        promptList.forceActiveFocus();
77
47
    }
78
48
 
79
49
    function showError() {
80
50
        wrongPasswordAnimation.start();
81
 
        root.resetAuthentication();
82
 
    }
83
 
 
84
 
    function reset() {
85
 
        root.resetAuthentication();
86
51
    }
87
52
 
88
53
    function showFakePassword() {
89
 
        passwordInput.showFakePassword();
90
 
    }
91
 
 
92
 
    QtObject {
93
 
        id: d
94
 
 
95
 
        function checkIfPromptless() {
96
 
            if (!waiting && !wasPrompted) {
97
 
                passwordInput.isPrompt = false;
98
 
                passwordInput.text = root.locked ? i18n.tr("Retry")
99
 
                                                 : i18n.tr("Log In")
100
 
            }
101
 
        }
102
 
    }
103
 
 
104
 
    onWaitingChanged: d.checkIfPromptless()
105
 
    onLockedChanged: d.checkIfPromptless()
 
54
        promptList.interactive = false;
 
55
        promptList.showFakePassword();
 
56
    }
106
57
 
107
58
    theme: ThemeSettings {
108
59
        name: "Ubuntu.Components.Themes.Ambiance"
109
60
    }
110
61
 
111
62
    Keys.onUpPressed: {
112
 
        selected(currentIndex - 1);
 
63
        if (currentIndex > 0) {
 
64
            selected(currentIndex - 1);
 
65
        }
113
66
        event.accepted = true;
114
67
    }
115
68
    Keys.onDownPressed: {
116
 
        selected(currentIndex + 1);
 
69
        if (currentIndex + 1 < model.count) {
 
70
            selected(currentIndex + 1);
 
71
        }
117
72
        event.accepted = true;
118
73
    }
119
74
    Keys.onEscapePressed: {
135
90
            rightMargin: units.gu(2)
136
91
        }
137
92
 
138
 
        height: root.highlightedHeight
 
93
        height: Math.max(units.gu(15), promptList.height + units.gu(8))
 
94
        Behavior on height { NumberAnimation { duration: root.moveDuration; easing.type: Easing.InOutQuad; } }
139
95
    }
140
96
 
141
97
    ListView {
153
109
        interactive: count > 1
154
110
 
155
111
        readonly property bool movingInternally: moveTimer.running || userList.moving
156
 
        onMovingInternallyChanged: {
157
 
            if (!movingInternally) {
158
 
                root.selected(currentIndex);
159
 
            }
160
 
        }
161
112
 
162
113
        onCurrentIndexChanged: {
163
 
            root.resetAuthentication();
164
114
            moveTimer.start();
165
115
        }
166
116
 
203
153
                    // Add an offset to bottomMargin for any items below the highlight
204
154
                    bottomMargin: -(units.gu(4) + (parent.belowHighlight ? parent.belowOffset : 0))
205
155
                }
206
 
                text: realName
 
156
                text: userList.currentIndex === index
 
157
                      && name === "*other"
 
158
                      && LightDMService.greeter.authenticationUser !== ""
 
159
                      ?  LightDMService.greeter.authenticationUser : realName
207
160
                color: userList.currentIndex !== index ? theme.palette.normal.raised
208
161
                                                       : theme.palette.normal.raisedText
209
162
 
309
262
        }
310
263
    }
311
264
 
312
 
    FadingLabel {
313
 
        id: infoLabel
314
 
        objectName: "infoLabel"
315
 
        anchors {
316
 
            bottom: passwordInput.top
317
 
            left: highlightItem.left
318
 
            topMargin: units.gu(1)
319
 
            bottomMargin: units.gu(1)
320
 
            leftMargin: units.gu(2)
321
 
            rightMargin: units.gu(1)
322
 
        }
323
 
 
324
 
        color: theme.palette.normal.raisedText
325
 
        width: root.width - anchors.leftMargin - anchors.rightMargin
326
 
        fontSize: "small"
327
 
        textFormat: Text.StyledText
328
 
 
329
 
        opacity: (userList.movingInternally || text == "") ? 0 : 1
330
 
        Behavior on opacity {
331
 
            NumberAnimation { duration: 100 }
332
 
        }
333
 
    }
334
 
 
335
 
    GreeterPrompt {
336
 
        id: passwordInput
337
 
        objectName: "passwordInput"
 
265
    PromptList {
 
266
        id: promptList
 
267
        objectName: "promptList"
338
268
        anchors {
339
269
            bottom: highlightItem.bottom
340
270
            horizontalCenter: highlightItem.horizontalCenter
341
271
            margins: units.gu(2)
342
272
        }
343
273
        width: highlightItem.width - anchors.margins * 2
344
 
        opacity: userList.movingInternally ? 0 : 1
345
 
 
346
 
        activeFocusOnTab: true
347
 
        isAlphanumeric: root.alphanumeric
348
 
 
349
 
        onClicked: root.tryToUnlock()
350
 
        onResponded: root.responded(text)
351
 
        onCanceled: root.selected(currentIndex)
352
 
 
353
 
        Behavior on opacity {
354
 
            NumberAnimation { duration: 100 }
355
 
        }
356
 
 
357
 
        WrongPasswordAnimation {
358
 
            id: wrongPasswordAnimation
359
 
            objectName: "wrongPasswordAnimation"
360
 
            target: passwordInput
 
274
 
 
275
        onClicked: {
 
276
            interactive = false;
 
277
            if (root.locked) {
 
278
                root.selected(currentIndex);
 
279
            } else {
 
280
                root.responded("");
 
281
            }
 
282
        }
 
283
        onResponded: {
 
284
            interactive = false;
 
285
            root.responded(text);
 
286
        }
 
287
        onCanceled: {
 
288
            interactive = false;
 
289
            root.selected(currentIndex);
 
290
        }
 
291
 
 
292
        Connections {
 
293
            target: LightDMService.prompts
 
294
            onModelReset: promptList.interactive = true
361
295
        }
362
296
    }
363
297
 
364
 
    function resetAuthentication() {
365
 
        if (!userList.currentItem) {
366
 
            return;
367
 
        }
368
 
        infoLabel.text = "";
369
 
        passwordInput.reset();
370
 
        root.wasPrompted = false;
 
298
    WrongPasswordAnimation {
 
299
        id: wrongPasswordAnimation
 
300
        objectName: "wrongPasswordAnimation"
 
301
        target: promptList
371
302
    }
372
303
}