@@ -19,6 +19,7 @@ import AccountsService 0.1
19import GSettings 1.0
19import GSettings 1.0
20import Unity.Application 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22+import Ubuntu.Components.Popups 0.1
22import Ubuntu.Gestures 0.1
23import Ubuntu.Gestures 0.1
23import Unity.Launcher 0.1
24import Unity.Launcher 0.1
24import LightDM 0.1 as LightDM
25import LightDM 0.1 as LightDM
@@ -268,7 +269,128 @@ FocusScope {
272+ property bool dialogShown: false
279+ text: "Are you sure that you want to logout?"
283+ PopupUtils.close(dialogueLogout);
284+ stages.dialogShown = false;
290+ DBusUnitySessionService.Logout();
291+ PopupUtils.close(dialogueLogout);
292+ stages.dialogShown = false;
301+ id: dialogueShutdown
303+ text: "Are you sure that you want to shutdown?"
307+ PopupUtils.close(dialogueShutdown);
308+ stages.dialogShown = false;
314+ dBusUnitySessionServiceConnection.closeAllApps();
315+ DBusUnitySessionService.Shutdown();
316+ PopupUtils.close(dialogueShutdown);
317+ stages.dialogShown = false;
328+ text: "Are you sure that you want to reboot?"
332+ PopupUtils.close(dialogueReboot)
333+ stages.dialogShown = false;
339+ dBusUnitySessionServiceConnection.closeAllApps();
340+ DBusUnitySessionService.Reboot();
341+ PopupUtils.close(dialogueReboot);
342+ stages.dialogShown = false;
353+ text: i18n.tr("Are you sure you would like to turn power off?")
355+ text: i18n.tr("Power off")
357+ dBusUnitySessionServiceConnection.closeAllApps();
358+ PopupUtils.close(dialoguePower);
359+ stages.dialogShown = false;
360+ shutdownFadeOutRectangle.enabled = true;
361+ shutdownFadeOutRectangle.visible = true;
362+ shutdownFadeOut.start();
366+ text: i18n.tr("Restart")
368+ dBusUnitySessionServiceConnection.closeAllApps();
369+ DBusUnitySessionService.Reboot();
370+ PopupUtils.close(dialoguePower);
371+ stages.dialogShown = false;
375+ text: i18n.tr("Cancel")
377+ PopupUtils.close(dialoguePower);
378+ stages.dialogShown = false;
384+ function showPowerDialog() {
385+ if (!stages.dialogShown) {
386+ stages.dialogShown = true;
387+ PopupUtils.open(powerDialog);
271 Connections {
391 Connections {
392+ id: dBusUnitySessionServiceConnection
393+ objectName: "dBusUnitySessionServiceConnection"
272 target: DBusUnitySessionService
394 target: DBusUnitySessionService
274 function closeAllApps() {
396 function closeAllApps() {
@@ -282,8 +404,27 @@ FocusScope {
284 onLogoutRequested: {
406 onLogoutRequested: {
407+ // Display a dialog to ask the user to confirm.
408+ if (!stages.dialogShown) {
409+ stages.dialogShown = true;
410+ PopupUtils.open(logoutDialog);
414+ onShutdownRequested: {
285− // TODO: Display a dialog to ask the user to confirm.
415+ // Display a dialog to ask the user to confirm.
286− DBusUnitySessionService.Logout();
416+ if (!stages.dialogShown) {
417+ stages.dialogShown = true;
418+ PopupUtils.open(shutdownDialog);
422+ onRebootRequested: {
423+ // Display a dialog to ask the user to confirm.
424+ if (!stages.dialogShown) {
425+ stages.dialogShown = true;
426+ PopupUtils.open(rebootDialog);
289 onLogoutReady: {
430 onLogoutReady: {
@@ -348,6 +489,8 @@ FocusScope {
348 Connections {
489 Connections {
349 target: LightDM.Greeter
490 target: LightDM.Greeter
492+ onShowGreeter: greeter.show()
351 onShowPrompt: {
494 onShowPrompt: {
352 if (LightDM.Users.count == 1) {
495 if (LightDM.Users.count == 1) {
353 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
496 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
@@ -373,6 +516,12 @@ FocusScope {
520+ target: LightDM.Greeter
522+ value: greeter.shown || lockscreen.shown
376 Rectangle {
525 Rectangle {
377 anchors.fill: parent
526 anchors.fill: parent
378 color: "black"
527 color: "black"
@@ -412,6 +561,9 @@ FocusScope {
412 onShownChanged: {
561 onShownChanged: {
413 if (shown) {
562 if (shown) {
414 lockscreen.reset();
563 lockscreen.reset();
564+ if (!LightDM.Greeter.promptless) {
415 // If there is only one user, we start authenticating with that one here.
567 // If there is only one user, we start authenticating with that one here.
416 // If there are more users, the Greeter will handle that
568 // If there are more users, the Greeter will handle that
417 if (LightDM.Users.count == 1) {
569 if (LightDM.Users.count == 1) {
@@ -472,10 +624,6 @@ FocusScope {
472 stages.hide()
624 stages.hide()
475− function hideIndicatorMenu(delay) {
476− panel.hideIndicatorMenu(delay);
480 id: overlay
628 id: overlay
@@ -679,4 +827,50 @@ FocusScope {
679 target: SessionBroadcast
827 target: SessionBroadcast
680 onShowHome: showHome()
828 onShowHome: showHome()
832+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
833+ if (!powerKeyTimer.running) {
834+ powerKeyTimer.start();
836+ event.accepted = true;
841+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
842+ powerKeyTimer.stop();
843+ event.accepted = true;
851+ triggeredOnStart: false
854+ stages.showPowerDialog();
859+ id: shutdownFadeOutRectangle
863+ anchors.fill: parent
865+ NumberAnimation on opacity {
870+ if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
871+ DBusUnitySessionService.Shutdown();