19
19
import Unity.Application 0.1
20
20
import Unity.Session 0.1
21
21
import Ubuntu.Components 1.1
22
import Ubuntu.Components.Popups 0.1
27
// Explicitly use the right domain for this widget because it might be used
28
// in other applications like the welcome wizard.
29
readonly property string domain: "unity8"
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);
31
38
function onPowerKeyPressed() {
32
39
// FIXME: event.isAutoRepeat is always false on Nexus 4.
74
title: i18n.dtr(root.domain, "Log out")
75
text: i18n.dtr(root.domain, "Are you sure you want to log out?")
77
text: i18n.dtr(root.domain, "No")
79
PopupUtils.close(dialogueLogout);
80
d.dialogShown = false;
84
text: i18n.dtr(root.domain, "Yes")
86
DBusUnitySessionService.Logout();
87
PopupUtils.close(dialogueLogout);
88
d.dialogShown = false;
98
title: i18n.dtr(root.domain, "Shut down")
99
text: i18n.dtr(root.domain, "Are you sure you want to shut down?")
101
text: i18n.dtr(root.domain, "No")
103
PopupUtils.close(dialogueShutdown);
104
d.dialogShown = false;
108
text: i18n.dtr(root.domain, "Yes")
110
dBusUnitySessionServiceConnection.closeAllApps();
111
DBusUnitySessionService.Shutdown();
112
PopupUtils.close(dialogueShutdown);
113
d.dialogShown = false;
123
title: i18n.dtr(root.domain, "Reboot")
124
text: i18n.dtr(root.domain, "Are you sure you want to reboot?")
126
text: i18n.dtr(root.domain, "No")
128
PopupUtils.close(dialogueReboot)
129
d.dialogShown = false;
133
text: i18n.dtr(root.domain, "Yes")
135
dBusUnitySessionServiceConnection.closeAllApps();
136
DBusUnitySessionService.Reboot();
137
PopupUtils.close(dialogueReboot);
138
d.dialogShown = false;
148
title: i18n.dtr(root.domain, "Power")
149
text: i18n.dtr(root.domain, "Are you sure you would like\nto power off?")
151
text: i18n.dtr(root.domain, "Power off")
153
dBusUnitySessionServiceConnection.closeAllApps();
154
PopupUtils.close(dialoguePower);
155
d.dialogShown = 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")
156
161
root.powerOffClicked();
158
163
color: UbuntuColors.red
161
text: i18n.dtr(root.domain, "Restart")
166
text: i18n.tr("Restart")
163
dBusUnitySessionServiceConnection.closeAllApps();
164
DBusUnitySessionService.Reboot();
165
PopupUtils.close(dialoguePower);
166
d.dialogShown = false;
169
unitySessionService.reboot();
168
172
color: UbuntuColors.green
171
text: i18n.dtr(root.domain, "Cancel")
175
text: i18n.tr("Cancel")
173
PopupUtils.close(dialoguePower);
174
d.dialogShown = false;
176
179
color: UbuntuColors.coolGrey
183
id: dBusUnitySessionServiceConnection
184
objectName: "dBusUnitySessionServiceConnection"
185
target: DBusUnitySessionService
187
function closeAllApps() {
189
var app = ApplicationManager.get(0);
193
ApplicationManager.stopApplication(app.appId);
185
target: root.unitySessionService
197
187
onLogoutRequested: {
198
188
// Display a dialog to ask the user to confirm.
199
if (!d.dialogShown) {
200
d.dialogShown = true;
201
PopupUtils.open(logoutDialog, root, {"z": root.z});
189
if (!dialogLoader.active) {
190
dialogLoader.sourceComponent = logoutDialogComponent;
191
dialogLoader.active = true;
205
195
onShutdownRequested: {
206
196
// Display a dialog to ask the user to confirm.
207
if (!d.dialogShown) {
208
d.dialogShown = true;
209
PopupUtils.open(shutdownDialog, root, {"z": root.z});
197
if (!dialogLoader.active) {
198
dialogLoader.sourceComponent = shutdownDialogComponent;
199
dialogLoader.active = true;
213
203
onRebootRequested: {
214
204
// Display a dialog to ask the user to confirm.
215
if (!d.dialogShown) {
216
d.dialogShown = true;
217
PopupUtils.open(rebootDialog, root, {"z": root.z});
205
if (!dialogLoader.active) {
206
dialogLoader.sourceComponent = rebootDialogComponent;
207
dialogLoader.active = true;