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 LightDM 0.1 as LightDM
27 // to be set from outside, useful mostly for testing purposes
28 property var unitySessionService: DBusUnitySessionService
29 property var closeAllApps: function() {
31 var app = ApplicationManager.get(0);
35 ApplicationManager.stopApplication(app.appId);
39 signal powerOffClicked();
41 function showPowerDialog() {
46 id: d // private stuff
47 objectName: "dialogsPrivate"
50 function showPowerDialog() {
51 if (!dialogLoader.active) {
52 dialogLoader.sourceComponent = powerDialogComponent;
53 dialogLoader.active = true;
64 id: logoutDialogComponent
67 title: i18n.tr("Log out")
68 text: i18n.tr("Are you sure you want to log out?")
72 LightDM.Greeter.showGreeter()
77 text: i18n.tr("Log Out")
79 unitySessionService.logout();
84 text: i18n.tr("Cancel")
93 id: shutdownDialogComponent
96 title: i18n.tr("Shut down")
97 text: i18n.tr("Are you sure you want to shut down?")
99 text: i18n.tr("Reboot")
102 unitySessionService.reboot();
103 shutdownDialog.hide();
107 text: i18n.tr("Shutdown")
110 unitySessionService.shutdown();
111 shutdownDialog.hide();
115 text: i18n.tr("Cancel")
117 shutdownDialog.hide();
124 id: rebootDialogComponent
127 title: i18n.tr("Reboot")
128 text: i18n.tr("Are you sure you want to reboot?")
139 unitySessionService.reboot();
147 id: powerDialogComponent
150 title: i18n.tr("Power")
151 text: i18n.tr("Are you sure you would like\nto power off?")
153 text: i18n.tr("Power off")
157 root.powerOffClicked();
159 color: UbuntuColors.red
162 text: i18n.tr("Restart")
165 unitySessionService.reboot();
168 color: UbuntuColors.green
171 text: i18n.tr("Cancel")
175 color: UbuntuColors.coolGrey
181 target: root.unitySessionService
184 // Display a dialog to ask the user to confirm.
185 if (!dialogLoader.active) {
186 dialogLoader.sourceComponent = logoutDialogComponent;
187 dialogLoader.active = true;
191 onShutdownRequested: {
192 // Display a dialog to ask the user to confirm.
193 if (!dialogLoader.active) {
194 dialogLoader.sourceComponent = shutdownDialogComponent;
195 dialogLoader.active = true;
200 // Display a dialog to ask the user to confirm.
201 if (!dialogLoader.active) {
202 dialogLoader.sourceComponent = rebootDialogComponent;
203 dialogLoader.active = true;
210 unitySessionService.endSession();