2 * Copyright (C) 2017 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/>.
18 import Lomiri.Components 1.3
19 import "../Components"
24 height: childrenRect.height
26 property bool alphanumeric: true
27 property bool interactive: true
28 property bool loginError: false
29 property bool hasKeyboard: false
31 signal responded(string text)
35 function showFakePassword() {
36 for (var i = 0; i < repeater.count; i++) {
37 var item = repeater.itemAt(i).item;
39 item.showFakePassword();
47 function sendResponse() {
48 for (var i = 0; i < repeater.count; i++) {
49 var item = repeater.itemAt(i).item;
51 root.responded(item.enteredText);
59 spacing: units.gu(0.5)
63 model: LightDMService.prompts
68 readonly property bool isLabel: model.type == LightDMService.prompts.Message ||
69 model.type == LightDMService.prompts.Error
70 readonly property var modelData: model
72 sourceComponent: isLabel ? infoLabel : greeterPrompt
75 for (var i = 0; i < repeater.count; i++) {
76 var item = repeater.itemAt(i);
77 if (item && !item.isLabel) {
82 loader.item.opacity = 1;
88 value: loader.modelData
98 objectName: "infoLabel" + model.index
102 readonly property bool isPrompt: false
104 color: model.type === LightDMService.prompts.Message ? theme.palette.normal.raisedSecondaryText
105 : theme.palette.normal.negative
107 textFormat: Text.PlainText
110 visible: model.type === LightDMService.prompts.Message
112 Behavior on opacity { LomiriNumberAnimation {} }
121 objectName: "greeterPrompt" + model.index
126 interactive: root.interactive
127 isAlphanumeric: model.text !== "" || root.alphanumeric
128 isPrompt: model.type !== LightDMService.prompts.Button
129 isSecret: model.type === LightDMService.prompts.Secret
130 loginError: root.loginError
131 hasKeyboard: root.hasKeyboard
132 text: model.text ? model.text : (isAlphanumeric ? i18n.tr("Passphrase") : i18n.tr("Passcode"))
134 onClicked: root.clicked()
136 // If there is another GreeterPrompt, focus it.
137 for (var i = model.index + 1; i < repeater.count; i++) {
138 var item = repeater.itemAt(i).item;
140 item.forceActiveFocus();
145 // Nope we're the last one; just send our response.
148 onCanceled: root.canceled()
150 Behavior on opacity { LomiriNumberAnimation {} }