Merge lp:~paulliu/unity8/reboot into lp:unity8

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Michael Zanetti
Approved revision: 858
Merged at revision: 1050
Proposed branch: lp:~paulliu/unity8/reboot
Merge into: lp:unity8
Diff against target: 364 lines (+283/-6)
3 files modified
plugins/Unity/Session/dbusunitysessionservice.cpp (+33/-0)
plugins/Unity/Session/dbusunitysessionservice.h (+61/-4)
qml/Shell.qml (+189/-2)
To merge this branch: bzr merge lp:~paulliu/unity8/reboot
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Zanetti (community) Approve
Michał Sawicz Pending
Review via email: mp+221159@code.launchpad.net

Commit message

Add reboot/shutdown

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
No.

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
No. We need to discuss this in Malta

To post a comment you must log in.
lp:~paulliu/unity8/reboot updated
851. By Ying-Chun Liu on 2014-07-04

merged trunk
* debian/control:
  list qtdeclarative5-ubuntu-ui-toolkit-plugin-gles as an alternative
  choice, since provides are not versionned, should restore installability
  on amd64 and i386
[ Michał Sawicz ]
* Adapt to suru theme.
[ Michael Terry ]
* Fix path in launcher mock after moving our mock icons, to avoid a
  lot of "icon not found" warnings during qmluitests.
