@@ -278,6 +278,8 @@ FocusScope {
278278 }
279279 }
280280
281+ property bool dialogShown: false
282+
281283 Component {
282284 id: logoutDialog
283285 Dialog {
@@ -286,13 +288,17 @@ FocusScope {
286288 text: "Are you sure that you want to logout?"
287289 Button {
288290 text: "Cancel"
289− onClicked: PopupUtils.close(dialogueLogout)
291+ onClicked: {
292+ PopupUtils.close(dialogueLogout);
293+ stages.dialogShown = false;
294+ }
290295 }
291296 Button {
292297 text: "Yes"
293298 onClicked: {
294299 DBusUnitySessionService.Logout();
295300 PopupUtils.close(dialogueLogout);
301+ stages.dialogShown = false;
296302 }
297303 }
298304 }
@@ -306,7 +312,10 @@ FocusScope {
306312 text: "Are you sure that you want to shutdown?"
307313 Button {
308314 text: "Cancel"
309− onClicked: PopupUtils.close(dialogueShutdown)
315+ onClicked: {
316+ PopupUtils.close(dialogueShutdown);
317+ stages.dialogShown = false;
318+ }
310319 }
311320 Button {
312321 text: "Yes"
@@ -314,6 +323,7 @@ FocusScope {
314323 dBusUnitySessionServiceConnection.closeAllApps();
315324 DBusUnitySessionService.Shutdown();
316325 PopupUtils.close(dialogueShutdown);
326+ stages.dialogShown = false;
317327 }
318328 }
319329 }
@@ -327,7 +337,10 @@ FocusScope {
327337 text: "Are you sure that you want to reboot?"
328338 Button {
329339 text: "Cancel"
330− onClicked: PopupUtils.close(dialogueReboot)
340+ onClicked: {
341+ PopupUtils.close(dialogueReboot)
342+ stages.dialogShown = false;
343+ }
331344 }
332345 Button {
333346 text: "Yes"
@@ -335,6 +348,7 @@ FocusScope {
335348 dBusUnitySessionServiceConnection.closeAllApps();
336349 DBusUnitySessionService.Reboot();
337350 PopupUtils.close(dialogueReboot);
351+ stages.dialogShown = false;
338352 }
339353 }
340354 }
@@ -356,17 +370,26 @@ FocusScope {
356370
357371 onLogoutRequested: {
358372 // Display a dialog to ask the user to confirm.
359− PopupUtils.open(logoutDialog);
373+ if (!stages.dialogShown) {
374+ stages.dialogShown = true;
375+ PopupUtils.open(logoutDialog);
376+ }
360377 }
361378
362379 onShutdownRequested: {
363380 // Display a dialog to ask the user to confirm.
364− PopupUtils.open(shutdownDialog);
381+ if (!stages.dialogShown) {
382+ stages.dialogShown = true;
383+ PopupUtils.open(shutdownDialog);
384+ }
365385 }
366386
367387 onRebootRequested: {
368388 // Display a dialog to ask the user to confirm.
369− PopupUtils.open(rebootDialog);
389+ if (!stages.dialogShown) {
390+ stages.dialogShown = true;
391+ PopupUtils.open(rebootDialog);
392+ }
370393 }
371394
372395 onLogoutReady: {
@@ -759,4 +782,31 @@ FocusScope {
759782 target: SessionBroadcast
760783 onShowHome: showHome()
761784 }
785+
786+ Keys.onPressed: {
787+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
788+ if (!powerKeyTimer.running) {
789+ powerKeyTimer.start();
790+ }
791+ event.accepted = true;
792+ }
793+ }
794+
795+ Keys.onReleased: {
796+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
797+ powerKeyTimer.stop();
798+ }
799+ event.accepted = true;
800+ }
801+
802+ Timer {
803+ id: powerKeyTimer
804+ interval: 500
805+ repeat: false
806+ triggeredOnStart: false
807+
808+ onTriggered: {
809+ DBusUnitySessionService.RequestShutdown();
810+ }
811+ }
762812}