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 Ubuntu.Components 1.3
19 import "../Components"
24 height: childrenRect.height
26 property bool alphanumeric: true
27 property bool interactive: true
29 signal responded(string text)
33 function showFakePassword() {
34 for (var i = 0; i < repeater.count; i++) {
35 var item = repeater.itemAt(i).item;
37 item.showFakePassword();
45 function sendResponse() {
46 for (var i = 0; i < repeater.count; i++) {
47 var item = repeater.itemAt(i).item;
49 root.responded(item.enteredText);
57 spacing: units.gu(0.5)
61 model: LightDMService.prompts
66 readonly property bool isLabel: model.type == LightDMService.prompts.Message ||
67 model.type == LightDMService.prompts.Error
68 readonly property var modelData: model
70 sourceComponent: isLabel ? infoLabel : greeterPrompt
73 for (var i = 0; i < repeater.count; i++) {
74 var item = repeater.itemAt(i);
75 if (item && !item.isLabel) {
80 loader.item.opacity = 1;
86 value: loader.modelData
96 objectName: "infoLabel" + model.index
100 readonly property bool isPrompt: false
102 color: model.type === LightDMService.prompts.Message ? theme.palette.normal.raisedText
103 : theme.palette.normal.negative
105 textFormat: Text.PlainText
108 Behavior on opacity { UbuntuNumberAnimation {} }
117 objectName: "greeterPrompt" + model.index
122 interactive: root.interactive
123 isAlphanumeric: model.text !== "" || root.alphanumeric
124 isPrompt: model.type !== LightDMService.prompts.Button
125 isSecret: model.type === LightDMService.prompts.Secret
126 text: model.text ? model.text : (isAlphanumeric ? i18n.tr("Passphrase") : i18n.tr("Passcode"))
128 onClicked: root.clicked()
130 // If there is another GreeterPrompt, focus it.
131 for (var i = model.index + 1; i < repeater.count; i++) {
132 var item = repeater.itemAt(i).item;
134 item.forceActiveFocus();
139 // Nope we're the last one; just send our response.
142 onCanceled: root.canceled()
144 Behavior on opacity { UbuntuNumberAnimation {} }