| 1 | /* |
| 2 | * Copyright 2016 Eric Hameleers, Eindhoven, NL <alien@slackware.com> |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and distribute this software for |
| 6 | * any purpose with or without fee is hereby granted, provided that |
| 7 | * the above copyright notice and this permission notice appear in all |
| 8 | * copies. |
| 9 | * |
| 10 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 11 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 12 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 13 | * IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
| 14 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 15 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 16 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 17 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 18 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 19 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 20 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 21 | * SUCH DAMAGE. |
| 22 | */ |
| 23 | |
| 24 | import QtQuick 2.2 |
| 25 | import SddmComponents 2.0 |
| 26 | |
| 27 | Rectangle { |
| 28 | id: container |
| 29 | width: 1024 |
| 30 | height: 768 |
| 31 | |
| 32 | property int sessionIndex: session.index |
| 33 | |
| 34 | TextConstants { id: textConstants } |
| 35 | |
| 36 | Connections { |
| 37 | target: sddm |
| 38 | onLoginSucceeded: { |
| 39 | } |
| 40 | |
| 41 | onLoginFailed: { |
| 42 | txtMessage.text = textConstants.loginFailed |
| 43 | listView.currentItem.password.text = "" |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | Repeater { |
| 48 | model: screenModel |
| 49 | Background { |
| 50 | x: geometry.x; y: geometry.y; width: geometry.width; height:geometry.height |
| 51 | source: config.background |
| 52 | fillMode: Image.PreserveAspectCrop |
| 53 | onStatusChanged: { |
| 54 | if (status == Image.Error && source != config.defaultBackground) { |
| 55 | source = config.defaultBackground |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | Rectangle { |
| 62 | property variant geometry: screenModel.geometry(screenModel.primary) |
| 63 | x: geometry.x; y: geometry.y; width: geometry.width; height: geometry.height |
| 64 | color: "transparent" |
| 65 | |
| 66 | Component { |
| 67 | id: userDelegate |
| 68 | |
| 69 | PictureBox { |
| 70 | anchors.verticalCenter: parent.verticalCenter |
| 71 | name: (model.realName === "") ? model.name : model.realName |
| 72 | icon: model.icon |
| 73 | |
| 74 | focus: (listView.currentIndex === index) ? true : false |
| 75 | state: (listView.currentIndex === index) ? "active" : "" |
| 76 | |
| 77 | onLogin: sddm.login(model.name, password, sessionIndex); |
| 78 | |
| 79 | MouseArea { |
| 80 | anchors.fill: parent |
| 81 | hoverEnabled: true |
| 82 | onEntered: listView.currentIndex = index |
| 83 | onClicked: listView.focus = true |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | Row { |
| 89 | anchors.fill: parent |
| 90 | |
| 91 | Text { |
| 92 | id: txtMessage |
| 93 | anchors.top: usersContainer.bottom; |
| 94 | anchors.margins: 20 |
| 95 | anchors.horizontalCenter: parent.horizontalCenter |
| 96 | color: "white" |
| 97 | text: textConstants.promptSelectUser |
| 98 | font.pixelSize: 16 |
| 99 | font.family: "sans" |
| 100 | } |
| 101 | |
| 102 | Item { |
| 103 | id: usersContainer |
| 104 | width: parent.width; height: 300 |
| 105 | anchors.verticalCenter: parent.verticalCenter |
| 106 | |
| 107 | ImageButton { |
| 108 | id: prevUser |
| 109 | anchors.left: parent.left |
| 110 | anchors.verticalCenter: parent.verticalCenter |
| 111 | anchors.margins: 10 |
| 112 | source: "angle-left.png" |
| 113 | onClicked: listView.decrementCurrentIndex() |
| 114 | |
| 115 | KeyNavigation.backtab: btnShutdown; KeyNavigation.tab: listView |
| 116 | } |
| 117 | |
| 118 | |
| 119 | |
| 120 | ListView { |
| 121 | id: listView |
| 122 | height: parent.height |
| 123 | anchors.left: prevUser.right; anchors.right: nextUser.left |
| 124 | anchors.verticalCenter: parent.verticalCenter |
| 125 | anchors.margins: 10 |
| 126 | |
| 127 | clip: true |
| 128 | focus: true |
| 129 | |
| 130 | spacing: 5 |
| 131 | |
| 132 | model: userModel |
| 133 | delegate: userDelegate |
| 134 | orientation: ListView.Horizontal |
| 135 | currentIndex: userModel.lastIndex |
| 136 | |
| 137 | KeyNavigation.backtab: prevUser; KeyNavigation.tab: nextUser |
| 138 | } |
| 139 | |
| 140 | ImageButton { |
| 141 | id: nextUser |
| 142 | anchors.right: parent.right |
| 143 | anchors.verticalCenter: parent.verticalCenter |
| 144 | anchors.margins: 10 |
| 145 | source: "angle-right.png" |
| 146 | onClicked: listView.incrementCurrentIndex() |
| 147 | KeyNavigation.backtab: listView; KeyNavigation.tab: session |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | Rectangle { |
| 155 | id: actionBar |
| 156 | anchors.top: parent.top; |
| 157 | anchors.horizontalCenter: parent.horizontalCenter |
| 158 | width: parent.width; height: 64 |
| 159 | color: "#44ffffff" |
| 160 | |
| 161 | Row { |
| 162 | anchors.left: parent.left |
| 163 | anchors.margins: 5 |
| 164 | height: parent.height |
| 165 | spacing: 5 |
| 166 | |
| 167 | Text { |
| 168 | height: parent.height |
| 169 | anchors.verticalCenter: parent.verticalCenter |
| 170 | text: textConstants.session |
| 171 | font.pixelSize: 14 |
| 172 | color: "white" |
| 173 | verticalAlignment: Text.AlignVCenter |
| 174 | } |
| 175 | |
| 176 | ComboBox { |
| 177 | id: session |
| 178 | width: 245 |
| 179 | anchors.verticalCenter: parent.verticalCenter |
| 180 | arrowIcon: "angle-down.png" |
| 181 | model: sessionModel |
| 182 | index: sessionModel.lastIndex |
| 183 | font.pixelSize: 14 |
| 184 | color: "#44ffffff" |
| 185 | KeyNavigation.backtab: nextUser; KeyNavigation.tab: layoutBox |
| 186 | } |
| 187 | |
| 188 | Text { |
| 189 | height: parent.height |
| 190 | anchors.verticalCenter: parent.verticalCenter |
| 191 | text: textConstants.layout |
| 192 | font.pixelSize: 14 |
| 193 | color: "white" |
| 194 | verticalAlignment: Text.AlignVCenter |
| 195 | } |
| 196 | |
| 197 | LayoutBox { |
| 198 | id: layoutBox |
| 199 | width: 90 |
| 200 | anchors.verticalCenter: parent.verticalCenter |
| 201 | font.pixelSize: 14 |
| 202 | arrowIcon: "angle-down.png" |
| 203 | KeyNavigation.backtab: session; KeyNavigation.tab: btnShutdown |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | Row { |
| 208 | height: parent.height |
| 209 | anchors.right: parent.right |
| 210 | anchors.margins: 5 |
| 211 | spacing: 5 |
| 212 | |
| 213 | ImageButton { |
| 214 | id: btnReboot |
| 215 | height: parent.height |
| 216 | source: "reboot.png" |
| 217 | visible: sddm.canReboot |
| 218 | onClicked: sddm.reboot() |
| 219 | KeyNavigation.backtab: layoutBox; KeyNavigation.tab: btnShutdown |
| 220 | } |
| 221 | |
| 222 | ImageButton { |
| 223 | id: btnShutdown |
| 224 | height: parent.height |
| 225 | source: "shutdown.png" |
| 226 | visible: sddm.canPowerOff |
| 227 | onClicked: sddm.powerOff() |
| 228 | KeyNavigation.backtab: btnReboot; KeyNavigation.tab: prevUser |
| 229 | } |
| 230 | Clock { |
| 231 | id: clock |
| 232 | anchors.margins: 5 |
| 233 | anchors.top: parent.top; anchors.right: parent.right |
| 234 | color: "white" |
| 235 | timeFont.family: "sans" |
| 236 | timeFont.bold: true |
| 237 | timeFont.pixelSize: 28 |
| 238 | dateFont.pixelSize: 12 |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | |
| 243 | } |
| 244 | } |