Merge lp:~lukas-kde/unity8/platformPlugin into lp:unity8

Proposed by Lukáš Tinkl on 2015-10-09
Status: Merged
Approved by: Michael Zanetti on 2015-10-09
Approved revision: 2002
Merged at revision: 2013
Proposed branch: lp:~lukas-kde/unity8/platformPlugin
Merge into: lp:unity8
Diff against target: 237 lines (+175/-2)
8 files modified
plugins/Unity/CMakeLists.txt (+1/-0)
plugins/Unity/Platform/CMakeLists.txt (+9/-0)
plugins/Unity/Platform/platform.cpp (+43/-0)
plugins/Unity/Platform/platform.h (+58/-0)
plugins/Unity/Platform/plugin.cpp (+27/-0)
plugins/Unity/Platform/plugin.h (+32/-0)
plugins/Unity/Platform/qmldir (+2/-0)
qml/Components/Dialogs.qml (+3/-2)
To merge this branch: bzr merge lp:~lukas-kde/unity8/platformPlugin
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-10-09
Michał Sawicz conceptual Approve on 2015-10-09
Michael Zanetti (community) 2015-10-09 Approve on 2015-10-09
Review via email: mp+273974@code.launchpad.net

Commit Message

Implement Unity.Platform plugin wrapping org.freedesktop.hostname1

Description of the Change

Implement Unity.Platform plugin wrapping org.freedesktop.hostname1

To get access to platform properties like form factor to be able to distinguish whether we run on a PC or on a phone/tablet. See http://www.freedesktop.org/wiki/Software/systemd/hostnamed/ for more details.

Allows fixing lpbug#1504318: power off dialog pops up instantly in window mode (https://bugs.launchpad.net/bugs/1504318)

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

No

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

Yes

* Did you make sure that your branch does not contain spurious tags?

Yes

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

Yes

* If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Michael Zanetti (mzanetti) wrote :

Tested, works fine. Code looks good

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

yes

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

waiting

 * Did you make sure that the branch does not contain spurious tags?

yes

review: Approve
Michał Sawicz (saviq) wrote :

Is this really the distinction we want to make? Shouldn't the phone, when connected to a kbd and mouse, behave like a desktop (so pressing the power button should not blank the screen but display the dialog)? Should not mouse and touch input wake the screen then?

review: Needs Information
Michael Zanetti (mzanetti) wrote :

> Is this really the distinction we want to make? Shouldn't the phone, when
> connected to a kbd and mouse, behave like a desktop (so pressing the power
> button should not blank the screen but display the dialog)? Should not mouse
> and touch input wake the screen then?

I think would allow being convinced otherwise but right now I would say, if I dock my phone to an external monitor and use it as a pocket PC, that still doesn't mean I want to shut the phone down with the power button. The device itself is still a "phone" and meant to be always on, keeping me reachable for phone calls etc. So I suggest to continue to walk the path in this MP, keeping phone-ish behavior for the power button even in pocket-desktop mode.

As for waking the screen up with mouse/keyboard, yes I would agree we want that. It's kinda unrelated to the power button situation though.

Michał Sawicz (saviq) wrote :

OK I can be forced to think that ;)

