@@ -19,8 +19,10 @@ 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
26import LightDM 0.1 as LightDM
25import Powerd 0.1
27import Powerd 0.1
26import SessionBroadcast 0.1
28import SessionBroadcast 0.1
@@ -34,7 +36,7 @@ import "Stages"
34import Unity.Notifications 1.0 as NotificationBackend
36import Unity.Notifications 1.0 as NotificationBackend
35import Unity.Session 0.1
37import Unity.Session 0.1
40 // this is only here to select the width / height of the window if not running fullscreen
42 // this is only here to select the width / height of the window if not running fullscreen
@@ -85,8 +87,31 @@ FocusScope {
85 id: volumeControl
87 id: volumeControl
91+ // Handle but do not filter out volume keys
88− Keys.onVolumeUpPressed: volumeControl.volumeUp()
92+ Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }
89− Keys.onVolumeDownPressed: volumeControl.volumeDown()
93+ Keys.onVolumeDownPressed: { volumeControl.volumeDown(); event.accepted = false; }
96+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
97+ if (!powerKeyTimer.running) {
98+ powerKeyTimer.start();
100+ event.accepted = true;
102+ event.accepted = false;
107+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
108+ powerKeyTimer.stop();
109+ event.accepted = true;
111+ event.accepted = false;
92 id: underlay
117 id: underlay
@@ -95,9 +120,6 @@ FocusScope {
96 // Whether the underlay is fully covered by opaque UI elements.
121 // Whether the underlay is fully covered by opaque UI elements.
97 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
122 property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
99− // NB! Application surfaces are stacked behind the shell one. So they can only be seen by the user
100− // through the translucent parts of the shell surface.
101 visible: !fullyCovered
123 visible: !fullyCovered
@@ -169,14 +191,23 @@ FocusScope {
170 visible: !fullyHidden && !ApplicationManager.empty
192 visible: !fullyHidden && !ApplicationManager.empty
199+ return launcher.progress;
172− x: shown ? launcher.progress : stagesDragArea.progress
201+ return stagesDragArea.progress
173 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
204 Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
175 property bool shown: false
206 property bool shown: false
176 onShownChanged: {
207 onShownChanged: {
177 if (shown) {
208 if (shown) {
178− if (ApplicationManager.topmostApplication) {
209+ if (ApplicationManager.count > 0) {
179− ApplicationManager.focusApplication(ApplicationManager.topmostApplication.appId);
210+ ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
182 if (ApplicationManager.focusedApplicationId) {
213 if (ApplicationManager.focusedApplicationId) {
@@ -194,6 +225,8 @@ FocusScope {
194 property bool fullyShown: x == 0
225 property bool fullyShown: x == 0
195 property bool fullyHidden: x == width
226 property bool fullyHidden: x == width
228+ property bool locked: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.locked : false
197 // It might technically not be fullyShown but visually it just looks so.
230 // It might technically not be fullyShown but visually it just looks so.
198 property bool roughlyFullyShown: x >= 0 && x <= units.gu(1)
231 property bool roughlyFullyShown: x >= 0 && x <= units.gu(1)
@@ -230,7 +263,128 @@ FocusScope {
266+ property bool dialogShown: false
273+ text: "Are you sure that you want to logout?"
277+ PopupUtils.close(dialogueLogout);
278+ stages.dialogShown = false;
284+ DBusUnitySessionService.Logout();
285+ PopupUtils.close(dialogueLogout);
286+ stages.dialogShown = false;
295+ id: dialogueShutdown
297+ text: "Are you sure that you want to shutdown?"
301+ PopupUtils.close(dialogueShutdown);
302+ stages.dialogShown = false;
308+ dBusUnitySessionServiceConnection.closeAllApps();
309+ DBusUnitySessionService.Shutdown();
310+ PopupUtils.close(dialogueShutdown);
311+ stages.dialogShown = false;
322+ text: "Are you sure that you want to reboot?"
326+ PopupUtils.close(dialogueReboot)
327+ stages.dialogShown = false;
333+ dBusUnitySessionServiceConnection.closeAllApps();
334+ DBusUnitySessionService.Reboot();
335+ PopupUtils.close(dialogueReboot);
336+ stages.dialogShown = false;
347+ text: i18n.tr("Are you sure you would like to turn power off?")
349+ text: i18n.tr("Power off")
351+ dBusUnitySessionServiceConnection.closeAllApps();
352+ PopupUtils.close(dialoguePower);
353+ stages.dialogShown = false;
354+ shutdownFadeOutRectangle.enabled = true;
355+ shutdownFadeOutRectangle.visible = true;
356+ shutdownFadeOut.start();
360+ text: i18n.tr("Restart")
362+ dBusUnitySessionServiceConnection.closeAllApps();
363+ DBusUnitySessionService.Reboot();
364+ PopupUtils.close(dialoguePower);
365+ stages.dialogShown = false;
369+ text: i18n.tr("Cancel")
371+ PopupUtils.close(dialoguePower);
372+ stages.dialogShown = false;
378+ function showPowerDialog() {
379+ if (!stages.dialogShown) {
380+ stages.dialogShown = true;
381+ PopupUtils.open(powerDialog);
233 Connections {
385 Connections {
386+ id: dBusUnitySessionServiceConnection
387+ objectName: "dBusUnitySessionServiceConnection"
234 target: DBusUnitySessionService
388 target: DBusUnitySessionService
236 function closeAllApps() {
390 function closeAllApps() {
@@ -244,8 +398,27 @@ FocusScope {
246 onLogoutRequested: {
400 onLogoutRequested: {
401+ // Display a dialog to ask the user to confirm.
402+ if (!stages.dialogShown) {
403+ stages.dialogShown = true;
404+ PopupUtils.open(logoutDialog);
408+ onShutdownRequested: {
247− // TODO: Display a dialog to ask the user to confirm.
409+ // Display a dialog to ask the user to confirm.
248− DBusUnitySessionService.Logout();
410+ if (!stages.dialogShown) {
411+ stages.dialogShown = true;
412+ PopupUtils.open(shutdownDialog);
416+ onRebootRequested: {
417+ // Display a dialog to ask the user to confirm.
418+ if (!stages.dialogShown) {
419+ stages.dialogShown = true;
420+ PopupUtils.open(rebootDialog);
251 onLogoutReady: {
424 onLogoutReady: {
@@ -274,14 +447,14 @@ FocusScope {
274 Binding {
447 Binding {
275 target: applicationsDisplayLoader.item
448 target: applicationsDisplayLoader.item
276 property: "interactive"
449 property: "interactive"
277− value: stages.roughlyFullyShown
450+ value: stages.roughlyFullyShown && !greeter.shown && !lockscreen.shown
282 InputMethod {
455 InputMethod {
283 id: inputMethod
456 id: inputMethod
284− anchors.fill: parent
457+ anchors { fill: parent; topMargin: panel.panelHeight }
285 z: notifications.useModal || panel.indicators.shown ? overlay.z + 1 : overlay.z - 1
458 z: notifications.useModal || panel.indicators.shown ? overlay.z + 1 : overlay.z - 1
@@ -337,6 +510,8 @@ FocusScope {
337 Connections {
510 Connections {
338 target: LightDM.Greeter
511 target: LightDM.Greeter
513+ onShowGreeter: greeter.show()
340 onShowPrompt: {
515 onShowPrompt: {
341 if (LightDM.Users.count == 1) {
516 if (LightDM.Users.count == 1) {
342 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
517 // TODO: There's no better way for now to determine if its a PIN or a passphrase.
@@ -362,6 +537,12 @@ FocusScope {
541+ target: LightDM.Greeter
543+ value: greeter.shown || lockscreen.shown
365 Rectangle {
546 Rectangle {
366 anchors.fill: parent
547 anchors.fill: parent
367 color: "black"
548 color: "black"
@@ -401,6 +582,9 @@ FocusScope {
401 onShownChanged: {
582 onShownChanged: {
402 if (shown) {
583 if (shown) {
403 lockscreen.reset();
584 lockscreen.reset();
585+ if (!LightDM.Greeter.promptless) {
404 // If there is only one user, we start authenticating with that one here.
588 // If there is only one user, we start authenticating with that one here.
405 // If there are more users, the Greeter will handle that
589 // If there are more users, the Greeter will handle that
406 if (LightDM.Users.count == 1) {
590 if (LightDM.Users.count == 1) {
@@ -477,8 +661,8 @@ FocusScope {
479 property bool topmostApplicationIsFullscreen:
663 property bool topmostApplicationIsFullscreen:
480− ApplicationManager.topmostApplication &&
664+ ApplicationManager.focusedApplicationId &&
481− ApplicationManager.topmostApplication.fullscreen
665+ ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
483 fullscreenMode: stages.roughlyFullyShown && topmostApplicationIsFullscreen
667 fullscreenMode: stages.roughlyFullyShown && topmostApplicationIsFullscreen
484 && !greeter.shown && !lockscreen.shown
668 && !greeter.shown && !lockscreen.shown
@@ -565,9 +749,6 @@ FocusScope {
569− onFocusChanged: if (!focus) forceActiveFocus();
571 Binding {
752 Binding {
572 target: i18n
753 target: i18n
573 property: "domain"
754 property: "domain"
@@ -604,4 +785,34 @@ FocusScope {
604 target: SessionBroadcast
785 target: SessionBroadcast
605 onShowHome: showHome()
786 onShowHome: showHome()
793+ triggeredOnStart: false
796+ stages.showPowerDialog();
801+ id: shutdownFadeOutRectangle
805+ anchors.fill: parent
807+ NumberAnimation on opacity {
812+ if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
813+ DBusUnitySessionService.Shutdown();