on 6231502 help sign in
unity8/qml/Components/PassphraseLockscreen.qml
94 lines 2.7 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../Components"
21Item {
22 id: root
23 height: highlightItem.height
25 property string infoText
26 property string username: ""
27 property bool entryEnabled: true
29 signal entered(string passphrase)
30 signal cancel()
32 function clear(playAnimation) {
33 pinentryField.text = "";
34 if (playAnimation) {
35 wrongPasswordAnimation.start();
36 pinentryField.forceActiveFocus();
37 } else {
38 pinentryField.focus = false
39 }
40 }
42 Rectangle {
43 id: highlightItem
44 width: units.gu(32)
45 height: units.gu(10)
46 anchors.centerIn: parent
47 color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
48 border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
49 border.width: units.dp(1)
50 radius: units.gu(1.5)
51 antialiasing: true
53 Label {
54 objectName: "greeterLabel"
55 anchors {
56 left: parent.left
57 top: parent.top
58 right: parent.right
59 margins: units.gu(1.5)
60 }
61 text: root.username.length > 0 ? i18n.tr("Hello %1").arg(root.username) : i18n.tr("Hello")
62 color: "white"
63 }
65 TextField {
66 id: pinentryField
67 objectName: "pinentryField"
68 anchors {
69 horizontalCenter: parent.horizontalCenter
70 bottom: parent.bottom
71 margins: units.gu(1)
72 }
73 height: units.gu(4.5)
74 width: parent.width - units.gu(2)
75 echoMode: TextInput.Password
76 opacity: 0.9
77 hasClearButton: false
78 enabled: root.entryEnabled
79 placeholderText: root.infoText
81 onAccepted: {
82 if (pinentryField.text) {
83 root.entered(pinentryField.text);
84 }
85 }
86 }
87 }
89 WrongPasswordAnimation {
90 id: wrongPasswordAnimation
91 objectName: "wrongPasswordAnimation"
92 target: pinentryField
93 }