* Fix the testMultiGreeter qmluitest. Incoming method variables are
  apparently read-only in Qt5.3. (LP: #1332488)
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Adapt scope mock to new api and quiet unused variable warnings.
* Fix dynamic overlay height. (LP: #1334879)
* Don't center items in CardVerticalJournal, kind of beats the
  purpose... Also don't bind unnecessarily.
[ Ying-Chun Liu ]
* Fix LP:1330957 Fix some failed test cases. (LP: #1330957)
[ Albert Astals ]
* Don't seem to need this waitForRendering And makes test fail in 5.3
[ Alberto Aguirre ]
* Update Powerd plugin and Shell.qml to accommodate changes in the
  display power state notification.
[ Ying-Chun Liu ]
* Add logout support. Reviewed by: Daniel d'Andrada (LP: #1302213)
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)
[ Pawel Stolowski ]
* Extend the hack for click scope categories with the upcoming 'store'
  category: single-tap on results from the 'store' category should
  activate them, instead of requesting a preview. (LP: #1326292)
[ Albert Astals ]
* Drop the " Preview" suffix from Preview title As requested in
  https://bugs.launchpad.net/unity8/+bug/1316671 (LP: #1316671)
[ Michael Terry ]
* Revert split greeter for now. We will bring it back as an option
  for Desktop, but use a big hammer revert right now to get Touch back
  in shape.
[ CI bot ]
* Fix build problems. Reviewed by: Michael Terry (LP: #1328850)
[ Michał Sawicz ]
* Make lockscreen buttons translatable.
[ Albert Astals ]
* Correctly mark these functions as overrides
* Remove connections to non existant signal
* Better test name
* Improvements for headerless categories LVPWH: No section name -> no
  header LVPWH: New hasSectionHeader context property for delegates
  GSV: Add topMargin if no hasSectionHeader (LP: #1326415)
* Make tryVerticalJournal, tryHorizontalJournal and tryOrganicGrid
  work again
[ Michael Zanetti ]
* Don't crash when we get an invalid app from ApplicationManager (LP:
  #1309162)
[ Andrea Cimitan ]
* Workaround for lp1324159 (LP: #1322233, #1324159)
[ CI bot ]
* Resync trunk
[ Florian Boucault ]
* Application startup: changed splash rectangle to be black instead of
  white and added a neat little animation. (LP: #1124265)
[ Michael Terry ]
* Bump version so ubuntu-touch-session can reference this one
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Move env setup past session init in greeter wrapper. (LP: #1325882)
* no change rebuild
* drop dbus-x11 dependency of unity8-greeter, it makes us end up with
  multiple session dbus daemons which breaks many AP tests in the lab
[ Michael Terry ]
* Bump version for Breaks due to unity8-greeter
* In split mode, determine whether the application identifiers in
  AccountsService are click packages or not, so we know the correct
  url prefix to use.
* Start logrotate in the greeter's session.
[ Andrea Cimitan ]
* Passes to make tryCommand -qmljsdebugger=port:3768 to enable
  debug/profiling test apps
* Fixes carousel shadow
[ Michał Sawicz ]
* Use dpkg-architecture, not gcc, to determine the machine triplet.
[ Ying-Chun Liu ]
* Fix ZoomableImage test failure. (LP: #1317254)
[ Albert Astals ]
* We don't need iconutils in this mock
* Don't reserve space for mascot if no mascot is specified (LP:
  #1319343)
* CardHeader is no more, remove stale line in CMakeLists.txt
* GenericScopeViewTest: Wait a bit more Otherwise sometimes we end
  getting up the wrong delegate (maybe one that will be garbage
  collected?) (LP: #1322279)
* Fix crash in organicgridtest
[ Daniel d'Andrada ]
* Remove Shell's underlay background image as it cannot be seen
  anymore Now that the Dash has its own, opaque, background, the
  underlay's background image can no longer be seen. So it's just a
  waste of resources to have it.
[ Michael Terry ]
* Use the same animation when dismissing a greeter slide from the
  launcher as from a normal greeter drag. (LP: #1316513)
[ Michael Zanetti ]
* enhance lockscreen add a retry indication label (e.g. 3 attempts
  left). add an additional label (e.g. phone number for multi sim).
  add a infoPopup (e.g. to display a warning for last retry). add min
  and max limit values. add tests for the above (LP: #1302050)

lp:~paulliu/unity8/reboot updated
852. By Ying-Chun Liu on 2014-07-08

fix dialog

853. By Ying-Chun Liu on 2014-07-08

Merge trunk
[ Nick Dedekind ]
* Added support for TransferMenu
[ Michał Sawicz ]
* Initial code for a payment button widget, to handle purchasing apps
  from the click scope.
[ Nick Dedekind ]
* Moved [Message]MenuItemFacotory from Unity.Indicators plugin to qml
  folder.
[ Albert Astals ]
* EasingCurve: Initialize members
* Fix valgrind warning by not emitting reset on model destructor That
  won't be supported until Qt 5.4 More info at https://bugreports.qt-
  project.org/browse/QTBUG-39780 Warning was ==16693== Invalid read of
  size 8 ==16693== at 0x72B19A0: QQmlContext::isValid() const
  (qqmlcontext.cpp:231) ==16693== by 0x736C82B:
  QQmlDelegateModelPrivate::emitChanges() (qqmldelegatemodel.cpp:1412)
  ==16693== by 0x7372AE6: QQmlDelegateModel::_q_modelReset()
  (qqmldelegatemodel.cpp:1463) ==16693== by 0x7397224:
  QQmlDelegateModel::qt_static_metacall(QObject*, QMetaObject::Call,
  int, void**) (moc_qqmldelegatemodel_p.cpp:196) ==16693== by
  0x739769E: QQmlDelegateModel::qt_metacall(QMetaObject::Call, int,
  void**) (moc_qqmldelegatemodel_p.cpp:292) ==16693== by 0x66379CC:
  QMetaObject::activate(QObject*, int, int, void**) (in
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.3.0) ==16693== by
  0x65AEEFD: QAbstractItemModel::endResetModel() (in /usr/lib/x86_64-
  linux-gnu/libQt5Core.so.5.3.0) ==16693== by 0x23461EFD:
  FakeIndicatorsModel::unload() (fakeindicatorsmodel.cpp:53) ==16693==
  by 0x23461E13: FakeIndicatorsModel::~FakeIndicatorsModel()
  (fakeindicatorsmodel.cpp:34) ==16693== by 0x2345C073:
  QQmlPrivate::QQmlElement<FakeIndicatorsModel>::~QQmlElement() (in
  /home/tsdgeos_work/phablet/unity8/investigate_test_shell_crash/build
  dir/tests/mocks/Unity/Indicators/libIndicatorsFakeQml.so) ==16693==
  by 0x2345C0A3:
  QQmlPrivate::QQmlElement<FakeIndicatorsModel>::~QQmlElement()
  (qqmlprivate.h:106) ==16693== by 0x663636B:
  QObjectPrivate::deleteChildren() (in /usr/lib/x86_64-linux-
  gnu/libQt5Core.so.5.3.0) ==16693== Address 0x1862d448 is 8 bytes
  inside a block of size 16 free'd ==16693== at 0x4C2C2BC: operator
  delete(void*) (vg_replace_malloc.c:503) ==16693== by 0x72B21B8:
  QQmlContextData::destroy() (qqmlcontext.cpp:647) ==16693== by
  0x7293458: QQmlPrivate::qdeclarativeelement_destructor(QObject*)
  (qqmlengine.cpp:612) ==16693== by 0x6C0CADD:
  QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement()
  (qqmlprivate.h:105) ==16693== by 0x663636B:
  QObjectPrivate::deleteChildren() (in /usr/lib/x86_64-linux-
  gnu/libQt5Core.so.5.3.0) ==16693== by 0x663F0EB: QObject::~QObject()
  (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.3.0) ==16693== by
  0x6BF64B5: QQuickItem::~QQuickItem() (qquickitem.cpp:2064) ==16693==
  by 0x6C0CAE5: QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement()
  (qqmlprivate.h:106) ==16693== by 0x663636B:
  QObjectPrivate::deleteChildren() (in /usr/lib/x86_64-linux-
  gnu/libQt5Core.so.5.3.0) ==16693== by 0x663F0EB: QObject::~QObject()
  (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.3.0) ==16693== by
  0x6BF64B5: QQuickItem::~QQuickItem() (qquickitem.cpp:2064) ==16693==
  by 0x6C0CAE5: QQmlPrivate::QQmlElement<QQuickItem>::~QQmlElement()
  (qqmlprivate.h:106) (LP: #1332598)
[ Michael Zanetti ]
* drop launcher item spacing (LP: #1332022)
* change wording in launcher quicklist (LP: #1332035)
[ Alejandro J. Cura ]
* Initial code for a payment button widget, to handle purchasing apps
  from the click scope.
[ Rodney Dawes ]
* Initial code for a payment button widget, to handle purchasing apps
  from the click scope.
[ Renato Araujo Oliveira Filho ]
* Create IndicatorsLight.qml component used to control indicator led.
  A blue led will pulse if the message indicator is blue and screen is
  off.

854. By Ying-Chun Liu on 2014-07-09

Fix FTBFS

Michael Zanetti (mzanetti) wrote :

I'm not sure if its a good idea to have the exact same interface exported into the shell and on D-Bus. Besides the fact that it looks quite chaotic, it also raises some security concerns here...

Michal, your opinion?

review: Needs Information
Michał Sawicz (saviq) wrote :

> I'm not sure if its a good idea to have the exact same interface exported into
> the shell and on D-Bus. Besides the fact that it looks quite chaotic, it also
> raises some security concerns here...

While I agree this is not ideal, the whole API here is rather temporary, until we spend the much needed time for analysis on session handling with accordance to fdo, systemd, logind etc. etc.

And applications can't call this API anyway, so it *should* be fine for now.

lp:~paulliu/unity8/reboot updated
855. By Ying-Chun Liu on 2014-07-10

Add fade-out effect.

856. By Ying-Chun Liu on 2014-07-10

Merge trunk

857. By Ying-Chun Liu on 2014-07-10

Fix bugs.

Ying-Chun Liu (paulliu) wrote :

The DBus is not used by the phone. It is for the desktop.
The indicators-session will use that DBus interface to ask the unity8 to shutdown.

lp:~paulliu/unity8/reboot updated
858. By Ying-Chun Liu on 2014-07-11

Merge trunk
[ Michal Hruby ]
* Fix FTBFS when using latest unity-api.
[ Michał Sawicz ]
* Refactor carousel item activation.
* Refactor ScopeItem into GenericScopeView.
* Add initial support for scope customizations.
* Make rating stars in PreviewReviewDisplay.qml non-interactive. (LP:
  #1337508)
[ Nick Dedekind ]
* Added active call hint A hint is displayed in the indicator panel
  when an call is active on the Telephony Serivce
[ Albert Astals ]
* We need to boostrap height also when we have 1 item ^_^ (LP:
  #1337408)
* Add initial support for scope customizations.
* CardCreator: Give a correct implicitHeight if we only have art The
  hasSubtitle change is really unrelated and not needed here, just
  sneaking it in to not create yet another review. (LP: #1330899)
* Fake Scopes Plugin: Register PreviewModelInterface
[ Michael Zanetti ]
* make the launcher's drag'n'drop indicator more prominent (LP:
  #1332042)
* make launcher items live having them non-live is not really required
  and reveals an issue in combination with UbuntuShape (LP: #1302761)
* Fade out launcher in place instead of moving it to the left on long
  left edge swipes. (LP: #1332096)
* update launcher icon glow as requested by design (LP: #1336725)
* update header in dash to use the new header from the SDK (LP:
  #1335491)
* fix testPreview with larger GRID_UNIT_PX values
* clip the corner of pinned icons in the launcher as per new design
* update launcher background according to latest design (LP: #1336314)
* Update Launcher's home button design according to new spec. (LP:
  #1329331)
[ CI bot ]
* make launcher items live having them non-live is not really required
  and reveals an issue in combination with UbuntuShape (LP: #1302761)

Michael Zanetti (mzanetti) wrote :

> The DBus is not used by the phone. It is for the desktop.
> The indicators-session will use that DBus interface to ask the unity8 to
> shutdown.

Not sure I understand what you're trying to say with this. But anyways, given its temporary I guess we can land as is... It worked fine in my tests...

 * Did you perform an exploratory manual test run of the code change and any related functionality?

ya

 * Did CI run pass? If not, please explain why.

no. flaky, unrelated tests

review: Approve
Michael Zanetti (mzanetti) wrote :

Oh... just saw the description says to NOT approve this branch yet... What's the status with that?

review: Needs Information
Ying-Chun Liu (paulliu) wrote :

> Oh... just saw the description says to NOT approve this branch yet... What's
> the status with that?

Sorry. I fix the description.

Thanks.

Michael Zanetti (mzanetti) wrote :

ack

review: Approve
lp:~paulliu/unity8/reboot updated
859. By Ying-Chun Liu on 2014-07-15

Merge trunk.
[ Michał Sawicz ]
* Activate all results in click scope by default. (LP: #1341262)
[ Mirco Müller ]
* Added support for utilization of the ComboButton SDK-element for
  snap-decision notifications with many actions.

860. By Ying-Chun Liu on 2014-07-16

Merge trunk.

Ying-Chun Liu (paulliu) wrote :

I just merge trunk and request a jenkins rebuild to see if it fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
2--- plugins/Unity/Session/dbusunitysessionservice.cpp 2014-05-27 11:44:25 +0000
3+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2014-07-16 14:44:35 +0000
4@@ -19,6 +19,7 @@
5
6 // Qt
7 #include <QDBusConnection>
8+#include <QDBusInterface>
9
10 DBusUnitySessionService::DBusUnitySessionService() : QObject()
11 {
12@@ -44,3 +45,35 @@
13 {
14 Q_EMIT logoutRequested(false);
15 }
16+
17+void DBusUnitySessionService::Reboot()
18+{
19+ QDBusConnection connection = QDBusConnection::systemBus();
20+ QDBusInterface iface1 ("org.freedesktop.login1",
21+ "/org/freedesktop/login1",
22+ "org.freedesktop.login1.Manager",
23+ connection);
24+
25+ iface1.call("Reboot", false);
26+}
27+
28+void DBusUnitySessionService::RequestReboot()
29+{
30+ Q_EMIT rebootRequested(false);
31+}
32+
33+void DBusUnitySessionService::Shutdown()
34+{
35+ QDBusConnection connection = QDBusConnection::systemBus();
36+ QDBusInterface iface1 ("org.freedesktop.login1",
37+ "/org/freedesktop/login1",
38+ "org.freedesktop.login1.Manager",
39+ connection);
40+
41+ iface1.call("PowerOff", false);
42+}
43+
44+void DBusUnitySessionService::RequestShutdown()
45+{
46+ Q_EMIT shutdownRequested(false);
47+}
48
49=== modified file 'plugins/Unity/Session/dbusunitysessionservice.h'
50--- plugins/Unity/Session/dbusunitysessionservice.h 2014-05-26 15:11:09 +0000
51+++ plugins/Unity/Session/dbusunitysessionservice.h 2014-07-16 14:44:35 +0000
52@@ -47,6 +47,27 @@
53 void logoutRequested(bool have_inhibitors);
54
55 /**
56+ * rebootRequested signal
57+ *
58+ * This signal is emitted when some applications request the system to
59+ * reboot.
60+ * @param have_inhibitors if there are any special running applications
61+ * which inhibit the reboot.
62+ */
63+ void rebootRequested(bool have_inhibitors);
64+
65+ /**
66+ * shutdownRequested signal
67+ *
68+ * This signal is emitted when some applications request the system to
69+ * shutdown.
70+ * @param have_inhibitors if there are any special running applications
71+ * which inhibit the shutdown.
72+ */
73+ void shutdownRequested(bool have_inhibitors);
74+
75+
76+ /**
77 * logoutReady signal
78 *
79 * This signal is emitted when all the apps are closed. And the system
80@@ -61,22 +82,58 @@
81 * This method directly logout the system without user's confirmation.
82 * Ordinary applications should avoid calling this method. Please call
83 * RequestLogout() to ask the user to decide logout or not.
84- * This method will stop all the running applications and then signal
85- * logoutReady when all the apps stopped.
86 */
87 Q_SCRIPTABLE void Logout();
88
89 /**
90+ * Reboot the system.
91+ *
92+ * This method directly reboot the system without user's confirmation.
93+ * Ordinary applications should avoid calling this method. Please call
94+ * RequestReboot() to ask the user to decide reboot or not.
95+ */
96+ Q_SCRIPTABLE void Reboot();
97+
98+ /**
99+ * Shutdown the system.
100+ *
101+ * This method directly shutdown the system without user's confirmation.
102+ * Ordinary applications should avoid calling this method. Please call
103+ * RequestShutdown() to ask the user to decide shutdown or not.
104+ */
105+ Q_SCRIPTABLE void Shutdown();
106+
107+ /**
108 * Issue a logout request.
109 *
110 * This method emit the logoutRequested signal to the shell with a boolean
111 * which indicates if there's any inhibitors. The shell should receive
112 * this signal and display a dialog to ask the user to confirm the logout
113- * action. If confirmed, shell can call Logout() method to kill the apps
114- * and then logout
115+ * action. If confirmed, shell can call Logout() method to logout.
116 */
117 Q_SCRIPTABLE void RequestLogout();
118
119+ /**
120+ * Issue a reboot request.
121+ *
122+ * This method emit the rebootRequested signal to the shell with a boolean
123+ * which indicates if there's any inhibitors. The shell should receive
124+ * this signal and display a dialog to ask the user to confirm the reboot
125+ * action. If confirmed, shell can call Reboot() method to reboot
126+ */
127+ Q_SCRIPTABLE void RequestReboot();
128+
129+ /**
130+ * Issue a shutdown request.
131+ *
132+ * This method emit the shutdownRequested signal to the shell with a
133+ * boolean which indicates if there's any inhibitors.
134+ * The shell should receive
135+ * this signal and display a dialog to ask the user to confirm the reboot
136+ * action. If confirmed, shell can call Shutdown() method to reboot
137+ */
138+ Q_SCRIPTABLE void RequestShutdown();
139+
140 };
141
142 #endif // DBUSUNITYSESSIONSERVICE_H
143
144=== modified file 'qml/Shell.qml'
145--- qml/Shell.qml 2014-07-09 19:44:14 +0000
146+++ qml/Shell.qml 2014-07-16 14:44:35 +0000
147@@ -19,6 +19,7 @@
148 import GSettings 1.0
149 import Unity.Application 0.1
150 import Ubuntu.Components 0.1
151+import Ubuntu.Components.Popups 0.1
152 import Ubuntu.Gestures 0.1
153 import Unity.Launcher 0.1
154 import LightDM 0.1 as LightDM
155@@ -268,7 +269,128 @@
156 }
157 }
158
159+ property bool dialogShown: false
160+
161+ Component {
162+ id: logoutDialog
163+ Dialog {
164+ id: dialogueLogout
165+ title: "Logout"
166+ text: "Are you sure that you want to logout?"
167+ Button {
168+ text: "Cancel"
169+ onClicked: {
170+ PopupUtils.close(dialogueLogout);
171+ stages.dialogShown = false;
172+ }
173+ }
174+ Button {
175+ text: "Yes"
176+ onClicked: {
177+ DBusUnitySessionService.Logout();
178+ PopupUtils.close(dialogueLogout);
179+ stages.dialogShown = false;
180+ }
181+ }
182+ }
183+ }
184+
185+ Component {
186+ id: shutdownDialog
187+ Dialog {
188+ id: dialogueShutdown
189+ title: "Shutdown"
190+ text: "Are you sure that you want to shutdown?"
191+ Button {
192+ text: "Cancel"
193+ onClicked: {
194+ PopupUtils.close(dialogueShutdown);
195+ stages.dialogShown = false;
196+ }
197+ }
198+ Button {
199+ text: "Yes"
200+ onClicked: {
201+ dBusUnitySessionServiceConnection.closeAllApps();
202+ DBusUnitySessionService.Shutdown();
203+ PopupUtils.close(dialogueShutdown);
204+ stages.dialogShown = false;
205+ }
206+ }
207+ }
208+ }
209+
210+ Component {
211+ id: rebootDialog
212+ Dialog {
213+ id: dialogueReboot
214+ title: "Reboot"
215+ text: "Are you sure that you want to reboot?"
216+ Button {
217+ text: "Cancel"
218+ onClicked: {
219+ PopupUtils.close(dialogueReboot)
220+ stages.dialogShown = false;
221+ }
222+ }
223+ Button {
224+ text: "Yes"
225+ onClicked: {
226+ dBusUnitySessionServiceConnection.closeAllApps();
227+ DBusUnitySessionService.Reboot();
228+ PopupUtils.close(dialogueReboot);
229+ stages.dialogShown = false;
230+ }
231+ }
232+ }
233+ }
234+
235+ Component {
236+ id: powerDialog
237+ Dialog {
238+ id: dialoguePower
239+ title: "Power"
240+ text: i18n.tr("Are you sure you would like to turn power off?")
241+ Button {
242+ text: i18n.tr("Power off")
243+ onClicked: {
244+ dBusUnitySessionServiceConnection.closeAllApps();
245+ PopupUtils.close(dialoguePower);
246+ stages.dialogShown = false;
247+ shutdownFadeOutRectangle.enabled = true;
248+ shutdownFadeOutRectangle.visible = true;
249+ shutdownFadeOut.start();
250+ }
251+ }
252+ Button {
253+ text: i18n.tr("Restart")
254+ onClicked: {
255+ dBusUnitySessionServiceConnection.closeAllApps();
256+ DBusUnitySessionService.Reboot();
257+ PopupUtils.close(dialoguePower);
258+ stages.dialogShown = false;
259+ }
260+ }
261+ Button {
262+ text: i18n.tr("Cancel")
263+ onClicked: {
264+ PopupUtils.close(dialoguePower);
265+ stages.dialogShown = false;
266+ }
267+ }
268+ }
269+ }
270+
271+ function showPowerDialog() {
272+ if (!stages.dialogShown) {
273+ stages.dialogShown = true;
274+ PopupUtils.open(powerDialog);
275+ }
276+ }
277+
278 Connections {
279+ id: dBusUnitySessionServiceConnection
280+ objectName: "dBusUnitySessionServiceConnection"
281 target: DBusUnitySessionService
282
283 function closeAllApps() {
284@@ -282,8 +404,27 @@
285 }
286
287 onLogoutRequested: {
288- // TODO: Display a dialog to ask the user to confirm.
289- DBusUnitySessionService.Logout();
290+ // Display a dialog to ask the user to confirm.
291+ if (!stages.dialogShown) {
292+ stages.dialogShown = true;
293+ PopupUtils.open(logoutDialog);
294+ }
295+ }
296+
297+ onShutdownRequested: {
298+ // Display a dialog to ask the user to confirm.
299+ if (!stages.dialogShown) {
300+ stages.dialogShown = true;
301+ PopupUtils.open(shutdownDialog);
302+ }
303+ }
304+
305+ onRebootRequested: {
306+ // Display a dialog to ask the user to confirm.
307+ if (!stages.dialogShown) {
308+ stages.dialogShown = true;
309+ PopupUtils.open(rebootDialog);
310+ }
311 }
312
313 onLogoutReady: {
314@@ -679,4 +820,50 @@
315 target: SessionBroadcast
316 onShowHome: showHome()
317 }
318+
319+ Keys.onPressed: {
320+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
321+ if (!powerKeyTimer.running) {
322+ powerKeyTimer.start();
323+ }
324+ event.accepted = true;
325+ }
326+ }
327+
328+ Keys.onReleased: {
329+ if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
330+ powerKeyTimer.stop();
331+ event.accepted = true;
332+ }
333+ }
334+
335+ Timer {
336+ id: powerKeyTimer
337+ interval: 2000
338+ repeat: false
339+ triggeredOnStart: false
340+
341+ onTriggered: {
342+ stages.showPowerDialog();
343+ }
344+ }
345+
346+ Rectangle {
347+ id: shutdownFadeOutRectangle
348+ enabled: false
349+ visible: false
350+ color: "black"
351+ anchors.fill: parent
352+ opacity: 0.0
353+ NumberAnimation on opacity {
354+ id: shutdownFadeOut
355+ from: 0.0
356+ to: 1.0
357+ onStopped: {
358+ if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
359+ DBusUnitySessionService.Shutdown();
360+ }
361+ }
362+ }
363+ }
364 }

Subscribers

People subscribed via source and target branches