on bedf8bc help sign in
unity8/qml/Greeter/WideView.qml
142 lines 4.1 kB history raw
1/*
2 * Copyright (C) 2015-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 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
20FocusScope {
21 id: root
22 focus: true
24 property alias dragHandleLeftMargin: coverPage.dragHandleLeftMargin
25 property alias launcherOffset: coverPage.launcherOffset
26 property alias currentIndex: loginList.currentIndex
27 property int delayMinutes // TODO
28 property alias backgroundTopMargin: coverPage.backgroundTopMargin
29 property alias background: coverPage.background
30 property bool locked
31 property alias alphanumeric: loginList.alphanumeric
32 property alias userModel: loginList.model
33 property alias infographicModel: coverPage.infographicModel
34 property bool waiting
35 readonly property bool fullyShown: coverPage.showProgress === 1
36 readonly property bool required: coverPage.required
37 readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
39 // so that it can be replaced in tests with a mock object
40 property var inputMethod: Qt.inputMethod
42 signal selected(int index)
43 signal responded(string response)
44 signal tease()
45 signal emergencyCall() // unused
47 function showMessage(html) {
48 loginList.showMessage(html);
49 }
51 function showPrompt(text, isSecret, isDefaultPrompt) {
52 loginList.showPrompt(text, isSecret, isDefaultPrompt);
53 }
55 function showLastChance() {
56 // TODO
57 }
59 function hide() {
60 coverPage.hide();
61 }
63 function notifyAuthenticationSucceeded(showFakePassword) {
64 // Nothing needed
65 }
67 function notifyAuthenticationFailed() {
68 loginList.showError();
69 }
71 function showErrorMessage(msg) {
72 coverPage.showErrorMessage(msg);
73 }
75 function reset() {
76 loginList.reset();
77 }
79 function tryToUnlock(toTheRight) {
80 if (root.locked) {
81 coverPage.show();
82 loginList.tryToUnlock();
83 return false;
84 } else {
85 var coverChanged = coverPage.shown;
86 if (toTheRight) {
87 coverPage.hideRight();
88 } else {
89 coverPage.hide();
90 }
91 return coverChanged;
92 }
93 }
95 Rectangle {
96 anchors.fill: parent
97 color: "black"
98 opacity: coverPage.showProgress * 0.8
99 }
101 CoverPage {
102 id: coverPage
103 objectName: "coverPage"
104 height: parent.height
105 width: parent.width
106 draggable: !root.locked && !root.waiting
108 infographics {
109 height: 0.75 * parent.height
110 anchors.leftMargin: loginList.x + loginList.width
111 }
113 onTease: root.tease()
115 onShowProgressChanged: {
116 if (showProgress === 0 && !root.locked) {
117 root.responded("");
118 }
119 }
121 LoginList {
122 id: loginList
123 objectName: "loginList"
125 anchors {
126 left: parent.left
127 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
128 top: parent.top
129 }
130 width: units.gu(40)
131 height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
132 : parent.height
133 Behavior on height { UbuntuNumberAnimation {} }
135 locked: root.locked
136 waiting: root.waiting
138 onSelected: root.selected(index)
139 onResponded: root.responded(response)
140 }
141 }