2 * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18import Ubuntu.Components 1.0
19import Ubuntu.Components.Popups 1.0
24 // Determine if a numeric or alphanumeric pad is used.
25 property bool alphaNumeric: false
27 // Whether to show an emergency call button
28 property bool showEmergencyCallButton: true
30 // Whether to show a cancel button (not all lockscreen types normally do anyway)
31 property bool showCancelButton: true
33 // Informational text. (e.g. some text to tell which domain this is pin is entered for)
34 property string infoText: ""
36 // Retries text (e.g. 3 retries left)
37 property string retryText: ""
39 // The text to be displayed in case the login failed
40 property string errorText: ""
42 // In case the Lockscreen can show a greeter message, this is the username
43 property string username: ""
45 // Set those to a value greater 0 to restrict the pin length.
46 // If both are unset, the Lockscreen will show a confirm button and allow typing any length of pin before
47 // confirming. If minPinLength is set to a value > 0, the confirm button will only become active when the
48 // entered pin is at least that long. If maxPinLength is set, the lockscreen won't allow entering any
49 // more numbers than that. If both are set to the same value, the lockscreen will enter auto confirming
50 // behavior, hiding the confirmation button and triggering that automatically when the entered pin reached
51 // that length. This is ignored by the alphaNumeric lockscreen as that one is always confirmed by pressing
53 property int minPinLength: -1
54 property int maxPinLength: -1
56 property url background: ""
58 signal entered(string passphrase)
60 signal emergencyCall()
61 signal infoPopupConfirmed()
64 if (required && pinPadLoader.item) {
69 function forceDelay(delay) {
70 forcedDelayTimer.interval = delay
71 forcedDelayTimer.start()
75 // This causes the loader below to destry and recreate the source
76 pinPadLoader.resetting = true;
77 pinPadLoader.resetting = false;
80 function clear(showAnimation) {
81 if (pinPadLoader.item) {
82 pinPadLoader.item.clear(showAnimation);
84 pinPadLoader.showWrongText = showAnimation
85 pinPadLoader.waiting = false
88 function showInfoPopup(title, text) {
89 PopupUtils.open(infoPopupComponent, root, {title: title, text: text})
94 onTriggered: pinPadLoader.showWrongText = false
98 // In case background fails to load
102 visible: root.background.toString() !== ""
107 objectName: "lockscreenBackground"
111 source: root.required ? root.background : ""
112 fillMode: Image.PreserveAspectCrop
121 objectName: "pinPadLoader"
125 verticalCenter: parent.verticalCenter
126 verticalCenterOffset: root.alphaNumeric ? -units.gu(10) : 0
128 property bool resetting: false
129 property bool waiting: false
130 property bool showWrongText: false
132 source: (!resetting && root.required) ? (root.alphaNumeric ? "PassphraseLockscreen.qml" : "PinLockscreen.qml") : ""
135 showWrongText = false
138 if (forcedDelayTimer.running) {
139 pinPadLoader.item.clear(true)
144 target: pinPadLoader.item
147 pinPadLoader.waiting = true
148 root.entered(passphrase);
157 target: pinPadLoader.item
158 property: "minPinLength"
159 value: root.minPinLength
162 target: pinPadLoader.item
163 property: "maxPinLength"
164 value: root.maxPinLength
167 target: pinPadLoader.item
172 target: pinPadLoader.item
173 property: "retryText"
174 value: forcedDelayTimer.running ? i18n.tr("Please wait") : root.retryText
177 target: pinPadLoader.item
178 property: "errorText"
179 value: forcedDelayTimer.running ? i18n.tr("Too many incorrect attempts") :
180 (pinPadLoader.showWrongText ? root.errorText : "")
183 target: pinPadLoader.item
188 target: pinPadLoader.item
189 property: "entryEnabled"
190 value: !pinPadLoader.waiting && !forcedDelayTimer.running
193 target: pinPadLoader.item
194 property: "showCancelButton"
195 value: root.showCancelButton
200 id: emergencyCallLabel
201 objectName: "emergencyCallLabel"
203 visible: showEmergencyCallButton
206 bottom: parent.bottom
207 bottomMargin: units.gu(4)
208 horizontalCenter: parent.horizontalCenter
211 text: i18n.tr("Emergency Call")
217 anchors.fill: emergencyCallLabel
218 onClicked: root.emergencyCall()
219 enabled: emergencyCallLabel.visible
223 id: infoPopupComponent
226 objectName: "infoPopup"
230 objectName: "infoPopupOkButton"
233 PopupUtils.close(dialog)
234 root.infoPopupConfirmed();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list