~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-yakkety-1895

« back to all changes in this revision

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

  • Committer: Bileto Bot
  • Date: 2016-06-20 14:01:03 UTC
  • mfrom: (103.6.69 fingerprint)
  • Revision ID: ci-train-bot@canonical.com-20160620140103-q57lulbze89e6yyd
jonas-drange
* Add components for Fingerprint management.

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 QtQuick 2.4
 
20
import Ubuntu.Components 1.3
 
21
 
 
22
Item {
 
23
    id: root
 
24
 
 
25
    property string initialText
 
26
    property int origX: 0
 
27
    readonly property alias text: label.text
 
28
 
 
29
    signal slideStarted()
 
30
    signal slideCompleted()
 
31
 
 
32
    Component.onCompleted: origX = label.x
 
33
 
 
34
    function setText(text, noAnimation) {
 
35
        if (noAnimation === true) {
 
36
            label.text = text;
 
37
            return;
 
38
        }
 
39
 
 
40
        function outStoppedHandler () {
 
41
            label.text = text;
 
42
            label.x = units.gu(50)
 
43
            inAnim.start();
 
44
            outAnim.stopped.disconnect(outStoppedHandler);
 
45
        }
 
46
        outAnim.stopped.connect(outStoppedHandler);
 
47
        outAnim.start();
 
48
    }
 
49
 
 
50
    Label {
 
51
        id: label
 
52
 
 
53
        font.pixelSize: units.gu(3.3)
 
54
        horizontalAlignment: Text.AlignLeft
 
55
        height: units.gu(4)
 
56
        text: initialText
 
57
        width: parent.width
 
58
        wrapMode: Text.WordWrap
 
59
    }
 
60
 
 
61
    NumberAnimation {
 
62
        id: outAnim
 
63
 
 
64
        alwaysRunToEnd: true
 
65
        duration: UbuntuAnimation.FastDuration
 
66
        easing: UbuntuAnimation.StandardEasing
 
67
        onStarted: root.slideStarted()
 
68
        property: "x"
 
69
        target: label
 
70
        to: -units.gu(50)
 
71
    }
 
72
 
 
73
    NumberAnimation {
 
74
        id: inAnim
 
75
 
 
76
        alwaysRunToEnd: true
 
77
        duration: UbuntuAnimation.FastDuration
 
78
        easing: UbuntuAnimation.StandardEasing
 
79
        onStopped: root.slideCompleted()
 
80
        property: "x"
 
81
        target: label
 
82
        to: root.origX
 
83
    }
 
84
}