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
26 // to be set from outside, useful mostly for testing purposes
27 property var unitySessionService: DBusUnitySessionService
28 property var closeAllApps: function() {
30 var app = ApplicationManager.get(0);
34 ApplicationManager.stopApplication(app.appId);
38 function onPowerKeyPressed() {
39 // FIXME: event.isAutoRepeat is always false on Nexus 4.
40 // So we use powerKeyTimer.running to avoid the PowerOff key repeat
41 // https://launchpad.net/bugs/1349416
42 if (!powerKeyTimer.running) {
43 powerKeyTimer.restart();
47 function onPowerKeyReleased() {
51 signal powerOffClicked();
54 id: d // private stuff
55 objectName: "dialogsPrivate"
58 function showPowerDialog() {
59 if (!dialogLoader.active) {
60 dialogLoader.sourceComponent = powerDialogComponent;
61 dialogLoader.active = true;
75 triggeredOnStart: false
83 id: logoutDialogComponent
86 title: i18n.tr("Log out")
87 text: i18n.tr("Are you sure you want to log out?")
97 unitySessionService.logout();
105 id: shutdownDialogComponent
108 title: i18n.tr("Shut down")
109 text: i18n.tr("Are you sure you want to shut down?")
113 shutdownDialog.hide();
120 unitySessionService.shutdown();
121 shutdownDialog.hide();
128 id: rebootDialogComponent
131 title: i18n.tr("Reboot")
132 text: i18n.tr("Are you sure you want to reboot?")
143 unitySessionService.reboot();
151 id: powerDialogComponent
154 title: i18n.tr("Power")
155 text: i18n.tr("Are you sure you would like\nto power off?")
157 text: i18n.tr("Power off")
161 root.powerOffClicked();
163 color: UbuntuColors.red
166 text: i18n.tr("Restart")
169 unitySessionService.reboot();
172 color: UbuntuColors.green
175 text: i18n.tr("Cancel")
179 color: UbuntuColors.coolGrey
185 target: root.unitySessionService
188 // Display a dialog to ask the user to confirm.
189 if (!dialogLoader.active) {
190 dialogLoader.sourceComponent = logoutDialogComponent;
191 dialogLoader.active = true;
195 onShutdownRequested: {
196 // Display a dialog to ask the user to confirm.
197 if (!dialogLoader.active) {
198 dialogLoader.sourceComponent = shutdownDialogComponent;
199 dialogLoader.active = true;
204 // Display a dialog to ask the user to confirm.
205 if (!dialogLoader.active) {
206 dialogLoader.sourceComponent = rebootDialogComponent;
207 dialogLoader.active = true;