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
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 modelText: model.text
71 readonly property var modelType: model.type
72 readonly property var modelIndex: model.index
74 sourceComponent: isLabel ? infoLabel : greeterPrompt
79 for (var i = 0; i < repeater.count; i++) {
80 var item = repeater.itemAt(i);
81 if (item && !item.isLabel) {
86 loader.item.opacity = 1;
96 objectName: "infoLabel" + modelIndex
99 readonly property bool isPrompt: false
101 color: modelType === LightDMService.prompts.Message ? theme.palette.normal.raisedSecondaryText
102 : theme.palette.normal.negative
104 textFormat: Text.PlainText
107 visible: modelType === LightDMService.prompts.Message
109 Behavior on opacity { UbuntuNumberAnimation {} }
118 objectName: "greeterPrompt" + modelIndex
121 property bool isAlphanumeric: modelText !== "" || root.alphanumeric
123 interactive: root.interactive
124 isPrompt: modelType !== LightDMService.prompts.Button
125 isSecret: modelType === LightDMService.prompts.Secret
126 isPinPrompt: isPrompt && !isAlphanumeric && isSecret
127 loginError: root.loginError
128 hasKeyboard: root.hasKeyboard
129 text: modelText ? modelText : (isAlphanumeric ? i18n.tr("Passphrase") : i18n.tr("Passcode"))
131 onClicked: root.clicked()
133 // If there is another GreeterPrompt, focus it.
134 for (var i = modelIndex + 1; i < repeater.count; i++) {
135 var item = repeater.itemAt(i).item;
137 item.forceActiveFocus();
142 // Nope we're the last one; just send our response.
145 onCanceled: root.canceled()
147 Behavior on opacity { UbuntuNumberAnimation {} }