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