Lomiri
Loading...
Searching...
No Matches
GreeterPrompt.qml
1/*
2 * Copyright (C) 2016 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 */
16
17import QtQuick 2.15
18import QtQml 2.15
19import Lomiri.Components 1.3
20import GSettings 1.0
21import "../Components"
22
23FocusScope {
24 id: root
25 implicitHeight: units.gu(5)
26 focus: true
27
28 property bool isPrompt
29 property bool isPinPrompt
30 property string text
31 property bool isSecret
32 property bool interactive: true
33 property bool loginError: false
34 readonly property string enteredText: loader.item ? loader.item.enteredText : ""
35 property bool hasKeyboard: false
36 property bool waitingToAccept: false
37 property string pinCodeManager: "PinPrompt.qml"
38
39 signal clicked()
40 signal canceled()
41 signal accepted()
42
43 GSettings {
44 id: lomiriSettings
45 schema.id: "com.lomiri.Shell"
46 }
47
48 onEnteredTextChanged: if (waitingToAccept) root.accepted()
49
50 function showFakePassword() {
51 // Just a silly hack for looking like 4 pin numbers got entered, if
52 // a fingerprint was used and we happen to be using a pin. This was
53 // a request from Design.
54 if (isSecret) {
55 loader.item.enteredText = "...."; // actual text doesn't matter
56 }
57 }
58
59 Loader {
60 id: loader
61 objectName: "promptLoader"
62
63 focus: true
64
65 anchors.fill: parent
66
67 Connections {
68 target: loader.item
69 function onClicked() { root.clicked() }
70 function onCanceled() { root.canceled() }
71 function onAccepted(response) {
72 if (response == root.enteredText)
73 root.accepted();
74 else
75 root.waitingToAccept = true;
76 }
77 }
78
79 Binding {
80 target: loader.item
81 property: "text"
82 value: root.text
83 }
84
85 Binding {
86 target: loader.item
87 property: "isSecret"
88 value: root.isSecret
89 }
90
91 Binding {
92 target: loader.item
93 property: "interactive"
94 value: root.interactive
95 }
96
97 Binding {
98 target: loader.item
99 property: "loginError"
100 value: root.loginError
101 }
102
103 Binding {
104 target: loader.item
105 property: "hasKeyboard"
106 value: root.hasKeyboard
107 }
108
109 onLoaded: loader.item.focus = true
110 }
111
112 states: [
113 State {
114 name: "ButtonPrompt"
115 when: !root.isPrompt
116 PropertyChanges { target: loader; source: "ButtonPrompt.qml" }
117 },
118 State {
119 name: "PinPrompt"
120 when: root.isPinPrompt
121 PropertyChanges { target: loader; source: root.pinCodeManager }
122 },
123 State {
124 name: "TextPrompt"
125 when: !root.isPinPrompt
126 PropertyChanges { target: loader; source: "TextPrompt.qml" }
127 }
128 ]
129}