Warning, /plasma/lightdm-kde-greeter/themes/classic/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 This file is part of LightDM-KDE. 0003 0004 Copyright 2011, 2012 David Edmundson <kde@davidedmundson.co.uk> 0005 0006 LightDM-KDE is free software: you can redistribute it and/or modify 0007 it under the terms of the GNU General Public License as published by 0008 the Free Software Foundation, either version 3 of the License, or 0009 (at your option) any later version. 0010 0011 LightDM-KDE is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with LightDM-KDE. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 import QtQuick 1.0 0020 //TODO phase this out 0021 import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets 0022 import org.kde.plasma.components 0.1 as PlasmaComponents 0023 import org.kde.qtextracomponents 0.1 as ExtraComponents 0024 import org.kde.plasma.core 0.1 as PlasmaCore 0025 import org.kde.lightdm 0.1 as LightDM 0026 0027 Item { 0028 0029 LightDM.ScreenManager { 0030 id: screenManager 0031 delegate: Image { 0032 // default to keeping aspect ratio 0033 fillMode: config.readEntry("BackgroundKeepAspectRatio") == false ? Image.Stretch : Image.PreserveAspectCrop; 0034 //read from config, if there's no entry use plasma theme 0035 0036 source: config.readEntry("Background") ? config.readEntry("Background"): theme.wallpaperPathForSize(width,height); 0037 smooth: true 0038 } 0039 } 0040 0041 Item { //recreate active screen at a sibling level which we can anchor in. 0042 id: activeScreen 0043 x: screenManager.activeScreen.x 0044 y: screenManager.activeScreen.y 0045 width: screenManager.activeScreen.width 0046 height: screenManager.activeScreen.height 0047 } 0048 0049 0050 Connections { 0051 target: greeter; 0052 onShowPrompt: { 0053 greeter.respond(passwordInput.text); 0054 } 0055 0056 onAuthenticationComplete: { 0057 busyIndicator.opacity = 0; 0058 loginButton.opacity = 1; 0059 0060 if(greeter.authenticated) { 0061 loginAnimation.start(); 0062 } 0063 else { 0064 feedbackLabel.text = i18n("Sorry, incorrect password please try again."); 0065 passwordInput.selectAll() 0066 passwordInput.forceActiveFocus() 0067 } 0068 } 0069 } 0070 0071 function login() { 0072 busyIndicator.opacity = 1; 0073 loginButton.opacity = 0; 0074 0075 if (useGuestOption.checked) { 0076 greeter.authenticateAsGuest(); 0077 } else { 0078 greeter.authenticate(usernameInput.text); 0079 } 0080 } 0081 0082 function doSessionSync() { 0083 var session = optionsMenu.currentSession; 0084 greeter.startSessionSync(session); 0085 } 0086 0087 ParallelAnimation { 0088 id: loginAnimation 0089 NumberAnimation { target: dialog; property: "opacity"; to: 0; duration: 400; easing.type: Easing.InOutQuad } 0090 NumberAnimation { target: powerDialog; property: "opacity"; to: 0; duration: 400; easing.type: Easing.InOutQuad } 0091 onCompleted: doSessionSync() 0092 } 0093 0094 PlasmaCore.FrameSvgItem { 0095 id: dialog; 0096 imagePath: "widgets/background" 0097 anchors.centerIn: activeScreen; 0098 0099 width: childrenRect.width + 55; 0100 height: childrenRect.height + 55; 0101 0102 Column { 0103 spacing: 15 0104 anchors.centerIn: parent 0105 0106 Image { 0107 id: logo 0108 source: config.readEntry("Logo") 0109 fillMode: Image.PreserveAspectFit 0110 height: 100 0111 anchors.horizontalCenter: parent.horizontalCenter 0112 smooth: true 0113 } 0114 0115 0116 PlasmaComponents.Label { 0117 anchors.horizontalCenter: parent.horizontalCenter; 0118 id: feedbackLabel; 0119 font.pointSize: 9 0120 text: config.readEntry("GreetMessage").replace("%hostname%", greeter.hostname); 0121 } 0122 0123 //if guest checked, replace the normal "user/pass" textboxes with a big login button 0124 PlasmaComponents.Button { 0125 visible: useGuestOption.checked 0126 text: i18n("Log in as guest"); 0127 onClicked: login() 0128 } 0129 0130 Row { 0131 visible: !useGuestOption.checked 0132 spacing: 10 0133 width: childrenRect.width 0134 height: childrenRect.height 0135 0136 Grid { 0137 columns: 2 0138 spacing: 15 0139 0140 ExtraComponents.QIconItem { 0141 icon: "meeting-participant" 0142 height: usernameInput.height; 0143 width: usernameInput.height; 0144 } 0145 0146 PlasmaComponents.TextField { 0147 id: usernameInput; 0148 placeholderText: i18n("Username"); 0149 text: greeter.lastLoggedInUser 0150 onAccepted: { 0151 passwordInput.focus = true; 0152 } 0153 width: 160 0154 0155 Component.onCompleted: { 0156 //if the username field has text, focus the password, else focus the username 0157 if (usernameInput.text) { 0158 passwordInput.focus = true; 0159 } else { 0160 usernameInput.focus = true; 0161 } 0162 } 0163 KeyNavigation.tab: passwordInput 0164 } 0165 0166 ExtraComponents.QIconItem { 0167 icon: "object-locked" 0168 height: passwordInput.height; 0169 width: passwordInput.height; 0170 } 0171 0172 PlasmaComponents.TextField { 0173 id: passwordInput 0174 echoMode: TextInput.Password 0175 placeholderText: i18n("Password") 0176 onAccepted: { 0177 login(); 0178 } 0179 width: 160 0180 KeyNavigation.backtab: usernameInput 0181 KeyNavigation.tab: loginButton 0182 } 0183 } 0184 0185 PlasmaComponents.ToolButton { 0186 id: loginButton 0187 anchors.verticalCenter: parent.verticalCenter 0188 iconSource: "go-next" 0189 onClicked: { 0190 login(); 0191 } 0192 KeyNavigation.backtab: passwordInput 0193 KeyNavigation.tab: usernameInput 0194 } 0195 0196 PlasmaComponents.BusyIndicator { 0197 id: busyIndicator 0198 running: (visible ? true : false) 0199 anchors.fill: loginButton 0200 opacity: 0 0201 } 0202 0203 } 0204 0205 Item { 0206 height: 10 0207 } 0208 0209 Row { 0210 spacing: 8; 0211 IconButton { 0212 icon: "system-shutdown" 0213 onClicked: { 0214 if (powerDialog.opacity == 1) { 0215 powerDialog.opacity = 0; 0216 } else { 0217 powerDialog.opacity = 1; 0218 } 0219 } 0220 } 0221 0222 PlasmaComponents.ContextMenu { 0223 id: sessionMenu 0224 visualParent: sessionMenuOption 0225 } 0226 0227 Repeater { 0228 parent: sessionMenu 0229 model: LightDM.SessionsModel {} 0230 delegate : PlasmaComponents.MenuItem { 0231 text: model.display 0232 checkable: true 0233 checked: model.key === optionsMenu.currentSession 0234 onClicked : { 0235 optionsMenu.currentSession = model.key; 0236 } 0237 0238 Component.onCompleted: { 0239 parent = sessionMenu 0240 } 0241 } 0242 Component.onCompleted: { 0243 model.showLastUsedSession = true 0244 } 0245 } 0246 0247 PlasmaComponents.ContextMenu { 0248 id: optionsMenu 0249 visualParent: optionsButton 0250 //in LightDM "" means "last user session". whereas NULL is default. 0251 property string currentSession: "" 0252 PlasmaComponents.MenuItem { 0253 id: useGuestOption 0254 text: i18n("Log in as guest") 0255 checkable: true 0256 enabled: greeter.hasGuestAccount 0257 } 0258 PlasmaComponents.MenuItem { 0259 separator: true 0260 } 0261 0262 PlasmaComponents.MenuItem { 0263 text: i18n("Session") 0264 id: sessionMenuOption 0265 onClicked: sessionMenu.open() 0266 } 0267 } 0268 0269 IconButton { 0270 id: optionsButton 0271 icon: "system-log-out" 0272 onClicked: { 0273 optionsMenu.open(); 0274 } 0275 } 0276 } 0277 } 0278 } 0279 0280 PlasmaCore.FrameSvgItem { 0281 id: powerDialog 0282 anchors.top: dialog.bottom 0283 anchors.topMargin: 3 0284 anchors.horizontalCenter: activeScreen.horizontalCenter 0285 imagePath: "translucent/dialogs/background" 0286 opacity: 0 0287 0288 Behavior on opacity { PropertyAnimation { duration: 500} } 0289 0290 width: childrenRect.width + 30; 0291 height: childrenRect.height + 30; 0292 0293 Row { 0294 spacing: 5 0295 anchors.centerIn: parent 0296 0297 LightDM.Power { 0298 id: power 0299 } 0300 0301 PlasmaWidgets.IconWidget { 0302 text: i18n("Suspend") 0303 icon: QIcon("system-suspend") 0304 enabled: power.canSuspend; 0305 onClicked: {power.suspend();} 0306 } 0307 0308 PlasmaWidgets.IconWidget { 0309 text: i18n("Hibernate") 0310 icon: QIcon("system-suspend-hibernate") 0311 //Hibernate is a special case, lots of distros disable it, so if it's not enabled don't show it 0312 visible: power.canHibernate; 0313 onClicked: {power.hibernate();} 0314 } 0315 0316 PlasmaWidgets.IconWidget { 0317 text: i18n("Restart") 0318 icon: QIcon("system-reboot") 0319 enabled: power.canRestart; 0320 onClicked: {power.restart();} 0321 } 0322 0323 PlasmaWidgets.IconWidget { 0324 text: i18n("Shutdown") 0325 icon: QIcon("system-shutdown") 0326 enabled: power.canShutdown; 0327 onClicked: {power.shutdown();} 0328 } 0329 } 0330 0331 } 0332 }