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;
54 dialogLoader.item.forceActiveFocus();
60 objectName: "dialogLoader"
66 id: logoutDialogComponent
69 title: i18n.ctr("Title: Lock/Log out dialog", "Log out")
70 text: i18n.tr("Are you sure you want to log out?")
72 text: i18n.ctr("Button: Lock the system", "Lock")
74 LightDM.Greeter.showGreeter()
79 text: i18n.ctr("Button: Log out from the system", "Log Out")
81 unitySessionService.logout();
86 text: i18n.tr("Cancel")
95 id: shutdownDialogComponent
98 title: i18n.ctr("Title: Reboot/Shut down dialog", "Shut down")
99 text: i18n.tr("Are you sure you want to shut down?")
101 text: i18n.ctr("Button: Reboot the system", "Reboot")
104 unitySessionService.reboot();
105 shutdownDialog.hide();
109 text: i18n.ctr("Button: Shut down the system", "Shut down")
112 unitySessionService.shutdown();
113 shutdownDialog.hide();
117 text: i18n.tr("Cancel")
119 shutdownDialog.hide();
126 id: rebootDialogComponent
129 title: i18n.ctr("Title: Reboot dialog", "Reboot")
130 text: i18n.tr("Are you sure you want to reboot?")
141 unitySessionService.reboot();
149 id: powerDialogComponent
152 title: i18n.ctr("Title: Power off/Restart dialog", "Power")
153 text: i18n.tr("Are you sure you would like\nto power off?")
155 text: i18n.ctr("Button: Power off the system", "Power off")
159 root.powerOffClicked();
161 color: UbuntuColors.red
164 text: i18n.ctr("Button: Restart the system", "Restart")
167 unitySessionService.reboot();
170 color: UbuntuColors.green
173 text: i18n.tr("Cancel")
177 color: UbuntuColors.coolGrey
183 target: root.unitySessionService
186 // Display a dialog to ask the user to confirm.
187 if (!dialogLoader.active) {
188 dialogLoader.sourceComponent = logoutDialogComponent;
189 dialogLoader.active = true;
193 onShutdownRequested: {
194 // Display a dialog to ask the user to confirm.
195 if (!dialogLoader.active) {
196 dialogLoader.sourceComponent = shutdownDialogComponent;
197 dialogLoader.active = true;
202 // Display a dialog to ask the user to confirm.
203 if (!dialogLoader.active) {
204 dialogLoader.sourceComponent = rebootDialogComponent;
205 dialogLoader.active = true;
212 unitySessionService.endSession();