review: Approve (conceptual)
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2002
http://jenkins.qa.ubuntu.com/job/unity8-ci/6445/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4582
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/827
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1157
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/476
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1052
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1053
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/684
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/685
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3714
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4579
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4579/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24115
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/493
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/827
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/827/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24109

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6445/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/CMakeLists.txt'
2--- plugins/Unity/CMakeLists.txt 2015-05-05 11:19:15 +0000
3+++ plugins/Unity/CMakeLists.txt 2015-10-09 12:43:13 +0000
4@@ -4,3 +4,4 @@
5 add_subdirectory(Session)
6 add_subdirectory(DashCommunicator)
7 add_subdirectory(InputInfo)
8+add_subdirectory(Platform)
9
10=== added directory 'plugins/Unity/Platform'
11=== added file 'plugins/Unity/Platform/CMakeLists.txt'
12--- plugins/Unity/Platform/CMakeLists.txt 1970-01-01 00:00:00 +0000
13+++ plugins/Unity/Platform/CMakeLists.txt 2015-10-09 12:43:13 +0000
14@@ -0,0 +1,9 @@
15+set(platformplugin_SRCS
16+ platform.cpp
17+ plugin.cpp)
18+
19+add_library(Platform-qml SHARED ${platformplugin_SRCS})
20+
21+qt5_use_modules(Platform-qml DBus Qml)
22+
23+add_unity8_plugin(Unity.Platform 1.0 Unity/Platform TARGETS Platform-qml)
24
25=== added file 'plugins/Unity/Platform/platform.cpp'
26--- plugins/Unity/Platform/platform.cpp 1970-01-01 00:00:00 +0000
27+++ plugins/Unity/Platform/platform.cpp 2015-10-09 12:43:13 +0000
28@@ -0,0 +1,43 @@
29+/*
30+ * Copyright (C) 2015 Canonical, Ltd.
31+ *
32+ * This program is free software; you can redistribute it and/or modify
33+ * it under the terms of the GNU General Public License as published by
34+ * the Free Software Foundation; version 3.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details.
40+ *
41+ * You should have received a copy of the GNU General Public License
42+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
43+ */
44+
45+#include "platform.h"
46+
47+#include <QDBusConnection>
48+
49+Platform::Platform(QObject *parent)
50+ : QObject(parent)
51+ , m_iface("org.freedesktop.hostname1", "/org/freedesktop/hostname1", "org.freedesktop.hostname1",
52+ QDBusConnection::systemBus(), this)
53+{
54+ QMetaObject::invokeMethod(this, "init");
55+}
56+
57+void Platform::init()
58+{
59+ m_chassis = m_iface.property("Chassis").toString();
60+ m_isPC = (m_chassis == "desktop" || m_chassis == "laptop" || m_chassis == "server");
61+}
62+
63+QString Platform::chassis() const
64+{
65+ return m_chassis;
66+}
67+
68+bool Platform::isPC() const
69+{
70+ return m_isPC;
71+}
72
73=== added file 'plugins/Unity/Platform/platform.h'
74--- plugins/Unity/Platform/platform.h 1970-01-01 00:00:00 +0000
75+++ plugins/Unity/Platform/platform.h 2015-10-09 12:43:13 +0000
76@@ -0,0 +1,58 @@
77+/*
78+ * Copyright (C) 2015 Canonical, Ltd.
79+ *
80+ * This program is free software; you can redistribute it and/or modify
81+ * it under the terms of the GNU General Public License as published by
82+ * the Free Software Foundation; version 3.
83+ *
84+ * This program is distributed in the hope that it will be useful,
85+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
86+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87+ * GNU General Public License for more details.
88+ *
89+ * You should have received a copy of the GNU General Public License
90+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
91+ */
92+
93+#ifndef PLATFORM_H
94+#define PLATFORM_H
95+
96+#include <QDBusInterface>
97+
98+/**
99+ * @brief The Platform class
100+ *
101+ * Wrapper around platform detection support (org.freedesktop.hostname1)
102+ */
103+class Platform: public QObject
104+{
105+ Q_OBJECT
106+ /**
107+ * The chassis property
108+ *
109+ * Supported values include: "laptop", "computer", "handset" or "tablet"
110+ * For full list see: http://www.freedesktop.org/wiki/Software/systemd/hostnamed/
111+ */
112+ Q_PROPERTY(QString chassis READ chassis CONSTANT)
113+ /**
114+ * Whether the machine is an ordinary PC (desktop, laptop or server)
115+ */
116+ Q_PROPERTY(bool isPC READ isPC CONSTANT)
117+
118+public:
119+ Platform(QObject *parent = nullptr);
120+ ~Platform() = default;
121+
122+ QString chassis() const;
123+ bool isPC() const;
124+
125+private Q_SLOTS:
126+ void init();
127+
128+private:
129+ QDBusInterface m_iface;
130+ QString m_chassis;
131+ bool m_isPC;
132+};
133+
134+#endif // PLATFORM_H
135
136=== added file 'plugins/Unity/Platform/plugin.cpp'
137--- plugins/Unity/Platform/plugin.cpp 1970-01-01 00:00:00 +0000
138+++ plugins/Unity/Platform/plugin.cpp 2015-10-09 12:43:13 +0000
139@@ -0,0 +1,27 @@
140+/*
141+ * Copyright (C) 2015 Canonical, Ltd.
142+ *
143+ * This program is free software; you can redistribute it and/or modify
144+ * it under the terms of the GNU General Public License as published by
145+ * the Free Software Foundation; version 3.
146+ *
147+ * This program is distributed in the hope that it will be useful,
148+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
149+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
150+ * GNU General Public License for more details.
151+ *
152+ * You should have received a copy of the GNU General Public License
153+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
154+ */
155+
156+#include "plugin.h"
157+#include "platform.h"
158+
159+#include <QtQml>
160+
161+void GlobalShortcutPlugin::registerTypes(const char *uri)
162+{
163+ Q_ASSERT(uri == QLatin1String("Unity.Platform"));
164+
165+ qmlRegisterSingletonType<Platform>(uri, 1, 0, "Platform", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Platform; });
166+}
167
168=== added file 'plugins/Unity/Platform/plugin.h'
169--- plugins/Unity/Platform/plugin.h 1970-01-01 00:00:00 +0000
170+++ plugins/Unity/Platform/plugin.h 2015-10-09 12:43:13 +0000
171@@ -0,0 +1,32 @@
172+/*
173+ * Copyright (C) 2015 Canonical, Ltd.
174+ *
175+ * This program is free software; you can redistribute it and/or modify
176+ * it under the terms of the GNU General Public License as published by
177+ * the Free Software Foundation; version 3.
178+ *
179+ * This program is distributed in the hope that it will be useful,
180+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
181+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
182+ * GNU General Public License for more details.
183+ *
184+ * You should have received a copy of the GNU General Public License
185+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
186+ */
187+
188+#ifndef PLATFORMPLUGIN_H
189+#define PLATFORMPLUGIN_H
190+
191+#include <QQmlExtensionPlugin>
192+
193+class GlobalShortcutPlugin: public QQmlExtensionPlugin
194+{
195+ Q_OBJECT
196+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
197+
198+public:
199+ void registerTypes(const char *uri) override;
200+};
201+
202+
203+#endif // PLATFORMPLUGIN_H
204
205=== added file 'plugins/Unity/Platform/qmldir'
206--- plugins/Unity/Platform/qmldir 1970-01-01 00:00:00 +0000
207+++ plugins/Unity/Platform/qmldir 2015-10-09 12:43:13 +0000
208@@ -0,0 +1,2 @@
209+module Unity.Platform
210+plugin Platform-qml
211
212=== modified file 'qml/Components/Dialogs.qml'
213--- qml/Components/Dialogs.qml 2015-09-02 09:30:32 +0000
214+++ qml/Components/Dialogs.qml 2015-10-09 12:43:13 +0000
215@@ -20,6 +20,7 @@
216 import Unity.Session 0.1
217 import Ubuntu.Components 1.1
218 import GlobalShortcut 1.0
219+import Unity.Platform 1.0
220 import "../Greeter"
221
222 Item {
223@@ -46,13 +47,13 @@
224
225 GlobalShortcut { // reboot/shutdown dialog
226 shortcut: Qt.Key_PowerDown
227- active: root.usageScenario === "desktop"
228+ active: Platform.isPC
229 onTriggered: root.unitySessionService.RequestShutdown()
230 }
231
232 GlobalShortcut { // reboot/shutdown dialog
233 shortcut: Qt.Key_PowerOff
234- active: root.usageScenario === "desktop"
235+ active: Platform.isPC
236 onTriggered: root.unitySessionService.RequestShutdown()
237 }
238

Subscribers

People subscribed via source and target branches