on 3bbd428 help sign in
unity8/Greeter/GreeterContent.qml
166 lines 5.2 kB history raw
1/*
2 * Copyright (C) 2013 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.0
18import AccountsService 0.1
19import Ubuntu.Components 0.1
20import LightDM 0.1 as LightDM
21import "../Components"
23MouseArea {
24 id: root
25 anchors.fill: parent
27 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
28 property bool leftTeaserPressed: teasingMouseArea.pressed &&
29 teasingMouseArea.mouseX < teasingMouseArea.width / 2
30 property bool rightTeaserPressed: teasingMouseArea.pressed &&
31 teasingMouseArea.mouseX > teasingMouseArea.width / 2
33 signal selected(int uid)
34 signal unlocked(int uid)
36 Rectangle {
37 // In case background fails to load
38 id: backgroundBackup
39 anchors.fill: parent
40 color: "black"
41 }
43 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
44 onBackgroundValueChanged: background.source = backgroundValue
46 CrossFadeImage {
47 id: background
48 objectName: "greeterBackground"
49 anchors {
50 fill: parent
51 topMargin: backgroundTopMargin
52 }
53 fillMode: Image.PreserveAspectCrop
54 }
56 // See Shell.qml's backgroundSettings treatment for why we need a separate
57 // Image, but it boils down to avoiding binding loop detection.
58 Image {
59 source: background.source
60 height: 0
61 width: 0
62 sourceSize.height: 0
63 sourceSize.width: 0
64 onStatusChanged: {
65 if (status == Image.Error && source != greeter.defaultBackground) {
66 background.source = greeter.defaultBackground
67 }
68 }
69 }
71 Rectangle {
72 anchors.fill: parent
73 color: "black"
74 opacity: 0.4
75 }
77 MouseArea {
78 id: teasingMouseArea
79 anchors.fill: parent
80 }
82 Loader {
83 id: loginLoader
84 objectName: "loginLoader"
85 anchors {
86 left: parent.left
87 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
88 verticalCenter: parent.verticalCenter
89 }
90 width: units.gu(29)
91 height: parent.height
93 // TODO: Once we have a system API for determining which mode we are
94 // in, tablet/phone/desktop, that should be used instead of narrowMode.
95 source: greeter.narrowMode ? "" : "LoginList.qml"
97 onLoaded: {
98 item.currentIndex = greeterContentLoader.currentIndex;
99 selected(item.currentIndex);
100 item.resetAuthentication();
101 }
103 Binding {
104 target: loginLoader.item
105 property: "model"
106 value: greeterContentLoader.model
107 }
109 Connections {
110 target: loginLoader.item
112 onSelected: {
113 root.selected(uid);
114 }
116 onUnlocked: {
117 root.unlocked(uid);
118 }
120 onCurrentIndexChanged: {
121 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
122 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
123 }
124 }
125 }
126 }
128 Infographics {
129 id: infographics
130 objectName: "infographics"
131 height: narrowMode ? parent.height : 0.75 * parent.height
132 model: greeterContentLoader.infographicModel
134 property string selectedUser
135 property string infographicUser: AccountsService.statsWelcomeScreen ? selectedUser : ""
136 onInfographicUserChanged: greeterContentLoader.infographicModel.username = infographicUser
138 Component.onCompleted: {
139 selectedUser = greeterContentLoader.model.data(greeterContentLoader.currentIndex, LightDM.UserRoles.NameRole)
140 greeterContentLoader.infographicModel.username = infographicUser
141 greeterContentLoader.infographicModel.readyForDataChange()
142 }
144 Connections {
145 target: root
146 onSelected: infographics.selectedUser = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
147 }
149 anchors {
150 verticalCenter: parent.verticalCenter
151 left: narrowMode ? root.left : loginLoader.right
152 right: root.right
153 }
154 }
156 Clock {
157 id: clock
158 visible: narrowMode
160 anchors {
161 top: parent.top
162 topMargin: units.gu(2)
163 horizontalCenter: parent.horizontalCenter
164 }
165 }