@@ -94,9 +94,7 @@ Item {
9494
9595 Keys.onPressed: {
9696 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
97− if (!powerKeyTimer.running) {
98− powerKeyTimer.start();
99− }
97+ dialogs.onPowerKeyPressed();
10098 event.accepted = true;
10199 } else {
102100 event.accepted = false;
@@ -105,7 +103,7 @@ Item {
105103
106104 Keys.onReleased: {
107105 if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
108− powerKeyTimer.stop();
106+ dialogs.onPowerKeyReleased();
109107 event.accepted = true;
110108 } else {
111109 event.accepted = false;
@@ -271,170 +269,6 @@ Item {
271269 }
272270 }
273271
274− property bool dialogShown: false
275−
276− Component {
277− id: logoutDialog
278− Dialog {
279− id: dialogueLogout
280− title: "Logout"
281− text: "Are you sure that you want to logout?"
282− Button {
283− text: "Cancel"
284− onClicked: {
285− PopupUtils.close(dialogueLogout);
286− stages.dialogShown = false;
287− }
288− }
289− Button {
290− text: "Yes"
291− onClicked: {
292− DBusUnitySessionService.Logout();
293− PopupUtils.close(dialogueLogout);
294− stages.dialogShown = false;
295− }
296− }
297− }
298− }
299−
300− Component {
301− id: shutdownDialog
302− Dialog {
303− id: dialogueShutdown
304− title: "Shutdown"
305− text: "Are you sure that you want to shutdown?"
306− Button {
307− text: "Cancel"
308− onClicked: {
309− PopupUtils.close(dialogueShutdown);
310− stages.dialogShown = false;
311− }
312− }
313− Button {
314− text: "Yes"
315− onClicked: {
316− dBusUnitySessionServiceConnection.closeAllApps();
317− DBusUnitySessionService.Shutdown();
318− PopupUtils.close(dialogueShutdown);
319− stages.dialogShown = false;
320− }
321− }
322− }
323− }
324−
325− Component {
326− id: rebootDialog
327− Dialog {
328− id: dialogueReboot
329− title: "Reboot"
330− text: "Are you sure that you want to reboot?"
331− Button {
332− text: "Cancel"
333− onClicked: {
334− PopupUtils.close(dialogueReboot)
335− stages.dialogShown = false;
336− }
337− }
338− Button {
339− text: "Yes"
340− onClicked: {
341− dBusUnitySessionServiceConnection.closeAllApps();
342− DBusUnitySessionService.Reboot();
343− PopupUtils.close(dialogueReboot);
344− stages.dialogShown = false;
345− }
346− }
347− }
348− }
349−
350− Component {
351− id: powerDialog
352− Dialog {
353− id: dialoguePower
354− title: "Power"
355− text: i18n.tr("Are you sure you would like to turn power off?")
356− Button {
357− text: i18n.tr("Power off")
358− onClicked: {
359− dBusUnitySessionServiceConnection.closeAllApps();
360− PopupUtils.close(dialoguePower);
361− stages.dialogShown = false;
362− shutdownFadeOutRectangle.enabled = true;
363− shutdownFadeOutRectangle.visible = true;
364− shutdownFadeOut.start();
365− }
366− }
367− Button {
368− text: i18n.tr("Restart")
369− onClicked: {
370− dBusUnitySessionServiceConnection.closeAllApps();
371− DBusUnitySessionService.Reboot();
372− PopupUtils.close(dialoguePower);
373− stages.dialogShown = false;
374− }
375− }
376− Button {
377− text: i18n.tr("Cancel")
378− onClicked: {
379− PopupUtils.close(dialoguePower);
380− stages.dialogShown = false;
381− }
382− }
383− }
384− }
385−
386− function showPowerDialog() {
387− if (!stages.dialogShown) {
388− stages.dialogShown = true;
389− PopupUtils.open(powerDialog);
390− }
391− }
392−
393− Connections {
394− id: dBusUnitySessionServiceConnection
395− objectName: "dBusUnitySessionServiceConnection"
396− target: DBusUnitySessionService
397−
398− function closeAllApps() {
399− while (true) {
400− var app = ApplicationManager.get(0);
401− if (app === null) {
402− break;
403− }
404− ApplicationManager.stopApplication(app.appId);
405− }
406− }
407−
408− onLogoutRequested: {
409− // Display a dialog to ask the user to confirm.
410− if (!stages.dialogShown) {
411− stages.dialogShown = true;
412− PopupUtils.open(logoutDialog);
413− }
414− }
415−
416− onShutdownRequested: {
417− // Display a dialog to ask the user to confirm.
418− if (!stages.dialogShown) {
419− stages.dialogShown = true;
420− PopupUtils.open(shutdownDialog);
421− }
422− }
423−
424− onRebootRequested: {
425− // Display a dialog to ask the user to confirm.
426− if (!stages.dialogShown) {
427− stages.dialogShown = true;
428− PopupUtils.open(rebootDialog);
429− }
430− }
431−
432− onLogoutReady: {
433− closeAllApps();
434− Qt.quit();
435− }
436− }
437−
438272 Loader {
439273 id: applicationsDisplayLoader
440274 anchors.fill: parent
@@ -812,11 +646,22 @@ Item {
812646 value: "unity8"
813647 }
814648
649+ Dialogs {
650+ id: dialogs
651+ anchors.fill: parent
652+ z: overlay.z + 10
653+ onPowerOffClicked: {
654+ shutdownFadeOutRectangle.enabled = true;
655+ shutdownFadeOutRectangle.visible = true;
656+ shutdownFadeOut.start();
657+ }
658+ }
659+
815660 Label {
816661 id: alphaDisclaimerLabel
817662 anchors.centerIn: parent
818663 visible: ApplicationManager.fake ? ApplicationManager.fake : false
819− z: overlay.z + 10
664+ z: dialogs.z + 10
820665 text: "EARLY ALPHA\nNOT READY FOR USE"
821666 color: "lightgrey"
822667 opacity: 0.2
@@ -843,19 +688,9 @@ Item {
843688 onShowHome: showHome()
844689 }
845690
846− Timer {
847− id: powerKeyTimer
848− interval: 2000
849− repeat: false
850− triggeredOnStart: false
851−
852− onTriggered: {
853− stages.showPowerDialog();
854− }
855− }
856−
857691 Rectangle {
858692 id: shutdownFadeOutRectangle
693+ z: edgeDemo.z + 10
859694 enabled: false
860695 visible: false
861696 color: "black"
@@ -872,4 +707,5 @@ Item {
872707 }
873708 }
874709 }
710+
875711}