on abbcda4 help sign in
unity8/qml/Components/PassphraseLockscreen.qml
95 lines 2.8 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 placeholderText
26 property string wrongPlaceholderText
27 property string username: ""
29 signal entered(string passphrase)
30 signal cancel()
32 function clear(playAnimation) {
33 pinentryField.text = "";
34 pinentryField.enabled = true
35 if (playAnimation) {
36 wrongPasswordAnimation.start();
37 pinentryField.forceActiveFocus();
38 } else {
39 pinentryField.focus = false
40 }
41 }
43 Rectangle {
44 id: highlightItem
45 width: units.gu(32)
46 height: units.gu(10)
47 anchors.centerIn: parent
48 color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
49 border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
50 border.width: units.dp(1)
51 radius: units.gu(1.5)
52 antialiasing: true
54 Label {
55 objectName: "greeterLabel"
56 anchors {
57 left: parent.left
58 top: parent.top
59 right: parent.right
60 margins: units.gu(1.5)
61 }
62 text: root.username.length > 0 ? i18n.tr("Hello %1").arg(root.username) : i18n.tr("Hello")
63 color: "white"
64 }
66 TextField {
67 id: pinentryField
68 objectName: "pinentryField"
69 anchors {
70 horizontalCenter: parent.horizontalCenter
71 bottom: parent.bottom
72 margins: units.gu(1)
73 }
74 height: units.gu(4.5)
75 width: parent.width - units.gu(2)
76 echoMode: TextInput.Password
77 opacity: 0.9
78 hasClearButton: false
79 placeholderText: wrongPasswordAnimation.running ? root.wrongPlaceholderText : root.placeholderText
81 onAccepted: {
82 if (pinentryField.text) {
83 pinentryField.enabled = false;
84 root.entered(pinentryField.text);
85 }
86 }
87 }
88 }
90 WrongPasswordAnimation {
91 id: wrongPasswordAnimation
92 objectName: "wrongPasswordAnimation"
93 target: pinentryField
94 }