on 8d0601f help sign in
unity8/Greeter/GreeterContent.qml
141 lines 4.1 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 Ubuntu.Components 0.1
19import LightDM 0.1 as LightDM
20import "../Components"
22MouseArea {
23 id: root
24 anchors.fill: parent
26 property bool ready: wallpaper.source == "" || wallpaper.status == Image.Ready || wallpaper.status == Image.Error
27 property bool leftTeaserPressed: teasingMouseArea.pressed &&
28 teasingMouseArea.mouseX < teasingMouseArea.width / 2
29 property bool rightTeaserPressed: teasingMouseArea.pressed &&
30 teasingMouseArea.mouseX > teasingMouseArea.width / 2
32 signal selected(int uid)
33 signal unlocked(int uid)
35 Rectangle {
36 // In case wallpaper fails to load
37 id: wallpaperBackup
38 anchors.fill: parent
39 color: "black"
40 }
42 CrossFadeImage {
43 id: wallpaper
45 source: shell.background
46 anchors.fill: parent
47 fadeInFirst: false
48 }
50 Rectangle {
51 anchors.fill: parent
52 color: "black"
53 opacity: 0.4
54 }
56 Clock {
57 id: clock
58 visible: narrowMode
60 anchors {
61 top: parent.top
62 topMargin: units.gu(2)
63 horizontalCenter: parent.horizontalCenter
64 }
65 }
67 MouseArea {
68 id: teasingMouseArea
69 anchors.fill: parent
70 }
72 Loader {
73 id: loginLoader
74 objectName: "loginLoader"
75 anchors {
76 left: parent.left
77 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
78 verticalCenter: parent.verticalCenter
79 }
80 width: units.gu(29)
81 height: parent.height
83 // TODO: Once we have a system API for determining which mode we are
84 // in, tablet/phone/desktop, that should be used instead of narrowMode.
85 source: greeter.narrowMode ? "" : "LoginList.qml"
87 onLoaded: {
88 item.currentIndex = greeterContentLoader.currentIndex;
89 selected(item.currentIndex);
90 item.resetAuthentication();
91 }
93 Binding {
94 target: loginLoader.item
95 property: "model"
96 value: greeterContentLoader.model
97 }
99 Connections {
100 target: loginLoader.item
102 onSelected: {
103 root.selected(uid);
104 }
106 onUnlocked: {
107 root.unlocked(uid);
108 }
110 onCurrentIndexChanged: {
111 if (greeterContentLoader.currentIndex !== loginLoader.item.currentIndex) {
112 greeterContentLoader.currentIndex = loginLoader.item.currentIndex;
113 }
114 }
115 }
116 }
118 Infographics {
119 id: infographics
120 height: narrowMode ? parent.height : 0.75 * parent.height
121 model: greeterContentLoader.infographicModel
123 Component.onCompleted: infographics.updateUsername(greeterContentLoader.currentIndex)
125 Connections {
126 target: root
127 onSelected: infographics.updateUsername(uid)
128 }
130 function updateUsername(uid) {
131 greeterContentLoader.infographicModel.username = greeterContentLoader.model.data(uid, LightDM.UserRoles.NameRole)
132 greeterContentLoader.infographicModel.readyForDataChangeSlot();
133 }
135 anchors {
136 verticalCenter: parent.verticalCenter
137 left: narrowMode ? root.left : loginLoader.right
138 right: root.right
139 }
140 }