on bb5feb3 help sign in
unity8/Greeter/GreeterContent.qml
159 lines 4.8 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: wallpaper.source == "" || wallpaper.status == Image.Ready || wallpaper.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 wallpaper fails to load
38 id: wallpaperBackup
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: wallpaper.source = backgroundValue
46 CrossFadeImage {
47 id: wallpaper
48 objectName: "wallpaper"
49 anchors.fill: parent
50 fadeInFirst: false
51 }
53 // See Shell.qml's backgroundSettings treatment for why we need a separate
54 // Image, but it boils down to avoiding binding loop detection.
55 Image {
56 source: wallpaper.source
57 height: 0
58 width: 0
59 sourceSize.height: 0
60 sourceSize.width: 0
61 onStatusChanged: {
62 if (status == Image.Error && source != greeter.defaultBackground) {
63 wallpaper.source = greeter.defaultBackground
64 }
65 }
66 }
68 Rectangle {
69 anchors.fill: parent
70 color: "black"
71 opacity: 0.4
72 }
74 Clock {
75 id: clock
76 visible: narrowMode
78 anchors {
79 top: parent.top
80 topMargin: units.gu(2)
81 horizontalCenter: parent.horizontalCenter
82 }
83 }
85 MouseArea {
86 id: teasingMouseArea
87 anchors.fill: parent
88 }
90 Loader {
91 id: loginLoader
92 objectName: "loginLoader"
93 anchors {
94 left: parent.left
95 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
96 verticalCenter: parent.verticalCenter
97 }
98 width: units.gu(29)
99 height: parent.height
101 // TODO: Once we have a system API for determining which mode we are
102 // in, tablet/phone/desktop, that should be used instead of narrowMode.
103 source: greeter.narrowMode ? "" : "LoginList.qml"
105 onLoaded: {
106 item.currentIndex = greeterContentLoader.currentIndex;
107 selected(item.currentIndex);
108 item.resetAuthentication();
109 }
111 Binding {
112 target: loginLoader.item
113 property: "model"
114 value: greeterContentLoader.model
115 }
117 Connections {
118 target: loginLoader.item
120 onSelected: {
121 root.selected(uid);
122 }
124 onUnlocked: {
125 root.unlocked(uid);
126 }
128 onCurrentIndexChanged: {
129 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
130 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
131 }
132 }
133 }
134 }
136 Infographics {
137 id: infographics
138 height: narrowMode ? parent.height : 0.75 * parent.height
139 model: greeterContentLoader.infographicModel
141 Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)
143 Connections {
144 target: root
145 onSelected: infographics.updateUsername(uid)
146 }
148 function updateUsername(uid) {
149 greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
150 greeterContentLoader.infographicModel.readyForDataChangeSlot();
151 }
153 anchors {
154 verticalCenter: parent.verticalCenter
155 left: narrowMode ? root.left : loginLoader.right
156 right: root.right
157 }
158 }