@@ -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
@@ -136,7 +137,7 @@ FocusScope {
137 objectName: "dash"
138 objectName: "dash"
139− available: !greeter.shown && !lockscreen.shown
140+ available: !LightDM.Greeter.active
140 hides: [stages, launcher, panel.indicators]
141 hides: [stages, launcher, panel.indicators]
141 shown: disappearingAnimationProgress !== 1.0 && greeterWrapper.showProgress !== 1.0
142 shown: disappearingAnimationProgress !== 1.0 && greeterWrapper.showProgress !== 1.0
142 enabled: disappearingAnimationProgress === 0.0 && greeterWrapper.showProgress === 0.0 && edgeDemo.dashEnabled
143 enabled: disappearingAnimationProgress === 0.0 && greeterWrapper.showProgress === 0.0 && edgeDemo.dashEnabled
@@ -199,7 +200,7 @@ FocusScope {
201 if (shown) {
202 if (shown) {
202− if (overlayMode || locked) {
203+ if (overlayMode || locked || greeter.fakeActiveForApp !== "") {
203 return 0;
204 return 0;
205 return launcher.progress
206 return launcher.progress
@@ -244,10 +245,17 @@ FocusScope {
244 target: ApplicationManager
245 target: ApplicationManager
246 onFocusRequested: {
247 onFocusRequested: {
248+ if (greeter.fakeActiveForApp !== "" && greeter.fakeActiveForApp !== appId) {
247 stages.show(true);
252 stages.show(true);
250 onFocusedApplicationIdChanged: {
255 onFocusedApplicationIdChanged: {
256+ if (greeter.fakeActiveForApp !== "" && greeter.fakeActiveForApp !== ApplicationManager.focusedApplicationId) {
251 if (ApplicationManager.focusedApplicationId.length > 0) {
259 if (ApplicationManager.focusedApplicationId.length > 0) {
252 stages.show(false);
260 stages.show(false);
@@ -268,7 +276,128 @@ FocusScope {
279+ property bool dialogShown: false
286+ text: "Are you sure that you want to logout?"
290+ PopupUtils.close(dialogueLogout);
291+ stages.dialogShown = false;
297+ DBusUnitySessionService.Logout();
298+ PopupUtils.close(dialogueLogout);
299+ stages.dialogShown = false;
308+ id: dialogueShutdown
310+ text: "Are you sure that you want to shutdown?"
314+ PopupUtils.close(dialogueShutdown);
315+ stages.dialogShown = false;
321+ dBusUnitySessionServiceConnection.closeAllApps();
322+ DBusUnitySessionService.Shutdown();
323+ PopupUtils.close(dialogueShutdown);
324+ stages.dialogShown = false;
335+ text: "Are you sure that you want to reboot?"
339+ PopupUtils.close(dialogueReboot)
340+ stages.dialogShown = false;
346+ dBusUnitySessionServiceConnection.closeAllApps();
347+ DBusUnitySessionService.Reboot();
348+ PopupUtils.close(dialogueReboot);
349+ stages.dialogShown = false;
360+ text: i18n.tr("Are you sure you would like to turn power off?")
362+ text: i18n.tr("Power off")
364+ dBusUnitySessionServiceConnection.closeAllApps();
365+ PopupUtils.close(dialoguePower);
366+ stages.dialogShown = false;
367+ shutdownFadeOutRectangle.enabled = true;
368+ shutdownFadeOutRectangle.visible = true;
369+ shutdownFadeOut.start();
373+ text: i18n.tr("Restart")
375+ dBusUnitySessionServiceConnection.closeAllApps();
376+ DBusUnitySessionService.Reboot();
377+ PopupUtils.close(dialoguePower);
378+ stages.dialogShown = false;
382+ text: i18n.tr("Cancel")
384+ PopupUtils.close(dialoguePower);
385+ stages.dialogShown = false;
391+ function showPowerDialog() {
392+ if (!stages.dialogShown) {
393+ stages.dialogShown = true;
394+ PopupUtils.open(powerDialog);
271 Connections {
398 Connections {
399+ id: dBusUnitySessionServiceConnection
400+ objectName: "dBusUnitySessionServiceConnection"
272 target: DBusUnitySessionService
401 target: DBusUnitySessionService
274 function closeAllApps() {
403 function closeAllApps() {
@@ -282,8 +411,27 @@ FocusScope {
284 onLogoutRequested: {
413 onLogoutRequested: {
414+ // Display a dialog to ask the user to confirm.
415+ if (!stages.dialogShown) {
416+ stages.dialogShown = true;
417+ PopupUtils.open(logoutDialog);
421+ onShutdownRequested: {
285− // TODO: Display a dialog to ask the user to confirm.
422+ // Display a dialog to ask the user to confirm.
286− DBusUnitySessionService.Logout();
423+ if (!stages.dialogShown) {
424+ stages.dialogShown = true;
425+ PopupUtils.open(shutdownDialog);
429+ onRebootRequested: {
430+ // Display a dialog to ask the user to confirm.
431+ if (!stages.dialogShown) {
432+ stages.dialogShown = true;
433+ PopupUtils.open(rebootDialog);
289 onLogoutReady: {
437 onLogoutReady: {
@@ -298,6 +446,11 @@ FocusScope {
299 source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
447 source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
450+ target: applicationsDisplayLoader.item
451+ property: "objectName"
301 Binding {
454 Binding {
302 target: applicationsDisplayLoader.item
455 target: applicationsDisplayLoader.item
303 property: "moving"
456 property: "moving"
@@ -313,6 +466,11 @@ FocusScope {
313 property: "dragAreaWidth"
466 property: "dragAreaWidth"
314 value: shell.edgeSize
467 value: shell.edgeSize
470+ target: applicationsDisplayLoader.item
471+ property: "spreadEnabled"
472+ value: greeter.fakeActiveForApp === "" // to support emergency dialer hack
@@ -337,6 +495,13 @@ FocusScope {
338 onEntered: LightDM.Greeter.respond(passphrase);
496 onEntered: LightDM.Greeter.respond(passphrase);
339 onCancel: greeter.show()
497 onCancel: greeter.show()
499+ greeter.fakeActiveForApp = "dialer-app"
500+ shell.activateApplication("dialer-app")
504+ onShownChanged: if (shown) greeter.fakeActiveForApp = ""
341 Component.onCompleted: {
506 Component.onCompleted: {
342 if (LightDM.Users.count == 1) {
507 if (LightDM.Users.count == 1) {
@@ -348,6 +513,8 @@ FocusScope {
348 Connections {
513 Connections {
349 target: LightDM.Greeter
514 target: LightDM.Greeter
516+ onShowGreeter: greeter.show()
351 onShowPrompt: {
518 onShowPrompt: {
352 if (LightDM.Users.count == 1) {
519 if (LightDM.Users.count == 1) {
353 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
520 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
@@ -367,12 +534,19 @@ FocusScope {
368 if (LightDM.Greeter.authenticated) {
535 if (LightDM.Greeter.authenticated) {
369 lockscreen.hide();
536 lockscreen.hide();
371 lockscreen.clear(true);
539 lockscreen.clear(true);
545+ target: LightDM.Greeter
547+ value: greeter.shown || lockscreen.shown || greeter.fakeActiveForApp != ""
376 Rectangle {
550 Rectangle {
377 anchors.fill: parent
551 anchors.fill: parent
378 color: "black"
552 color: "black"
@@ -393,11 +567,16 @@ FocusScope {
395 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
569 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
570+ onShowProgressChanged: if (LightDM.Greeter.promptless && showProgress === 0) greeter.login()
397 Greeter {
572 Greeter {
398 id: greeter
573 id: greeter
399 objectName: "greeter"
574 objectName: "greeter"
576+ signal sessionStarted() // helpful for tests
578+ property string fakeActiveForApp: ""
401 available: true
580 available: true
402 hides: [launcher, panel.indicators]
581 hides: [launcher, panel.indicators]
403 shown: true
582 shown: true
@@ -409,14 +588,28 @@ FocusScope {
410 dragHandleWidth: shell.edgeSize
589 dragHandleWidth: shell.edgeSize
593+ LightDM.Greeter.startSessionSync();
412 onShownChanged: {
601 onShownChanged: {
413 if (shown) {
602 if (shown) {
414 lockscreen.reset();
603 lockscreen.reset();
604+ if (!LightDM.Greeter.promptless) {
415 // If there is only one user, we start authenticating with that one here.
607 // If there is only one user, we start authenticating with that one here.
416 // If there are more users, the Greeter will handle that
608 // If there are more users, the Greeter will handle that
417 if (LightDM.Users.count == 1) {
609 if (LightDM.Users.count == 1) {
418 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
610 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
612+ greeter.fakeActiveForApp = "";
420 greeter.forceActiveFocus();
613 greeter.forceActiveFocus();
@@ -466,14 +659,38 @@ FocusScope {
468 function showHome() {
661 function showHome() {
662+ if (edgeDemo.running) {
666+ if (LightDM.Greeter.active) {
667+ if (!LightDM.Greeter.promptless) {
469− var animate = !greeter.shown && !stages.shown
673+ var animate = !LightDM.Greeter.active && !stages.shown
471 dash.setCurrentScope("clickscope", animate, false)
674 dash.setCurrentScope("clickscope", animate, false)
472 stages.hide()
675 stages.hide()
475− function hideIndicatorMenu(delay) {
678+ function showDash() {
476− panel.hideIndicatorMenu(delay);
679+ if (LightDM.Greeter.active && !LightDM.Greeter.promptless) {
683+ if (stages.shown && !stages.overlayMode && !stages.locked) {
687+ launcher.switchToNextState("visible");
690+ if (greeter.shown) {
691+ greeter.hideRight();
@@ -483,17 +700,18 @@ FocusScope {
485 id: panel
702 id: panel
486 anchors.fill: parent //because this draws indicator menus
704 anchors.fill: parent //because this draws indicator menus
487 indicators {
705 indicators {
488 hides: [launcher]
706 hides: [launcher]
489− available: edgeDemo.panelEnabled
707+ available: edgeDemo.panelEnabled && greeter.fakeActiveForApp === ""
490 contentEnabled: edgeDemo.panelContentEnabled
708 contentEnabled: edgeDemo.panelContentEnabled
491 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
709 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
492 panelHeight: units.gu(3)
710 panelHeight: units.gu(3)
494 property string focusedAppId: ApplicationManager.focusedApplicationId
712 property string focusedAppId: ApplicationManager.focusedApplicationId
495 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
713 property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
496− fullscreenMode: focusedApplication && stages.fullscreen && !greeter.shown && !lockscreen.shown
714+ fullscreenMode: (focusedApplication && stages.fullscreen && !LightDM.Greeter.active) || greeter.fakeActiveForApp !== ""
498 InputFilterArea {
716 InputFilterArea {
499 anchors {
717 anchors {
@@ -518,6 +736,7 @@ FocusScope {
519 Launcher {
737 Launcher {
520 id: launcher
738 id: launcher
739+ objectName: "launcher"
522 readonly property bool dashSwipe: progress > 0
741 readonly property bool dashSwipe: progress > 0
@@ -525,29 +744,15 @@ FocusScope {
525 anchors.bottom: parent.bottom
744 anchors.bottom: parent.bottom
526 width: parent.width
745 width: parent.width
527 dragAreaWidth: shell.edgeSize
746 dragAreaWidth: shell.edgeSize
528− available: edgeDemo.launcherEnabled
747+ available: edgeDemo.launcherEnabled && greeter.fakeActiveForApp === ""
531− if (edgeDemo.running)
537− if (stages.shown && !stages.overlayMode && !stages.locked) {
541− launcher.switchToNextState("visible");
544− if (greeter.shown) {
749+ onShowDashHome: showHome()
545− greeter.hideRight();
750+ onDash: showDash()
549 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
751 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
550 onLauncherApplicationSelected: {
752 onLauncherApplicationSelected: {
753+ if (greeter.fakeActiveForApp !== "") {
551 if (!edgeDemo.running)
756 if (!edgeDemo.running)
552 shell.activateApplication(appId)
757 shell.activateApplication(appId)
@@ -679,4 +884,50 @@ FocusScope {
679 target: SessionBroadcast
884 target: SessionBroadcast
680 onShowHome: showHome()
885 onShowHome: showHome()
889+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
890+ if (!powerKeyTimer.running) {
891+ powerKeyTimer.start();
893+ event.accepted = true;
898+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
899+ powerKeyTimer.stop();
900+ event.accepted = true;
908+ triggeredOnStart: false
911+ stages.showPowerDialog();
916+ id: shutdownFadeOutRectangle
920+ anchors.fill: parent
922+ NumberAnimation on opacity {
927+ if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
928+ DBusUnitySessionService.Shutdown();