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
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);
27
38
function onPowerKeyPressed() {
28
39
// FIXME: event.isAutoRepeat is always false on Nexus 4.
29
40
// So we use powerKeyTimer.running to avoid the PowerOff key repeat
43
54
id: d // private stuff
55
objectName: "dialogsPrivate"
45
property bool dialogShown: false
47
58
function showPowerDialog() {
50
PopupUtils.open(powerDialog, root, {"z": root.z});
59
if (!dialogLoader.active) {
60
dialogLoader.sourceComponent = powerDialogComponent;
61
dialogLoader.active = true;
83
id: logoutDialogComponent
70
86
title: i18n.tr("Log out")
71
87
text: i18n.tr("Are you sure you want to log out?")
73
89
text: i18n.tr("No")
75
PopupUtils.close(dialogueLogout);
76
d.dialogShown = false;
80
95
text: i18n.tr("Yes")
82
DBusUnitySessionService.Logout();
83
PopupUtils.close(dialogueLogout);
84
d.dialogShown = false;
97
unitySessionService.logout();
105
id: shutdownDialogComponent
94
108
title: i18n.tr("Shut down")
95
109
text: i18n.tr("Are you sure you want to shut down?")
97
111
text: i18n.tr("No")
99
PopupUtils.close(dialogueShutdown);
100
d.dialogShown = false;
113
shutdownDialog.hide();
104
117
text: i18n.tr("Yes")
106
dBusUnitySessionServiceConnection.closeAllApps();
107
DBusUnitySessionService.Shutdown();
108
PopupUtils.close(dialogueShutdown);
109
d.dialogShown = false;
120
unitySessionService.shutdown();
121
shutdownDialog.hide();
128
id: rebootDialogComponent
119
131
title: i18n.tr("Reboot")
120
132
text: i18n.tr("Are you sure you want to reboot?")
122
134
text: i18n.tr("No")
124
PopupUtils.close(dialogueReboot)
125
d.dialogShown = false;
129
140
text: i18n.tr("Yes")
131
dBusUnitySessionServiceConnection.closeAllApps();
132
DBusUnitySessionService.Reboot();
133
PopupUtils.close(dialogueReboot);
134
d.dialogShown = false;
143
unitySessionService.reboot();
151
id: powerDialogComponent
144
154
title: i18n.tr("Power")
145
155
text: i18n.tr("Are you sure you would like\nto power off?")
147
157
text: i18n.tr("Power off")
149
dBusUnitySessionServiceConnection.closeAllApps();
150
PopupUtils.close(dialoguePower);
151
d.dialogShown = false;
152
161
root.powerOffClicked();
154
163
color: UbuntuColors.red
157
166
text: i18n.tr("Restart")
159
dBusUnitySessionServiceConnection.closeAllApps();
160
DBusUnitySessionService.Reboot();
161
PopupUtils.close(dialoguePower);
162
d.dialogShown = false;
169
unitySessionService.reboot();
164
172
color: UbuntuColors.green
167
175
text: i18n.tr("Cancel")
169
PopupUtils.close(dialoguePower);
170
d.dialogShown = false;
172
179
color: UbuntuColors.coolGrey
179
id: dBusUnitySessionServiceConnection
180
objectName: "dBusUnitySessionServiceConnection"
181
target: DBusUnitySessionService
183
function closeAllApps() {
185
var app = ApplicationManager.get(0);
189
ApplicationManager.stopApplication(app.appId);
185
target: root.unitySessionService
193
187
onLogoutRequested: {
194
188
// Display a dialog to ask the user to confirm.
195
if (!d.dialogShown) {
196
d.dialogShown = true;
197
PopupUtils.open(logoutDialog, root, {"z": root.z});
189
if (!dialogLoader.active) {
190
dialogLoader.sourceComponent = logoutDialogComponent;
191
dialogLoader.active = true;
201
195
onShutdownRequested: {
202
196
// Display a dialog to ask the user to confirm.
203
if (!d.dialogShown) {
204
d.dialogShown = true;
205
PopupUtils.open(shutdownDialog, root, {"z": root.z});
197
if (!dialogLoader.active) {
198
dialogLoader.sourceComponent = shutdownDialogComponent;
199
dialogLoader.active = true;
209
203
onRebootRequested: {
210
204
// Display a dialog to ask the user to confirm.
211
if (!d.dialogShown) {
212
d.dialogShown = true;
213
PopupUtils.open(rebootDialog, root, {"z": root.z});
205
if (!dialogLoader.active) {
206
dialogLoader.sourceComponent = rebootDialogComponent;
207
dialogLoader.active = true;