on b44b2f0 help sign in
unity8/Greeter/Lockscreen.qml
149 lines 4.0 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"
20import LightDM 0.1 as LightDM
22Showable {
23 id: root
25 // Determine if a numeric or alphanumeric pad is used.
26 property bool alphaNumeric: false
28 // Placeholder text
29 property string placeholderText: ""
31 // In case the Lockscreen can show a greeter message, this is the username
32 property string username: ""
34 // As the numeric PIN pad doesn't have a OK button by design, we need to auto-confirm on a certain length.
35 // This is ignored by the alphaNumeric lockscreen as that one is confirmed with pressing enter on the OSK.
36 property int pinLength: 4
38 property url background: ""
40 signal unlocked()
41 signal cancel()
42 signal emergencyCall()
44 function reset() {
45 pinPadLoader.resetting = true;
46 pinPadLoader.resetting = false;
47 }
49 Image {
50 anchors.fill: parent
51 source: root.required ? root.background : ""
52 }
54 MouseArea {
55 anchors.fill: root
56 }
58 Loader {
59 id: pinPadLoader
60 objectName: "pinPadLoader"
61 anchors {
62 left: parent.left
63 right: parent.right
64 verticalCenter: parent.verticalCenter
65 verticalCenterOffset: root.alphaNumeric ? -units.gu(10) : 0
66 }
67 property bool resetting: false
69 source: (!resetting && root.required) ? (root.alphaNumeric ? "PassphraseLockscreen.qml" : "PinLockscreen.qml") : ""
71 Connections {
72 target: pinPadLoader.item
74 onEntered: {
75 LightDM.Greeter.respond(passphrase);
76 }
78 onCancel: {
79 root.cancel()
80 }
81 }
83 Binding {
84 target: pinPadLoader.item
85 property: "pinLength"
86 value: root.pinLength
87 }
88 Binding {
89 target: pinPadLoader.item
90 property: "placeholderText"
91 value: root.placeholderText
92 }
93 Binding {
94 target: pinPadLoader.item
95 property: "username"
96 value: root.username
97 }
98 }
100 Column {
101 anchors {
102 left: parent.left
103 top: pinPadLoader.bottom
104 topMargin: units.gu(4)
105 right: parent.right
106 bottom: parent.bottom
107 }
108 spacing: units.gu(1)
110 Icon {
111 objectName: "emergencyCallIcon"
112 height: units.gu(3)
113 width: height
114 anchors.horizontalCenter: parent.horizontalCenter
115 name: "phone-app-call-symbolic"
116 color: "white"
117 opacity: 0.9
119 MouseArea {
120 anchors.fill: parent
121 onClicked: root.emergencyCall()
122 }
123 }
125 Label {
126 text: i18n.tr("Emergency call")
127 color: "white"
128 opacity: 0.9
129 fontSize: "medium"
130 anchors.horizontalCenter: parent.horizontalCenter
131 }
132 }
134 Connections {
135 target: LightDM.Greeter
137 onAuthenticationComplete: {
138 if (LightDM.Greeter.promptless) {
139 return;
140 }
141 if (LightDM.Greeter.authenticated) {
142 root.unlocked();
143 pinPadLoader.item.clear(false);
144 } else {
145 pinPadLoader.item.clear(true);
146 }
147 }
148 }