2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import Unity.Application 0.1
20 import Unity.Session 0.1
21 import Ubuntu.Components 1.1
22 import Ubuntu.Components.Popups 0.1
27 function onPowerKeyPressed() {
28 // FIXME: event.isAutoRepeat is always false on Nexus 4.
29 // So we use powerKeyTimer.running to avoid the PowerOff key repeat
30 // https://launchpad.net/bugs/1349416
31 if (!powerKeyTimer.running) {
32 powerKeyTimer.restart();
36 function onPowerKeyReleased() {
40 signal powerOffClicked();
43 id: d // private stuff
45 property bool dialogShown: false
47 function showPowerDialog() {
50 PopupUtils.open(powerDialog, root, {"z": root.z});
59 triggeredOnStart: false
70 title: i18n.tr("Log out")
71 text: i18n.tr("Are you sure you want to log out?")
75 PopupUtils.close(dialogueLogout);
76 d.dialogShown = false;
82 DBusUnitySessionService.Logout();
83 PopupUtils.close(dialogueLogout);
84 d.dialogShown = false;
94 title: i18n.tr("Shut down")
95 text: i18n.tr("Are you sure you want to shut down?")
99 PopupUtils.close(dialogueShutdown);
100 d.dialogShown = false;
106 dBusUnitySessionServiceConnection.closeAllApps();
107 DBusUnitySessionService.Shutdown();
108 PopupUtils.close(dialogueShutdown);
109 d.dialogShown = false;
119 title: i18n.tr("Reboot")
120 text: i18n.tr("Are you sure you want to reboot?")
124 PopupUtils.close(dialogueReboot)
125 d.dialogShown = false;
131 dBusUnitySessionServiceConnection.closeAllApps();
132 DBusUnitySessionService.Reboot();
133 PopupUtils.close(dialogueReboot);
134 d.dialogShown = false;
144 title: i18n.tr("Power")
145 text: i18n.tr("Are you sure you would like\nto power off?")
147 text: i18n.tr("Power off")
149 dBusUnitySessionServiceConnection.closeAllApps();
150 PopupUtils.close(dialoguePower);
151 d.dialogShown = false;
152 root.powerOffClicked();
154 color: UbuntuColors.red
157 text: i18n.tr("Cancel")
159 PopupUtils.close(dialoguePower);
160 d.dialogShown = false;
162 color: UbuntuColors.coolGrey
169 id: dBusUnitySessionServiceConnection
170 objectName: "dBusUnitySessionServiceConnection"
171 target: DBusUnitySessionService
173 function closeAllApps() {
175 var app = ApplicationManager.get(0);
179 ApplicationManager.stopApplication(app.appId);
184 // Display a dialog to ask the user to confirm.
185 if (!d.dialogShown) {
186 d.dialogShown = true;
187 PopupUtils.open(logoutDialog, root, {"z": root.z});
191 onShutdownRequested: {
192 // Display a dialog to ask the user to confirm.
193 if (!d.dialogShown) {
194 d.dialogShown = true;
195 PopupUtils.open(shutdownDialog, root, {"z": root.z});
200 // Display a dialog to ask the user to confirm.
201 if (!d.dialogShown) {
202 d.dialogShown = true;
203 PopupUtils.open(rebootDialog, root, {"z": root.z});