~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/Fingerprint.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
import Ubuntu.Components.Popups 1.3
 
22
import Ubuntu.Components.Themes.Ambiance 1.3
 
23
 
 
24
Page {
 
25
    id: root
 
26
    property string name
 
27
    property string templateId
 
28
 
 
29
    signal requestDeletion(string templateId)
 
30
    signal requestRename(string templateId, string name)
 
31
 
 
32
    function deletionFailed() {
 
33
        PopupUtils.open(deletionFailed);
 
34
        state = "";
 
35
    }
 
36
 
 
37
    header: PageHeader {
 
38
        objectName: "templateHeader"
 
39
        title: nameInput.text.length > 0 ? nameInput.text : name
 
40
        flickable: flickable
 
41
    }
 
42
 
 
43
    states: [
 
44
        State {
 
45
            name: "deleting"
 
46
            PropertyChanges {
 
47
                target: nameInput
 
48
                enabled: false
 
49
            }
 
50
            PropertyChanges {
 
51
                target: deleteButton
 
52
                enabled: false
 
53
            }
 
54
        }
 
55
    ]
 
56
 
 
57
    Flickable {
 
58
        id: flickable
 
59
        anchors {
 
60
            fill: parent
 
61
            topMargin: units.gu(2)
 
62
        }
 
63
        boundsBehavior: (contentHeight > root.height) ?
 
64
                         Flickable.DragAndOvershootBounds :
 
65
                         Flickable.StopAtBounds
 
66
        contentHeight: contentItem.childrenRect.height
 
67
 
 
68
        Column {
 
69
            spacing: units.gu(2)
 
70
            anchors {
 
71
                left: parent.left
 
72
                right: parent.right
 
73
                margins: units.gu(3)
 
74
            }
 
75
 
 
76
            Label {
 
77
                id: nameLabel
 
78
                anchors.left: parent.left
 
79
                anchors.right: parent.right
 
80
                text: i18n.dtr("ubuntu-settings-components", "Fingerprint Name")
 
81
                font.weight: Font.Light
 
82
            }
 
83
 
 
84
            TextField {
 
85
                id: nameInput
 
86
                objectName: "nameInput"
 
87
                anchors.left: parent.left
 
88
                anchors.right: parent.right
 
89
                inputMethodHints: Qt.ImhNoPredictiveText
 
90
                style: TextFieldStyle {}
 
91
                text: name
 
92
                onTextChanged: {
 
93
                    if (text)
 
94
                        requestRename(templateId, text)
 
95
                }
 
96
                onAccepted: {
 
97
                    if (text) {
 
98
                        requestRename(templateId, text);
 
99
                        pageStack.pop();
 
100
                    }
 
101
                }
 
102
            }
 
103
 
 
104
            Button {
 
105
                id: deleteButton
 
106
                objectName: "templateDelete"
 
107
                text: i18n.dtr("ubuntu-settings-components", "Delete Fingerprint")
 
108
                onClicked: {
 
109
                    root.state = "deleting";
 
110
                    requestDeletion(templateId)
 
111
                }
 
112
                width: parent.width
 
113
            }
 
114
        }
 
115
    }
 
116
 
 
117
    Component {
 
118
        id: deletionFailed
 
119
 
 
120
        Dialog {
 
121
            id: deletionFailedDialog
 
122
            objectName: "fingerprintDeletionFailedDialog"
 
123
            text: i18n.dtr("ubuntu-settings-components",
 
124
                           "Sorry, the fingerprint could not be deleted.")
 
125
 
 
126
            Button {
 
127
                objectName: "fingerprintDeleteionFailedOk"
 
128
                onClicked: PopupUtils.close(deletionFailedDialog)
 
129
                text: i18n.dtr("ubuntu-settings-components", "OK")
 
130
            }
 
131
        }
 
132
    }
 
133
}