~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-zesty-2202

« back to all changes in this revision

Viewing changes to plugins/Ubuntu/Settings/Fingerprint/Setup.qml

Merging with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Jonas G. Drange <jonas.drange@canonical.com>
 
17
 */
 
18
 
 
19
import Biometryd 0.0
 
20
import QtQuick 2.4
 
21
import QtQuick.Layouts 1.1
 
22
import Ubuntu.Components 1.3
 
23
import Ubuntu.Settings.Fingerprint 0.1
 
24
 
 
25
Page {
 
26
    id: root
 
27
 
 
28
    objectName: "fingerprintSetupPage"
 
29
 
 
30
    signal enroll()
 
31
    signal cancel()
 
32
 
 
33
    function enrollmentFailed(error) {
 
34
        root.state = "failed";
 
35
    }
 
36
 
 
37
    function enrollmentCompleted() {
 
38
        root.state = "done";
 
39
    }
 
40
 
 
41
    function enrollmentProgressed(progress, hints) {
 
42
        root.state = "reading";
 
43
        imageDefault.masks = hints[FingerprintReader.masks];
 
44
        progressLabel.progress = 100 * progress;
 
45
        directionContainer.direction = hints[FingerprintReader.suggestedNextDirection] || FingerprintReader.NotAvailable;
 
46
    }
 
47
 
 
48
    states: [
 
49
        State {
 
50
            name: ""
 
51
            StateChangeScript {
 
52
                script: statusLabel.setText(statusLabel.initialText)
 
53
            }
 
54
        },
 
55
        State {
 
56
            name: "reading"
 
57
            StateChangeScript {
 
58
                script: statusLabel.setText(
 
59
                    i18n.dtr("ubuntu-settings-components",
 
60
                             "Tap your finger repeatedly on the reader.")
 
61
                )
 
62
            }
 
63
            PropertyChanges {
 
64
                target: imageDefault
 
65
                opacity: 1
 
66
            }
 
67
            PropertyChanges {
 
68
                target: progressLabel
 
69
                opacity: 1
 
70
            }
 
71
        },
 
72
        State {
 
73
            name: "longer"
 
74
            StateChangeScript {
 
75
                script: statusLabel.setText(
 
76
                    i18n.dtr("ubuntu-settings-components",
 
77
                             "Keep your finger on the reader for longer.")
 
78
                )
 
79
            }
 
80
        },
 
81
        State {
 
82
            name: "failed"
 
83
            PropertyChanges {
 
84
                target: imageDefault
 
85
                opacity: 0
 
86
            }
 
87
            PropertyChanges {
 
88
                target: imageFailed
 
89
                opacity: 1
 
90
            }
 
91
            PropertyChanges {
 
92
                target: cancelButton
 
93
                text: i18n.dtr("ubuntu-settings-components", "Back");
 
94
            }
 
95
            PropertyChanges {
 
96
                target: doneButton
 
97
                visible: false
 
98
            }
 
99
            StateChangeScript {
 
100
                script: statusLabel.setText(
 
101
                    i18n.dtr("ubuntu-settings-components",
 
102
                             "Sorry, the reader doesn’t seem to be working."),
 
103
                    true // No animation
 
104
                )
 
105
            }
 
106
            StateChangeScript {
 
107
                script: imageFailed.start()
 
108
            }
 
109
            PropertyChanges {
 
110
                target: directionContainer
 
111
                opacity: 0
 
112
            }
 
113
        },
 
114
        State {
 
115
            name: "done"
 
116
            PropertyChanges {
 
117
                target: imageDefault
 
118
                opacity: 0
 
119
            }
 
120
            PropertyChanges {
 
121
                target: imageDone
 
122
                opacity: 1
 
123
            }
 
124
            PropertyChanges {
 
125
                target: cancelButton
 
126
                visible: false
 
127
            }
 
128
            StateChangeScript {
 
129
                script: statusLabel.setText(
 
130
                    i18n.dtr("ubuntu-settings-components", "All done!"),
 
131
                    true // No animation
 
132
                )
 
133
            }
 
134
            PropertyChanges {
 
135
                target: doneButton
 
136
                enabled: true
 
137
                text: i18n.dtr("ubuntu-settings-components", "OK")
 
138
            }
 
139
            StateChangeScript {
 
140
                script: imageDone.start()
 
141
            }
 
142
            PropertyChanges {
 
143
                target: directionContainer
 
144
                opacity: 0
 
145
            }
 
146
        }
 
147
    ]
 
148
 
 
149
    header: PageHeader {
 
150
        visible: false
 
151
    }
 
152
 
 
153
    Item {
 
154
        anchors.fill: parent
 
155
 
 
156
        Item {
 
157
            id: fingerprintBox
 
158
            anchors.centerIn: parent
 
159
            width: units.gu(26)
 
160
            height: units.gu(29)
 
161
 
 
162
            Item {
 
163
                id: imageContainer
 
164
                anchors.centerIn: parent
 
165
                width: imageDefault.implicitWidth
 
166
                height: imageDefault.implicitHeight
 
167
 
 
168
                // Default image.
 
169
                FingerprintVisual {
 
170
                    id: imageDefault
 
171
                    objectName: "fingerprintDefaultVisual"
 
172
                    anchors.centerIn: parent
 
173
 
 
174
                    Behavior on opacity { UbuntuNumberAnimation {
 
175
                        duration: UbuntuAnimation.SlowDuration
 
176
                        easing: UbuntuAnimation.StandardEasing
 
177
                    }}
 
178
                }
 
179
 
 
180
                // Failed image.
 
181
                CircularSegment {
 
182
                    id: imageFailed
 
183
                    objectName: "fingerprintFailedVisual"
 
184
                    opacity: 0
 
185
                    color: "#ED3146"
 
186
                    width: directionContainer.width - units.dp(3)
 
187
 
 
188
                    anchors.centerIn: parent
 
189
 
 
190
                    function start () {
 
191
                        failAngstopAnim.start();
 
192
                        failThichAnim.start();
 
193
                    }
 
194
 
 
195
                    NumberAnimation on angleStop {
 
196
                        id: failAngstopAnim
 
197
                        running: false
 
198
                        from: 0
 
199
                        to: 360
 
200
                        duration: UbuntuAnimation.SlowDuration
 
201
                        easing: UbuntuAnimation.StandardEasing
 
202
                    }
 
203
 
 
204
                    NumberAnimation on thickness {
 
205
                        id: failThichAnim
 
206
                        running: false
 
207
                        from: 0
 
208
                        to: units.dp(3)
 
209
                        duration: UbuntuAnimation.SlowDuration
 
210
                        easing: UbuntuAnimation.StandardEasing
 
211
                    }
 
212
 
 
213
                    Icon {
 
214
                        name: "close"
 
215
                        color: "#ED3146"
 
216
                        width: units.gu(18)
 
217
                        anchors.centerIn: parent
 
218
                    }
 
219
 
 
220
                    Behavior on opacity { UbuntuNumberAnimation {
 
221
                        duration: UbuntuAnimation.SlowDuration
 
222
                        easing: UbuntuAnimation.StandardEasing
 
223
                    }}
 
224
                }
 
225
 
 
226
                // Done image.
 
227
                CircularSegment {
 
228
                    id: imageDone
 
229
                    objectName: "fingerprintDoneVisual"
 
230
                    opacity: 0
 
231
                    width: directionContainer.width - units.dp(3)
 
232
 
 
233
                    anchors.centerIn: parent
 
234
 
 
235
                    function start () {
 
236
                        angstopAnim.start();
 
237
                        thickAnim.start();
 
238
                    }
 
239
 
 
240
                    NumberAnimation on angleStop {
 
241
                        id: angstopAnim
 
242
                        running: false
 
243
                        from: 0
 
244
                        to: 360
 
245
                        duration: UbuntuAnimation.SlowDuration
 
246
                        easing: UbuntuAnimation.StandardEasing
 
247
                    }
 
248
 
 
249
                    NumberAnimation on thickness {
 
250
                        id: thickAnim
 
251
                        running: false
 
252
                        from: 0
 
253
                        to: units.dp(3)
 
254
                        duration: UbuntuAnimation.SlowDuration
 
255
                        easing: UbuntuAnimation.StandardEasing
 
256
                    }
 
257
 
 
258
                    Icon {
 
259
                        name: "tick"
 
260
                        color: "#3EB34F"
 
261
                        width: units.gu(18)
 
262
                        anchors.centerIn: parent
 
263
                    }
 
264
 
 
265
                    Behavior on opacity { UbuntuNumberAnimation {
 
266
                        duration: UbuntuAnimation.SlowDuration
 
267
                        easing: UbuntuAnimation.StandardEasing
 
268
                    }}
 
269
                }
 
270
 
 
271
                DirectionVisual {
 
272
                    id: directionContainer
 
273
                    objectName: "fingerprintDirectionVisual"
 
274
                    anchors.centerIn: parent
 
275
 
 
276
                    width: Math.sqrt(
 
277
                        imageContainer.width*imageContainer.width
 
278
                        + imageContainer.height*imageContainer.height
 
279
                    )
 
280
                    height: width
 
281
                }
 
282
            }
 
283
        }
 
284
 
 
285
        StatusLabel {
 
286
            id: statusLabel
 
287
            anchors {
 
288
                left: parent.left
 
289
                leftMargin: units.gu(2.9)
 
290
                right: parent.right
 
291
                rightMargin: units.gu(2.9)
 
292
                top: parent.top
 
293
                topMargin: units.gu(5)
 
294
            }
 
295
            initialText: i18n.dtr("ubuntu-settings-components",
 
296
                                  "Swipe your finger over the reader.")
 
297
            objectName: "fingerprintStatusLabel"
 
298
        }
 
299
 
 
300
 
 
301
        Label {
 
302
            id: progressLabel
 
303
            objectName: "fingerprintProgressLabel"
 
304
            property int progress: 0
 
305
            anchors {
 
306
                top: fingerprintBox.bottom
 
307
                topMargin: units.gu(1.5)
 
308
                horizontalCenter: parent.horizontalCenter
 
309
            }
 
310
            text: i18n.dtr("ubuntu-settings-components", "%1%").arg((progress).toFixed());
 
311
            opacity: 0
 
312
            horizontalAlignment: Text.AlignHCenter
 
313
            fontSize: "large"
 
314
            color: theme.palette.normal.backgroundTertiaryText
 
315
 
 
316
            Behavior on opacity { UbuntuNumberAnimation {} }
 
317
            Behavior on progress {
 
318
                NumberAnimation {
 
319
                    duration: UbuntuAnimation.SlowDuration
 
320
                    easing: UbuntuAnimation.StandardEasing
 
321
                }
 
322
            }
 
323
        }
 
324
 
 
325
        Rectangle {
 
326
            id: actions
 
327
 
 
328
            anchors {
 
329
                left: parent.left
 
330
                right: parent.right
 
331
                bottom: parent.bottom
 
332
            }
 
333
 
 
334
            // Color and height values are copied from the Wizard.
 
335
            color: "#f5f5f5"
 
336
            height: units.gu(5)
 
337
 
 
338
            AbstractButton {
 
339
                id: cancelButton
 
340
                property alias text: cancelButtonText.text
 
341
                objectName: "fingerprintSetupCancelButton"
 
342
                anchors {
 
343
                    left: parent.left
 
344
                    leftMargin: units.gu(3)
 
345
                    verticalCenter: parent.verticalCenter
 
346
                }
 
347
                height: parent.height
 
348
                width: units.gu(10)
 
349
                onClicked: {
 
350
                    root.cancel();
 
351
                    pageStack.pop();
 
352
                }
 
353
 
 
354
                Label {
 
355
                    id: cancelButtonText
 
356
                    anchors.verticalCenter: parent.verticalCenter
 
357
                    text: i18n.dtr("ubuntu-settings-components", "Cancel")
 
358
                }
 
359
            }
 
360
 
 
361
            AbstractButton {
 
362
                id: doneButton
 
363
                property alias text: doneButtonText.text
 
364
                objectName: "fingerprintSetupDoneButton"
 
365
                anchors {
 
366
                    right: parent.right
 
367
                    rightMargin: units.gu(3)
 
368
                    verticalCenter: parent.verticalCenter
 
369
                }
 
370
                enabled: false
 
371
                height: parent.height
 
372
                width: units.gu(10)
 
373
                onClicked: pageStack.pop()
 
374
 
 
375
                Label {
 
376
                    id: doneButtonText
 
377
                    anchors {
 
378
                        verticalCenter: parent.verticalCenter
 
379
                        right: parent.right
 
380
                    }
 
381
                    font.bold: parent.enabled
 
382
                    text: i18n.dtr("ubuntu-settings-components", "Next")
 
383
                }
 
384
            }
 
385
        }
 
386
    }
 
387
}