Unity 8
WideView.qml
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  */
16 
17 import QtQuick 2.3
18 import Ubuntu.Components 1.1
19 
20 FocusScope {
21  id: root
22 
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 
36  // so that it can be replaced in tests with a mock object
37  property var inputMethod: Qt.inputMethod
38 
39  signal selected(int index)
40  signal responded(string response)
41  signal tease()
42  signal emergencyCall() // unused
43 
44  function showMessage(html) {
45  loginList.showMessage(html);
46  }
47 
48  function showPrompt(text, isSecret, isDefaultPrompt) {
49  loginList.showPrompt(text, isSecret, isDefaultPrompt);
50  }
51 
52  function showLastChance() {
53  // TODO
54  }
55 
56  function hide() {
57  coverPage.hide();
58  }
59 
60  function notifyAuthenticationSucceeded() {
61  // Nothing needed
62  }
63 
64  function notifyAuthenticationFailed() {
65  loginList.showError();
66  }
67 
68  function reset() {
69  loginList.reset();
70  }
71 
72  function tryToUnlock(toTheRight) {
73  if (root.locked) {
74  coverPage.show();
75  loginList.tryToUnlock();
76  return false;
77  } else {
78  var coverChanged = coverPage.shown;
79  if (toTheRight) {
80  coverPage.hideRight();
81  } else {
82  coverPage.hide();
83  }
84  return coverChanged;
85  }
86  }
87 
88  Rectangle {
89  anchors.fill: parent
90  color: "black"
91  opacity: coverPage.showProgress * 0.8
92  }
93 
94  CoverPage {
95  id: coverPage
96  objectName: "coverPage"
97  height: parent.height
98  width: parent.width
99  draggable: !root.locked
100 
101  infographics {
102  height: 0.75 * parent.height
103  anchors.leftMargin: loginList.x + loginList.width
104  }
105 
106  onTease: root.tease()
107 
108  onShowProgressChanged: {
109  if (showProgress === 0 && !root.locked) {
110  root.responded("");
111  }
112  }
113 
114  LoginList {
115  id: loginList
116  objectName: "loginList"
117 
118  anchors {
119  left: parent.left
120  leftMargin: Math.min(parent.width * 0.16, units.gu(20))
121  top: parent.top
122  }
123  width: units.gu(29)
124  height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
125  : parent.height
126  Behavior on height { UbuntuNumberAnimation {} }
127 
128  locked: root.locked
129 
130  onSelected: root.selected(index)
131  onResponded: root.responded(response)
132  }
133  }
134 }