Unity 8
 All Classes Functions Properties
PassphraseLockscreen.qml
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  */
16 
17 import QtQuick 2.0
18 import Ubuntu.Components 0.1
19 import "../Components"
20 
21 Item {
22  id: root
23  height: highlightItem.height
24 
25  property string placeholderText
26  property string wrongPlaceholderText
27  property string username: ""
28 
29  signal entered(string passphrase)
30  signal cancel()
31 
32  function clear(playAnimation) {
33  pinentryField.text = "";
34  if (playAnimation) {
35  wrongPasswordAnimation.start();
36  } else {
37  pinentryField.focus = false
38  }
39  }
40 
41  Rectangle {
42  id: highlightItem
43  width: units.gu(32)
44  height: units.gu(10)
45  anchors.centerIn: parent
46  color: Qt.rgba(0.1, 0.1, 0.1, 0.4)
47  border.color: Qt.rgba(0.4, 0.4, 0.4, 0.4)
48  border.width: units.dp(1)
49  radius: units.gu(1.5)
50  antialiasing: true
51 
52  Label {
53  objectName: "greeterLabel"
54  anchors {
55  left: parent.left
56  top: parent.top
57  right: parent.right
58  margins: units.gu(1.5)
59  }
60  text: root.username.length > 0 ? i18n.tr("Hello %1").arg(root.username) : i18n.tr("Hello")
61  color: "white"
62  }
63 
64  TextField {
65  id: pinentryField
66  objectName: "pinentryField"
67  anchors {
68  horizontalCenter: parent.horizontalCenter
69  bottom: parent.bottom
70  margins: units.gu(1)
71  }
72  height: units.gu(4.5)
73  width: parent.width - units.gu(2)
74  echoMode: TextInput.Password
75  opacity: 0.9
76  hasClearButton: false
77  placeholderText: wrongPasswordAnimation.running ? root.wrongPlaceholderText : root.placeholderText
78 
79  onAccepted: {
80  if (pinentryField.text) {
81  root.entered(pinentryField.text);
82  }
83  }
84  }
85  }
86 
87  WrongPasswordAnimation {
88  id: wrongPasswordAnimation
89  objectName: "wrongPasswordAnimation"
90  target: pinentryField
91  }
92 }