on xenial help sign in
Add power dialog
ec7d520Ying-Chun Liu
qml/Shell.qml+42−1
@@ -354,6 +354,47 @@ FocusScope {
354 }
354 }
355 }
355 }
356
356
357+ Component {
358+ id: powerDialog
359+ Dialog {
360+ id: dialoguePower
361+ title: "Power"
362+ text: "What do you want to do?"
363+ Button {
364+ text: "Cancel"
365+ onClicked: {
366+ PopupUtils.close(dialoguePower);
367+ stages.dialogShown = false;
368+ }
369+ }
370+ Button {
371+ text: "Shutdown"
372+ onClicked: {
373+ dBusUnitySessionServiceConnection.closeAllApps();
374+ DBusUnitySessionService.Shutdown();
375+ PopupUtils.close(dialoguePower);
376+ stages.dialogShown = false;
377+ }
378+ }
379+ Button {
380+ text: "Reboot"
381+ onClicked: {
382+ dBusUnitySessionServiceConnection.closeAllApps();
383+ DBusUnitySessionService.Reboot();
384+ PopupUtils.close(dialoguePower);
385+ stages.dialogShown = false;
386+ }
387+ }
388+ }
389+ }
390+
391+ function showPowerDialog() {
392+ if (!stages.dialogShown) {
393+ stages.dialogShown = true;
394+ PopupUtils.open(powerDialog);
395+ }
396+ }
397+
357 Connections {
398 Connections {
358 id: dBusUnitySessionServiceConnection
399 id: dBusUnitySessionServiceConnection
359 objectName: "dBusUnitySessionServiceConnection"
400 objectName: "dBusUnitySessionServiceConnection"
@@ -807,7 +848,7 @@ FocusScope {
807 triggeredOnStart: false
848 triggeredOnStart: false
808
849
809 onTriggered: {
850 onTriggered: {
810− DBusUnitySessionService.RequestShutdown();
851+ stages.showPowerDialog();
811 }
852 }
812 }
853 }
813}
854}