on f2c2cdb help sign in
unity8/Greeter/Lockscreen.qml
155 lines 4.2 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 onRequiredChanged: {
45 if (required && pinPadLoader.item) {
46 pinPadLoader.item.clear(false);
47 }
48 }
50 function reset() {
51 // This causes the loader below to destry and recreate the source
52 pinPadLoader.resetting = true;
53 pinPadLoader.resetting = false;
54 }
56 Image {
57 anchors.fill: parent
58 source: root.required ? root.background : ""
59 }
61 MouseArea {
62 anchors.fill: root
63 }
65 Loader {
66 id: pinPadLoader
67 objectName: "pinPadLoader"
68 anchors {
69 left: parent.left
70 right: parent.right
71 verticalCenter: parent.verticalCenter
72 verticalCenterOffset: root.alphaNumeric ? -units.gu(10) : 0
73 }
74 property bool resetting: false
76 source: (!resetting && root.required) ? (root.alphaNumeric ? "PassphraseLockscreen.qml" : "PinLockscreen.qml") : ""
78 Connections {
79 target: pinPadLoader.item
81 onEntered: {
82 LightDM.Greeter.respond(passphrase);
83 }
85 onCancel: {
86 root.cancel()
87 }
88 }
90 Binding {
91 target: pinPadLoader.item
92 property: "pinLength"
93 value: root.pinLength
94 }
95 Binding {
96 target: pinPadLoader.item
97 property: "placeholderText"
98 value: root.placeholderText
99 }
100 Binding {
101 target: pinPadLoader.item
102 property: "username"
103 value: root.username
104 }
105 }
107 Column {
108 anchors {
109 left: parent.left
110 top: pinPadLoader.bottom
111 topMargin: units.gu(4)
112 right: parent.right
113 bottom: parent.bottom
114 }
115 spacing: units.gu(1)
117 Icon {
118 objectName: "emergencyCallIcon"
119 height: units.gu(3)
120 width: height
121 anchors.horizontalCenter: parent.horizontalCenter
122 name: "phone-app-call-symbolic"
123 color: "white"
124 opacity: 0.9
126 MouseArea {
127 anchors.fill: parent
128 onClicked: root.emergencyCall()
129 }
130 }
132 Label {
133 text: i18n.tr("Emergency call")
134 color: "white"
135 opacity: 0.9
136 fontSize: "medium"
137 anchors.horizontalCenter: parent.horizontalCenter
138 }
139 }
141 Connections {
142 target: LightDM.Greeter
144 onAuthenticationComplete: {
145 if (LightDM.Greeter.promptless) {
146 return;
147 }
148 if (LightDM.Greeter.authenticated) {
149 root.unlocked();
150 } else {
151 pinPadLoader.item.clear(true);
152 }
153 }
154 }