on beb293c help sign in
unity8/qml/Greeter/WideView.qml
139 lines 4.0 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.4
18import Ubuntu.Components 1.3
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 alias alphanumeric: loginList.alphanumeric
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(showFakePassword) {
62 // Nothing needed
63 }
65 function notifyAuthenticationFailed() {
66 loginList.showError();
67 }
69 function showErrorMessage(msg) {
70 coverPage.showErrorMessage(msg);
71 }
73 function reset() {
74 loginList.reset();
75 }
77 function tryToUnlock(toTheRight) {
78 if (root.locked) {
79 coverPage.show();
80 loginList.tryToUnlock();
81 return false;
82 } else {
83 var coverChanged = coverPage.shown;
84 if (toTheRight) {
85 coverPage.hideRight();
86 } else {
87 coverPage.hide();
88 }
89 return coverChanged;
90 }
91 }
93 Rectangle {
94 anchors.fill: parent
95 color: "black"
96 opacity: coverPage.showProgress * 0.8
97 }
99 CoverPage {
100 id: coverPage
101 objectName: "coverPage"
102 height: parent.height
103 width: parent.width
104 draggable: !root.locked
106 infographics {
107 height: 0.75 * parent.height
108 anchors.leftMargin: loginList.x + loginList.width
109 }
111 onTease: root.tease()
113 onShowProgressChanged: {
114 if (showProgress === 0 && !root.locked) {
115 root.responded("");
116 }
117 }
119 LoginList {
120 id: loginList
121 objectName: "loginList"
123 anchors {
124 left: parent.left
125 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
126 top: parent.top
127 }
128 width: units.gu(29)
129 height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
130 : parent.height
131 Behavior on height { UbuntuNumberAnimation {} }
133 locked: root.locked
135 onSelected: root.selected(index)
136 onResponded: root.responded(response)
137 }
138 }