on 7cd287d help sign in
unity8/Greeter/Lockscreen.qml
156 lines 4.3 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"
21Showable {
22 id: root
24 // Determine if a numeric or alphanumeric pad is used.
25 property bool alphaNumeric: false
27 // Placeholder text
28 property string placeholderText: ""
30 // In case the Lockscreen can show a greeter message, this is the username
31 property string username: ""
33 // As the numeric PIN pad doesn't have a OK button by design, we need to auto-confirm on a certain length.
34 // This is ignored by the alphaNumeric lockscreen as that one is confirmed with pressing enter on the OSK.
35 property int pinLength: 4
37 property url background: ""
39 signal entered(string passphrase)
40 signal cancel()
41 signal emergencyCall()
43 onRequiredChanged: {
44 if (required && pinPadLoader.item) {
45 pinPadLoader.item.clear(false);
46 }
47 }
49 function reset() {
50 // This causes the loader below to destry and recreate the source
51 pinPadLoader.resetting = true;
52 pinPadLoader.resetting = false;
53 }
55 function clear(showAnimation) {
56 pinPadLoader.item.clear(showAnimation);
57 }
59 Rectangle {
60 // In case background fails to load or is undefined
61 id: backgroundBackup
62 anchors.fill: parent
63 color: "black"
64 }
66 Image {
67 id: backgroundImage
68 objectName: "lockscreenBackground"
69 anchors {
70 fill: parent
71 topMargin: backgroundTopMargin
72 }
73 source: root.required ? root.background : ""
74 fillMode: Image.PreserveAspectCrop
75 }
77 MouseArea {
78 anchors.fill: root
79 }
81 Loader {
82 id: pinPadLoader
83 objectName: "pinPadLoader"
84 anchors {
85 left: parent.left
86 right: parent.right
87 verticalCenter: parent.verticalCenter
88 verticalCenterOffset: root.alphaNumeric ? -units.gu(10) : -units.gu(4)
89 }
90 property bool resetting: false
92 source: (!resetting && root.required) ? (root.alphaNumeric ? "PassphraseLockscreen.qml" : "PinLockscreen.qml") : ""
94 Connections {
95 target: pinPadLoader.item
97 onEntered: {
98 root.entered(passphrase);
99 }
101 onCancel: {
102 root.cancel()
103 }
104 }
106 Binding {
107 target: pinPadLoader.item
108 property: "pinLength"
109 value: root.pinLength
110 }
111 Binding {
112 target: pinPadLoader.item
113 property: "placeholderText"
114 value: root.placeholderText
115 }
116 Binding {
117 target: pinPadLoader.item
118 property: "username"
119 value: root.username
120 }
121 }
123 Column {
124 anchors {
125 left: parent.left
126 bottom: parent.bottom
127 bottomMargin: units.gu(4)
128 right: parent.right
129 }
130 height: childrenRect.height
131 spacing: units.gu(1)
133 Icon {
134 objectName: "emergencyCallIcon"
135 height: units.gu(3)
136 width: height
137 anchors.horizontalCenter: parent.horizontalCenter
138 name: "phone-app-call-symbolic"
139 color: "#f3f3e7"
140 opacity: 0.6
142 MouseArea {
143 anchors.fill: parent
144 onClicked: root.emergencyCall()
145 }
146 }
148 Label {
149 text: i18n.tr("Emergency Call")
150 color: "#f3f3e7"
151 opacity: 0.6
152 fontSize: "medium"
153 anchors.horizontalCenter: parent.horizontalCenter
154 }
155 }