Merge lp:~osomon/webbrowser-app/bottom-edge-mouse into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1340
Merged at revision: 1339
Proposed branch: lp:~osomon/webbrowser-app/bottom-edge-mouse
Merge into: lp:webbrowser-app
Diff against target: 1518 lines (+1284/-27)
19 files modified
debian/control (+3/-0)
debian/rules (+3/-1)
debian/webbrowser-app-apparmor.manifest (+2/-1)
src/app/CMakeLists.txt (+1/-0)
src/app/browserapplication.cpp (+5/-0)
src/app/unity8/README (+11/-3)
src/app/unity8/plugins/CMakeLists.txt (+1/-0)
src/app/unity8/plugins/Unity/CMakeLists.txt (+1/-0)
src/app/unity8/plugins/Unity/InputInfo/CMakeLists.txt (+40/-0)
src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp (+291/-0)
src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h (+98/-0)
src/app/unity8/plugins/Unity/InputInfo/plugin.cpp (+32/-0)
src/app/unity8/plugins/Unity/InputInfo/plugin.h (+30/-0)
src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp (+196/-0)
src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h (+102/-0)
src/app/unity8/plugins/Unity/InputInfo/qinputinfo.cpp (+270/-0)
src/app/unity8/plugins/Unity/InputInfo/qinputinfo.h (+143/-0)
src/app/unity8/plugins/Unity/InputInfo/qmldir (+3/-0)
src/app/webbrowser/Browser.qml (+52/-22)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/bottom-edge-mouse
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Jamie Strandboge Approve
Review via email: mp+284283@code.launchpad.net

Commit message

In narrow mode, when a mouse is connected, turn the bottom edge hint into a clickable bottom edge bar.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1332. By Olivier Tilloy

Add missing build dependency.

1333. By Olivier Tilloy

In narrow mode, when a mouse is connected, turn the bottom edge hint into a clickable bottom edge bar.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1334. By Olivier Tilloy

Merge the latest changes from trunk, and resolve a minor conflict.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Testing on device, I’m getting apparmor denials which prevent the Unity.InputInfo plugin from working. Disabling the apparmor profile makes it work.
The following additional rules appear to be needed:

  /sys/class/ r,
  /sys/class/input/ r,
  /sys/devices/**/input*/ r,
  /sys/devices/**/input*/** r,

1335. By Olivier Tilloy

Remove the "Open tabs" and "New tab" actions from the drawer menu.
 - In wide mode, they are useless because there is a visible tab bar.
 - In narrow mode, if there is a mouse connected the bottom edge bar opens the tabs view, and if there is no mouse the bottom edge hint opens it.

1336. By Olivier Tilloy

Also detect touchpads.

1337. By Olivier Tilloy

Add apparmor rules to allow InputInfo to work.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

With the "/sys/devices/**/input*/" change to read_path, you don't need /sys/devices/**/input*/** in your sed. '/sys/class/ r,' and '/sys/bus/ r,' in the sed are good though.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1338. By Olivier Tilloy

Simpler sed rule.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

The apparmor changes look fine. Thanks!

review: Approve
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

FYI, the other changes to debian/ look good too.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1339. By Olivier Tilloy

Escape $ in debian/rules.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1340. By Olivier Tilloy

Also allow read access to /run/udev/data/**, so that input device capabilities can be discovered.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2015-12-15 15:38:35 +0000
+++ debian/control 2016-01-29 09:32:29 +0000
@@ -10,8 +10,11 @@
10 dh-apparmor,10 dh-apparmor,
11 dh-translations,11 dh-translations,
12 hardening-wrapper,12 hardening-wrapper,
13 libevdev-dev,
13 liboxideqt-qmlplugin (>= 1.9),14 liboxideqt-qmlplugin (>= 1.9),
14 libqt5sql5-sqlite,15 libqt5sql5-sqlite,
16 libudev-dev,
17 pkg-config,
15 python3-all,18 python3-all,
16 python3-flake8,19 python3-flake8,
17 qml-module-qt-labs-folderlistmodel,20 qml-module-qt-labs-folderlistmodel,
1821
=== modified file 'debian/rules'
--- debian/rules 2015-10-22 15:07:44 +0000
+++ debian/rules 2016-01-29 09:32:29 +0000
@@ -14,7 +14,9 @@
14 aa-easyprof -m ./debian/webbrowser-app-apparmor.manifest --no-verify | \14 aa-easyprof -m ./debian/webbrowser-app-apparmor.manifest --no-verify | \
15 egrep -v '(# Click packages|CLICK_DIR)' | \15 egrep -v '(# Click packages|CLICK_DIR)' | \
16 sed 's/@{APP_PKGNAME}_@{APP_APPNAME}_@{APP_VERSION}/@{APP_PKGNAME}/g' | \16 sed 's/@{APP_PKGNAME}_@{APP_APPNAME}_@{APP_VERSION}/@{APP_PKGNAME}/g' | \
17 sed 's#/run/shm/\.org\.chromium\.Chromium\.\*#/{dev,run}/shm/.org.chromium.Chromium.*#g' \17 sed 's#/run/shm/\.org\.chromium\.Chromium\.\*#/{dev,run}/shm/.org.chromium.Chromium.*#g' | \
18 egrep -v 'deny /run/udev/data/\*\* r,' | \
19 sed 's#^}$$#\n /sys/class/ r,\n /sys/class/input/ r,\n /run/udev/data/** r,\n}#g' \
18 > ./debian/usr.bin.webbrowser-app20 > ./debian/usr.bin.webbrowser-app
19 apparmor_parser -QTK ./debian/usr.bin.webbrowser-app21 apparmor_parser -QTK ./debian/usr.bin.webbrowser-app
2022
2123
=== modified file 'debian/webbrowser-app-apparmor.manifest'
--- debian/webbrowser-app-apparmor.manifest 2015-10-26 11:28:31 +0000
+++ debian/webbrowser-app-apparmor.manifest 2016-01-29 09:32:29 +0000
@@ -32,7 +32,8 @@
32 "/usr/share/applications/",32 "/usr/share/applications/",
33 "/custom/vendor/here/location-provider/consent/*.html",33 "/custom/vendor/here/location-provider/consent/*.html",
34 "@{HOME}/.local/share/applications/",34 "@{HOME}/.local/share/applications/",
35 "@{HOME}/Downloads/"35 "@{HOME}/Downloads/",
36 "/sys/devices/**/input*/"
36 ],37 ],
37 "write_path": [38 "write_path": [
38 "@{HOME}/Downloads/"39 "@{HOME}/Downloads/"
3940
=== modified file 'src/app/CMakeLists.txt'
--- src/app/CMakeLists.txt 2016-01-13 16:23:16 +0000
+++ src/app/CMakeLists.txt 2016-01-29 09:32:29 +0000
@@ -37,6 +37,7 @@
37 Qt5::Quick37 Qt5::Quick
38 Qt5::Widgets38 Qt5::Widgets
39 UbuntuGesturesQml39 UbuntuGesturesQml
40 InputInfo
40)41)
4142
42file(GLOB QML_FILES *.qml)43file(GLOB QML_FILES *.qml)
4344
=== modified file 'src/app/browserapplication.cpp'
--- src/app/browserapplication.cpp 2016-01-15 10:06:31 +0000
+++ src/app/browserapplication.cpp 2016-01-29 09:32:29 +0000
@@ -37,6 +37,7 @@
37#include "TouchRegistry.h"37#include "TouchRegistry.h"
38#include "Ubuntu/Gestures/Direction.h"38#include "Ubuntu/Gestures/Direction.h"
39#include "Ubuntu/Gestures/DirectionalDragArea.h"39#include "Ubuntu/Gestures/DirectionalDragArea.h"
40#include "Unity/InputInfo/qdeclarativeinputdevicemodel_p.h"
4041
41BrowserApplication::BrowserApplication(int& argc, char** argv)42BrowserApplication::BrowserApplication(int& argc, char** argv)
42 : QApplication(argc, argv)43 : QApplication(argc, argv)
@@ -165,6 +166,10 @@
165 qmlRegisterSingletonType<Direction>(gesturesUri, 0, 1, "Direction", Direction_singleton_factory);166 qmlRegisterSingletonType<Direction>(gesturesUri, 0, 1, "Direction", Direction_singleton_factory);
166 qmlRegisterType<DirectionalDragArea>(gesturesUri, 0, 1, "DirectionalDragArea");167 qmlRegisterType<DirectionalDragArea>(gesturesUri, 0, 1, "DirectionalDragArea");
167168
169 const char* inputInfoUri = "Unity.InputInfo";
170 qmlRegisterType<QDeclarativeInputDeviceModel>(inputInfoUri, 0, 1, "InputDeviceModel");
171 qmlRegisterType<QInputDevice>(inputInfoUri, 0, 1, "InputInfo");
172
168 m_engine = new QQmlEngine;173 m_engine = new QQmlEngine;
169 connect(m_engine, SIGNAL(quit()), SLOT(quit()));174 connect(m_engine, SIGNAL(quit()), SLOT(quit()));
170 if (!isRunningInstalled()) {175 if (!isRunningInstalled()) {
171176
=== modified file 'src/app/unity8/README'
--- src/app/unity8/README 2015-03-17 15:14:11 +0000
+++ src/app/unity8/README 2016-01-29 09:32:29 +0000
@@ -1,11 +1,19 @@
1Code in this directory was copied over from unity8.1Code in this directory was copied over from unity8.
2
3Ubuntu.Gestures:
2 - first import: 2015-02-04, at revision 1583 of lp:unity84 - first import: 2015-02-04, at revision 1583 of lp:unity8
3 - last sync: 2015-03-17, at revision 1663 of lp:unity85 - last sync: 2015-03-17, at revision 1663 of lp:unity8
46
7Unity.InputInfo:
8 - first import: 2016-01-28, at revision 2143 of lp:unity8
9
5The structure of the directories has been kept identical, to ease syncing the10The structure of the directories has been kept identical, to ease syncing the
6code in the future. Minor changes were made to the build system to integrate it11code in the future. Minor changes were made to the build system to integrate it
7with the existing webbrowser-app code base.12with the existing webbrowser-app code base.
813
9The goal is to eventually have those components moved over to the UITK, thus14As of 2015-12-09, the SwipeArea component is available in the UITK, so we should
10removing the need for a copy here. See15start using it instead of building a local copy of Ubuntu.Gestures. This is
11https://docs.google.com/a/canonical.com/document/d/1_ljZunMXWqJfrBGEkCp0peVD8gq6-E4ZMFpuH0PVKRc.16currently blocked on https://launchpad.net/bugs/1459362.
17
18The Unity.InputInfo plugin should be replaced by an upstream Qt API in the near
19future.
1220
=== modified file 'src/app/unity8/plugins/CMakeLists.txt'
--- src/app/unity8/plugins/CMakeLists.txt 2015-02-04 10:56:38 +0000
+++ src/app/unity8/plugins/CMakeLists.txt 2016-01-29 09:32:29 +0000
@@ -1,1 +1,2 @@
1add_subdirectory(Ubuntu)1add_subdirectory(Ubuntu)
2add_subdirectory(Unity)
23
=== added directory 'src/app/unity8/plugins/Unity'
=== added file 'src/app/unity8/plugins/Unity/CMakeLists.txt'
--- src/app/unity8/plugins/Unity/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/CMakeLists.txt 2016-01-29 09:32:29 +0000
@@ -0,0 +1,1 @@
1add_subdirectory(InputInfo)
02
=== added directory 'src/app/unity8/plugins/Unity/InputInfo'
=== added file 'src/app/unity8/plugins/Unity/InputInfo/CMakeLists.txt'
--- src/app/unity8/plugins/Unity/InputInfo/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/CMakeLists.txt 2016-01-29 09:32:29 +0000
@@ -0,0 +1,40 @@
1# This is a temporary snapshot of the WIP QInputInfo API as we
2# require this in unity now but upstream isn't finished yet.
3# Eventually this should be dropped in favor of the upstream
4# QInputInfo API.
5
6project(InputInfo)
7
8find_package(Qt5Core REQUIRED)
9find_package(Qt5Quick REQUIRED)
10
11include(FindPkgConfig)
12pkg_check_modules(LIBUDEV REQUIRED libudev)
13pkg_check_modules(LIBEVDEV REQUIRED libevdev)
14
15include_directories(
16 ${CMAKE_CURRENT_SOURCE_DIR}
17 ${CMAKE_CURRENT_BINARY_DIR}
18 ${LIBUDEV_INCLUDE_DIRS}
19 ${LIBEVDEV_INCLUDE_DIRS}
20)
21
22set(InputInfo_SOURCES
23 plugin.cpp
24 qinputinfo.cpp
25 qdeclarativeinputdevicemodel.cpp
26 linux/qinputdeviceinfo_linux.cpp
27)
28
29add_library(InputInfo STATIC
30 ${InputInfo_SOURCES}
31)
32
33target_link_libraries(InputInfo
34 ${LIBUDEV_LDFLAGS}
35 ${LIBEVDEV_LDFLAGS}
36)
37
38qt5_use_modules(InputInfo Core Qml Quick)
39
40#add_unity8_plugin(Unity.InputInfo 0.1 Unity/InputInfo TARGETS InputInfo)
041
=== added directory 'src/app/unity8/plugins/Unity/InputInfo/linux'
=== added file 'src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp'
--- src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 2016-01-29 09:32:29 +0000
@@ -0,0 +1,291 @@
1/****************************************************************************
2**
3** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qinputdeviceinfo_linux_p.h"
43
44#include <libudev.h>
45#include <libevdev/libevdev.h>
46#include <fcntl.h>
47#include <QDebug>
48#include <QSocketNotifier>
49#include <QTimer>
50#include <QDir>
51
52QInputDeviceManagerPrivate::QInputDeviceManagerPrivate(QObject *parent) :
53 QObject(parent),
54 currentFilter(QInputDevice::Unknown),
55 udevice(0)
56{
57 QTimer::singleShot(250,this,SLOT(init()));
58}
59
60QInputDeviceManagerPrivate::~QInputDeviceManagerPrivate()
61{
62 udev_unref(udevice);
63 udev_monitor_unref(udevMonitor);
64}
65
66void QInputDeviceManagerPrivate::init()
67{
68 if (!udevice)
69 udevice = udev_new();
70
71 udev_list_entry *devices;
72 udev_list_entry *dev_list_entry;
73 udev_device *dev;
74
75 QString subsystem = QStringLiteral("input");
76 struct udev_enumerate *enumerate = 0;
77
78 if (udevice) {
79
80 udevMonitor = udev_monitor_new_from_netlink(udevice, "udev");
81 udev_monitor_filter_add_match_subsystem_devtype(udevMonitor, subsystem.toLatin1(), NULL);
82 enumerate = udev_enumerate_new(udevice);
83 udev_enumerate_add_match_subsystem(enumerate, subsystem.toLatin1());
84
85 udev_monitor_enable_receiving(udevMonitor);
86 notifierFd = udev_monitor_get_fd(udevMonitor);
87
88 notifier = new QSocketNotifier(notifierFd, QSocketNotifier::Read, this);
89 connect(notifier, SIGNAL(activated(int)), this, SLOT(onUDevChanges()));
90
91 udev_enumerate_scan_devices(enumerate);
92 devices = udev_enumerate_get_list_entry(enumerate);
93
94 udev_list_entry_foreach(dev_list_entry, devices) {
95 const char *path;
96 path = udev_list_entry_get_name(dev_list_entry);
97
98 dev = udev_device_new_from_syspath(udevice, path);
99 if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) {
100 QInputDevice *iDevice = addDevice(dev);
101 if (iDevice && !iDevice->devicePath().isEmpty()) {
102 deviceMap.insert(iDevice->devicePath(),iDevice);
103 }
104 }
105 udev_device_unref(dev);
106 }
107 udev_enumerate_unref(enumerate);
108 }
109 // udev_unref(udevice);
110 Q_FOREACH (const QString &devicePath, deviceMap.keys()) {
111 Q_EMIT deviceAdded(devicePath);
112 }
113 Q_EMIT ready();
114}
115
116QInputDevice::InputTypeFlags QInputDeviceManagerPrivate::getInputTypeFlags(struct udev_device *dev)
117{
118 QInputDevice::InputTypeFlags flags = QInputDevice::Unknown;
119 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEY"), "1") == 0 ) {
120 flags |= QInputDevice::Button;
121 }
122 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0) {
123 flags |= QInputDevice::Mouse;
124 }
125 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0) {
126 flags |= QInputDevice::TouchPad;
127 }
128 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0
129 || qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TABLET"), "1") == 0) {
130 flags |= QInputDevice::TouchScreen;
131 }
132 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 ) {
133 flags |= QInputDevice::Keyboard;
134 }
135 if (!QString::fromLatin1(udev_device_get_property_value(dev, "SW")).isEmpty()) {
136 flags |= QInputDevice::Switch;
137 }
138
139 return flags;
140}
141
142QInputDevice *QInputDeviceManagerPrivate::addDevice(struct udev_device *udev)
143{
144 QString eventPath = QString::fromLatin1(udev_device_get_sysname(udev));
145
146 if (eventPath.contains(QStringLiteral("event")))
147 eventPath.prepend(QStringLiteral("/dev/input/"));
148
149 if (deviceMap.contains(eventPath)) {
150 return Q_NULLPTR;
151 }
152 struct libevdev *dev = NULL;
153 int fd;
154 int rc = 1;
155 QInputDevice *inputDevice;
156 inputDevice = addUdevDevice(udev);
157 if (!inputDevice) {
158 return Q_NULLPTR;
159 }
160 eventPath = inputDevice->devicePath();
161
162 qDebug() << "Input device added:" << inputDevice->name() << inputDevice->devicePath() << inputDevice->type();
163
164 fd = open(eventPath.toLatin1(), O_RDONLY|O_NONBLOCK);
165 if (fd == -1) {
166 return inputDevice;
167 }
168 rc = libevdev_new_from_fd(fd, &dev);
169 if (rc < 0) {
170 qWarning() << "Failed to init libevdev ("<< strerror(-rc) << ")";
171 return Q_NULLPTR;
172 }
173
174 for (int i = 0; i < EV_MAX; i++) {
175 if (i == EV_KEY || i == EV_SW || i == EV_REL
176 || i == EV_REL || i == EV_ABS) {
177 for (int j = 0; j < libevdev_event_type_get_max(i); j++) {
178 if (libevdev_has_event_code(dev, i, j)) {
179 switch (i) {
180 case EV_KEY:
181 inputDevice->addButton(j);
182 break;
183 case EV_SW:
184 inputDevice->addSwitch(j);
185 break;
186 case EV_REL:
187 inputDevice->addRelativeAxis(j);
188 break;
189 case EV_ABS:
190 inputDevice->addAbsoluteAxis(j);
191 break;
192 };
193 }
194 }
195 }
196 }
197
198 return inputDevice;
199}
200
201void QInputDeviceManagerPrivate::addDetails(struct udev_device *)
202{
203}
204
205void QInputDeviceManagerPrivate::removeDevice(const QString &path)
206{
207 // this path is not a full evdev path
208 Q_FOREACH (const QString devicePath, deviceMap.keys()) {
209 if (devicePath.contains(path)) {
210 qDebug() << "Input device removed:" << deviceMap.value(devicePath)->name() << devicePath << deviceMap.value(devicePath)->type();
211 deviceMap.remove(devicePath);
212 Q_EMIT deviceRemoved(devicePath);
213 }
214 }
215}
216
217QInputDevice *QInputDeviceManagerPrivate::addUdevDevice(struct udev_device *udev)
218{
219 QInputDevice *iDevice;
220
221 struct udev_list_entry *list;
222 struct udev_list_entry *node;
223
224 list = udev_device_get_properties_list_entry (udev);
225 QString syspath = QString::fromLatin1(udev_device_get_syspath(udev));
226 QDir sysdir(syspath);
227
228 QStringList infoList = sysdir.entryList(QStringList() << QStringLiteral("event*"),QDir::Dirs);
229
230 if (infoList.count() > 0) {
231 QString token = infoList.at(0);
232
233 token.prepend(QStringLiteral("/dev/input/"));
234 iDevice = new QInputDevice(this);
235 iDevice->setDevicePath(token);
236 } else {
237 return Q_NULLPTR;
238 }
239 udev_list_entry_foreach (node, list) {
240
241 QString key = QString::fromLatin1(udev_list_entry_get_name(node));
242 QString value = QString::fromLatin1(udev_list_entry_get_value(node));
243
244 if (key == QStringLiteral("NAME")) {
245 iDevice->setName(value.remove(QStringLiteral("\"")));
246 }
247 }
248 iDevice->setType(getInputTypeFlags(udev));
249 return iDevice;
250}
251
252void QInputDeviceManagerPrivate::onUDevChanges()
253{
254 if (!udevMonitor)
255 return;
256
257 udev_device *dev = udev_monitor_receive_device(udevMonitor);
258
259 if (dev) {
260 if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) {
261 QString eventPath = QString::fromLatin1(udev_device_get_sysname(dev));
262
263 QString action = QString::fromStdString(udev_device_get_action(dev));
264
265 if (!eventPath.contains(QStringLiteral("/dev/input/")))
266 eventPath.prepend(QStringLiteral("/dev/input/"));
267
268 if (action == QStringLiteral("add")) {
269 if (deviceMap.contains(eventPath)){
270 udev_device_unref(dev);
271 return;
272 }
273
274 QInputDevice *iDevice = addDevice(dev);
275 if (!iDevice) {
276 delete iDevice;
277 return;
278 }
279 iDevice->setType(getInputTypeFlags(dev));
280 udev_device_unref(dev);
281
282 deviceMap.insert(eventPath,iDevice);
283
284 Q_EMIT deviceAdded(eventPath);
285
286 } else if (action == QStringLiteral("remove")) {
287 removeDevice(eventPath);
288 }
289 }
290 }
291}
0292
=== added file 'src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h'
--- src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 2016-01-29 09:32:29 +0000
@@ -0,0 +1,98 @@
1/****************************************************************************
2**
3** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QINPUTDEVICEINFO_LINUX_P_H
43#define QINPUTDEVICEINFO_LINUX_P_H
44
45#include <QObject>
46#include "qinputinfo.h"
47#include <libudev.h>
48
49class QInputDevicePrivate : public QObject
50{
51 Q_OBJECT
52public:
53 explicit QInputDevicePrivate(QObject *parent = 0);
54
55 QString name;
56 QString devicePath;
57 QList <int> buttons; //keys
58 QList <int> switches;
59 QList <int> relativeAxis;
60 QList <int> absoluteAxis;
61 QInputDevice::InputTypeFlags type;
62};
63
64class QInputDeviceManagerPrivate : public QObject
65{
66 Q_OBJECT
67public:
68 explicit QInputDeviceManagerPrivate(QObject *parent = 0);
69 ~QInputDeviceManagerPrivate();
70 QVector <QInputDevice *> deviceList;
71 QMap <QString, QInputDevice *> deviceMap;
72 static QInputDeviceManagerPrivate * instance();
73 QInputDevice::InputType currentFilter;
74
75Q_SIGNALS:
76 void deviceAdded(const QString &);
77 void deviceRemoved(const QString &);
78 void ready();
79
80private:
81 QInputDevice *addDevice(struct udev_device *udev);
82 QInputDevice *addUdevDevice(struct udev_device *);
83
84 QInputDevice *addDevice(const QString &path);
85 void removeDevice(const QString &path);
86 QSocketNotifier *notifier;
87 int notifierFd;
88 struct udev_monitor *udevMonitor;
89 QInputDevice::InputTypeFlags getInputTypeFlags(struct udev_device *);
90 struct udev *udevice;
91 void addDetails(struct udev_device *);
92
93private Q_SLOTS:
94 void onUDevChanges();
95 void init();
96};
97
98#endif // QINPUTDEVICEINFO_LINUX_P_H
099
=== added file 'src/app/unity8/plugins/Unity/InputInfo/plugin.cpp'
--- src/app/unity8/plugins/Unity/InputInfo/plugin.cpp 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/plugin.cpp 2016-01-29 09:32:29 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17// Qt
18#include <QtQml/qqml.h>
19
20// self
21#include "plugin.h"
22
23// local
24#include "qdeclarativeinputdevicemodel_p.h"
25
26void InputInfoPlugin::registerTypes(const char *uri)
27{
28 int major = 0;
29 int minor = 1;
30 qmlRegisterType<QDeclarativeInputDeviceModel>(uri, major, minor, "InputDeviceModel");
31 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
32}
033
=== added file 'src/app/unity8/plugins/Unity/InputInfo/plugin.h'
--- src/app/unity8/plugins/Unity/InputInfo/plugin.h 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/plugin.h 2016-01-29 09:32:29 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef INPUTINFO_PLUGIN_H
18#define INPUTINFO_PLUGIN_H
19
20#include <QtQml/QQmlExtensionPlugin>
21
22class InputInfoPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26public:
27 void registerTypes(const char *uri);
28};
29
30#endif // INPUTINFO_PLUGIN_H
031
=== added file 'src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp'
--- src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp 2016-01-29 09:32:29 +0000
@@ -0,0 +1,196 @@
1/****************************************************************************
2**
3** Copyright (C) 2015 Jolla.
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41#include "qdeclarativeinputdevicemodel_p.h"
42#include "qinputinfo.h"
43
44QDeclarativeInputDeviceModel::QDeclarativeInputDeviceModel(QObject *parent) :
45 QAbstractListModel(parent),
46 deviceInfo(new QInputDeviceManager),
47 currentFilter(QInputDevice::Unknown)
48{
49 connect(deviceInfo,SIGNAL(ready()),this,SLOT(updateDeviceList()));
50 connect(deviceInfo, &QInputDeviceManager::deviceAdded,this,&QDeclarativeInputDeviceModel::addedDevice);
51 connect(deviceInfo, &QInputDeviceManager::deviceRemoved,this,&QDeclarativeInputDeviceModel::removedDevice);
52}
53
54QDeclarativeInputDeviceModel::~QDeclarativeInputDeviceModel()
55{
56 delete deviceInfo;
57}
58
59QVariant QDeclarativeInputDeviceModel::data(const QModelIndex &index, int role) const
60{
61 switch (role) {
62 case ServiceRole:
63 return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row())));
64 break;
65 case NameRole:
66 return QVariant::fromValue(static_cast<QString>(inputDevices.value(index.row())->name()));
67 break;
68 case DevicePathRole:
69 return QVariant::fromValue(static_cast<QString>(inputDevices.value(index.row())->devicePath()));
70 break;
71 case ButtonsRole:
72 return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->buttons()));
73 break;
74 case SwitchesRole:
75 return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->switches()));
76 break;
77 case RelativeAxisRole:
78 return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->relativeAxis()));
79 break;
80 case AbsoluteAxisRole:
81 return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->absoluteAxis()));
82 break;
83 case TypesRole:
84 return QVariant::fromValue(static_cast<int>(inputDevices.value(index.row())->type()));
85 break;
86 };
87
88 return QVariant();
89}
90
91int QDeclarativeInputDeviceModel::rowCount(const QModelIndex &parent) const
92{
93 Q_UNUSED(parent);
94
95 return inputDevices.count();
96}
97
98int QDeclarativeInputDeviceModel::indexOf(const QString &devicePath) const
99{
100 int idx(-1);
101 Q_FOREACH (QInputDevice *device, inputDevices) {
102 idx++;
103 if (device->devicePath() == devicePath) return idx;
104 }
105
106 return -1;
107}
108
109QInputDevice *QDeclarativeInputDeviceModel::get(int index) const
110{
111 if (index < 0 || index > inputDevices.count())
112 return 0;
113 return inputDevices.value(index);
114}
115
116void QDeclarativeInputDeviceModel::updateDeviceList()
117{
118 QVector <QInputDevice *> newDevices = deviceInfo->deviceListOfType(currentFilter);
119
120 int numNew = newDevices.count();
121
122 for (int i = 0; i < numNew; i++) {
123 int j = inputDevices.indexOf(newDevices.value(i));
124
125 if (j == -1) {
126 beginInsertRows(QModelIndex(), i, i);
127 inputDevices.insert(i, newDevices.value(i));
128 endInsertRows();
129 Q_EMIT countChanged();
130 } else if (i != j) {
131 // changed its position -> move it
132 QInputDevice* device = inputDevices.value(j);
133 beginMoveRows(QModelIndex(), j, j, QModelIndex(), i);
134 inputDevices.remove(j);
135 inputDevices.insert(i, device);
136 endMoveRows();
137 Q_EMIT countChanged();
138 } //else {
139 QModelIndex changedIndex(this->index(j, 0, QModelIndex()));
140 Q_EMIT dataChanged(changedIndex, changedIndex);
141 }
142
143 int numOld = inputDevices.count();
144 if (numOld > numNew) {
145 beginRemoveRows(QModelIndex(), numNew, numOld - 1);
146 inputDevices.remove(numNew, numOld - numNew);
147 endRemoveRows();
148 Q_EMIT countChanged();
149 }
150}
151
152void QDeclarativeInputDeviceModel::addedDevice(const QString &devicePath)
153{
154 updateDeviceList();
155 Q_EMIT deviceAdded(devicePath);
156}
157
158void QDeclarativeInputDeviceModel::removedDevice(const QString &devicePath)
159{
160 updateDeviceList();
161 Q_EMIT deviceRemoved(devicePath);
162}
163
164QHash<int,QByteArray> QDeclarativeInputDeviceModel::roleNames() const
165{
166 QHash<int, QByteArray> roles;
167 roles[NameRole] = "name";
168 roles[DevicePathRole] = "devicePath";
169 roles[ButtonsRole] = "buttons";
170 roles[SwitchesRole] = "switches";
171 roles[RelativeAxisRole] = "rAxis";
172 roles[AbsoluteAxisRole] = "aAxis";
173 roles[TypesRole] = "types";
174 return roles;
175}
176
177/*
178 * Returns the currently set device filter.
179 * */
180QInputDevice::InputType QDeclarativeInputDeviceModel::deviceFilter()
181{
182 return currentFilter;
183}
184
185/*
186 * Sets the current input device filter to filter.
187 * */
188void QDeclarativeInputDeviceModel::setDeviceFilter(QInputDevice::InputType filter)
189{
190 if (filter != currentFilter) {
191 deviceInfo->setDeviceFilter(filter);
192 currentFilter = filter;
193 updateDeviceList();
194 Q_EMIT deviceFilterChanged(filter);
195 }
196}
0197
=== added file 'src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h'
--- src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h 2016-01-29 09:32:29 +0000
@@ -0,0 +1,102 @@
1/****************************************************************************
2**
3** Copyright (C) 2015 Jolla.
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVEINPUTDEVICEMODEL_H
43#define QDECLARATIVEINPUTDEVICEMODEL_H
44
45#include <QObject>
46#include <QAbstractListModel>
47#include "qinputinfo.h"
48
49class QDeclarativeInputDeviceModel : public QAbstractListModel
50{
51 Q_OBJECT
52 Q_DISABLE_COPY(QDeclarativeInputDeviceModel)
53 Q_PROPERTY(QInputDevice::InputType deviceFilter READ deviceFilter WRITE setDeviceFilter NOTIFY deviceFilterChanged)
54
55 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
56
57public:
58 enum ItemRoles {
59 ServiceRole = Qt::UserRole + 1,
60 NameRole,
61 DevicePathRole,
62 ButtonsRole,
63 SwitchesRole,
64 RelativeAxisRole,
65 AbsoluteAxisRole,
66 TypesRole
67 };
68
69 explicit QDeclarativeInputDeviceModel(QObject *parent = 0);
70 virtual ~QDeclarativeInputDeviceModel();
71
72 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
73 int rowCount(const QModelIndex &parent = QModelIndex()) const;
74
75 void setDeviceFilter(QInputDevice::InputType filter);
76 QInputDevice::InputType deviceFilter();
77
78 Q_INVOKABLE int indexOf(const QString &devicePath) const;
79
80 Q_INVOKABLE QInputDevice *get(int index) const;
81 QHash<int, QByteArray> roleNames() const;
82
83Q_SIGNALS:
84 void deviceAdded(const QString &devicePath);
85 void deviceRemoved(const QString &devicePath);
86 void deviceFilterChanged(const QInputDevice::InputType filter);
87 void countChanged();
88
89public Q_SLOTS:
90 void updateDeviceList();
91private:
92 QInputDeviceManager *deviceInfo;
93 QVector<QInputDevice *> inputDevices;
94 QInputDevice::InputType currentFilter;
95
96private Q_SLOTS:
97 void addedDevice(const QString &);
98 void removedDevice(const QString &path);
99
100};
101
102#endif // QDECLARATIVEINPUTDEVICEMODEL_H
0103
=== added file 'src/app/unity8/plugins/Unity/InputInfo/qinputinfo.cpp'
--- src/app/unity8/plugins/Unity/InputInfo/qinputinfo.cpp 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/qinputinfo.cpp 2016-01-29 09:32:29 +0000
@@ -0,0 +1,270 @@
1/****************************************************************************
2**
3** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qinputinfo.h"
43
44#if defined(UNITY_MOCKS)
45#include "qinputdeviceinfo_mock_p.h"
46#elif defined(Q_OS_LINUX)
47#include "linux/qinputdeviceinfo_linux_p.h"
48#endif
49
50Q_GLOBAL_STATIC(QInputDeviceManagerPrivate, inputDeviceManagerPrivate)
51
52QT_BEGIN_NAMESPACE
53
54QInputDeviceManagerPrivate * QInputDeviceManagerPrivate::instance()
55{
56 QInputDeviceManagerPrivate *priv = inputDeviceManagerPrivate();
57 return priv;
58}
59
60QInputDevicePrivate::QInputDevicePrivate(QObject *parent) :
61 QObject(parent),
62 type(QInputDevice::Unknown)
63{
64}
65
66QInputDevice::QInputDevice(QObject *parent) :
67 QObject(parent),
68 d_ptr(new QInputDevicePrivate(this))
69{
70}
71
72/*
73 * Returns the name of this input device.
74 */
75QString QInputDevice::name() const
76{
77 return d_ptr->name;
78}
79
80/*
81 * Sets the name of this input device to \b name.
82 */
83void QInputDevice::setName(const QString &name)
84{
85 d_ptr->name = name;
86}
87
88/*
89 * Returns the device path of this device.
90 */
91QString QInputDevice::devicePath() const
92{
93 return d_ptr->devicePath;
94}
95
96/*
97 * Sets the device ppath of this device to /b path.
98 */
99void QInputDevice::setDevicePath(const QString &path)
100{
101 d_ptr->devicePath = path;
102}
103
104/*
105 * Returns the number of buttons this device has.
106 */
107QList <int> QInputDevice::buttons() const
108{
109 return d_ptr->buttons;
110}
111
112/*
113 * Adds a button
114 */
115void QInputDevice::addButton(int buttonCode)
116{
117 d_ptr->buttons.append(buttonCode);
118}
119
120/*
121 * Returns the number of switch of this device.
122 */
123QList <int> QInputDevice::switches() const
124{
125 return d_ptr->switches;
126}
127
128/*
129 * Adds a switch
130 */
131void QInputDevice::addSwitch(int switchCode)
132{
133 d_ptr->switches.append(switchCode);
134}
135
136/*
137 * Returns a list of the relative axis of this device
138 */
139QList <int> QInputDevice::relativeAxis() const
140{
141 return d_ptr->relativeAxis;
142}
143
144/*
145 */
146void QInputDevice::addRelativeAxis(int axisCode)
147{
148 d_ptr->relativeAxis.append(axisCode);
149}
150
151/*
152 * Returns a list of the absolute axis of this device
153 */
154QList <int> QInputDevice::absoluteAxis() const
155{
156 return d_ptr->absoluteAxis;
157}
158
159/*
160 */
161void QInputDevice::addAbsoluteAxis(int axisCode)
162{
163 d_ptr->absoluteAxis.append(axisCode);
164}
165
166/*
167 * Returns a QInputDevice::InputTypeFlags of all the types of types.
168 */
169QInputDevice::InputTypeFlags QInputDevice::type() const
170{
171 return d_ptr->type;
172}
173
174/*
175 */
176void QInputDevice::setType(QInputDevice::InputTypeFlags type) //? setTypes?
177{
178 d_ptr->type = type;
179}
180
181QInputDeviceManager::QInputDeviceManager(QObject *parent) :
182 QObject(parent),
183 d_ptr(inputDeviceManagerPrivate)
184{
185 connect(d_ptr, &QInputDeviceManagerPrivate::deviceAdded,this,&QInputDeviceManager::addedDevice);
186 connect(d_ptr, &QInputDeviceManagerPrivate::deviceRemoved,this,&QInputDeviceManager::deviceRemoved);
187
188 connect(d_ptr,SIGNAL(ready()),this,SIGNAL(ready()));
189}
190
191/*
192 * Returns a QMap of known input devices.
193 */
194QMap <QString, QInputDevice *> QInputDeviceManager::deviceMap()
195{
196 return d_ptr->deviceMap;
197}
198
199/*
200 */
201void QInputDeviceManager::addedDevice(const QString & devicePath)
202{
203 Q_EMIT deviceAdded(devicePath);
204}
205
206/*
207 * Returns a QVector of InputDevices of type filter
208 * */
209QVector <QInputDevice *> QInputDeviceManager::deviceListOfType(QInputDevice::InputType filter)
210{
211 QVector <QInputDevice *> dList;
212 QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
213 while (i.hasNext()) {
214 i.next();
215 if (i.value()->type().testFlag(filter) || filter == QInputDevice::Unknown) {
216 dList.append(i.value());
217 }
218 }
219 return dList;
220}
221
222/*
223 * Returns the number of input devices with the currently set QInputDevice::InputType filter.
224 * If no device filter has been set, returns number of all available input devices.
225 * If filter has not been set, returns all available input devices
226 */
227int QInputDeviceManager::deviceCount() const
228{
229 return deviceCount(static_cast< QInputDevice::InputType >(d_ptr->currentFilter));
230}
231
232/*
233 * Returns the number of input devices of the type filter.
234 */
235int QInputDeviceManager::deviceCount(const QInputDevice::InputType filter) const
236{
237 int dList = 0;
238 QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
239 while (i.hasNext()) {
240 i.next();
241// qDebug() << i.value()->name() << i.value()->devicePath();
242// qDebug() << i.value()->type() << i.value()->type().testFlag(filter);
243
244 if (i.value()->type().testFlag(filter)) {
245 dList++;
246 }
247 }
248 return dList;
249}
250
251/*
252 * Returns the currently set device filter.
253 * */
254QInputDevice::InputType QInputDeviceManager::deviceFilter()
255{
256 return d_ptr->currentFilter;
257}
258
259/*
260 * Sets the current input device filter to filter.
261 * */
262void QInputDeviceManager::setDeviceFilter(QInputDevice::InputType filter)
263{
264 if (filter != d_ptr->currentFilter) {
265 d_ptr->currentFilter = filter;
266 Q_EMIT deviceFilterChanged(filter);
267 }
268}
269
270QT_END_NAMESPACE
0271
=== added file 'src/app/unity8/plugins/Unity/InputInfo/qinputinfo.h'
--- src/app/unity8/plugins/Unity/InputInfo/qinputinfo.h 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/qinputinfo.h 2016-01-29 09:32:29 +0000
@@ -0,0 +1,143 @@
1/****************************************************************************
2**
3** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QINPUTINFO_H
43#define QINPUTINFO_H
44
45#include <QObject>
46#include <QVector>
47#include <QMap>
48#include <QSocketNotifier>
49#include <QDebug>
50
51class QInputDeviceManagerPrivate;
52class QInputDevicePrivate;
53class QInputDevice;
54
55class QInputDeviceManager;
56
57class QInputDevice : public QObject
58{
59 Q_OBJECT
60 Q_ENUMS(InputType)
61 Q_FLAGS(InputType InputTypeFlags)
62 friend class QInputDeviceManagerPrivate;
63
64public:
65
66 enum InputType {
67 Unknown = 0,
68 Button = 1,
69 Mouse = 2,
70 TouchPad = 4,
71 TouchScreen = 8,
72 Keyboard = 16,
73 Switch = 32
74 };
75 Q_ENUMS(InputType)
76 Q_DECLARE_FLAGS(InputTypeFlags, InputType)
77
78 explicit QInputDevice(QObject *parent = 0);
79 QString name() const;
80 QString devicePath() const;
81 QList <int> buttons() const; //keys event code
82 QList <int> switches() const;
83 QList <int> relativeAxis() const;
84 QList <int> absoluteAxis() const;
85 QInputDevice::InputTypeFlags type() const;
86
87private:
88
89 QInputDevicePrivate *d_ptr;
90 void setName(const QString &);
91 void setDevicePath(const QString &);
92 void addButton(int);
93 void addSwitch(int);
94 void addRelativeAxis(int);
95 void addAbsoluteAxis(int);
96 void setType(QInputDevice::InputTypeFlags flags);
97
98};
99
100Q_DECLARE_METATYPE(QInputDevice::InputType)
101Q_DECLARE_METATYPE(QInputDevice::InputTypeFlags)
102
103class QInputDeviceManagerPrivate;
104
105class QInputDeviceManager : public QObject
106{
107 Q_OBJECT
108 Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
109 Q_PROPERTY(QInputDevice::InputType deviceFilter READ deviceFilter WRITE setDeviceFilter NOTIFY deviceFilterChanged)
110public:
111
112 explicit QInputDeviceManager(QObject *parent = 0);
113
114 int deviceCount() const;
115 int deviceCount(const QInputDevice::InputType filter) const;
116
117 void setDeviceFilter(QInputDevice::InputType filter);
118 QInputDevice::InputType deviceFilter();
119
120 QMap <QString, QInputDevice *> deviceMap();
121 Q_INVOKABLE QVector <QInputDevice *> deviceListOfType(QInputDevice::InputType filter);
122
123Q_SIGNALS:
124
125 void deviceAdded(const QString & devicePath);
126 void deviceRemoved(const QString & devicePath);
127
128 void ready();
129 void deviceCountChanged(int count);
130 void deviceFilterChanged(const QInputDevice::InputType filter);
131
132public Q_SLOTS:
133 void addedDevice(const QString & devicePath);
134
135private:
136 Q_DISABLE_COPY(QInputDeviceManager)
137#if !defined(QT_SIMULATOR)
138 QInputDeviceManagerPrivate *const d_ptr;
139 Q_DECLARE_PRIVATE(QInputDeviceManager)
140#endif
141};
142
143#endif // QINPUTINFO_H
0144
=== added file 'src/app/unity8/plugins/Unity/InputInfo/qmldir'
--- src/app/unity8/plugins/Unity/InputInfo/qmldir 1970-01-01 00:00:00 +0000
+++ src/app/unity8/plugins/Unity/InputInfo/qmldir 2016-01-29 09:32:29 +0000
@@ -0,0 +1,3 @@
1module Unity.InputInfo
2plugin InputInfo
3typeinfo InputInfo.qmltypes
04
=== modified file 'src/app/webbrowser/Browser.qml'
--- src/app/webbrowser/Browser.qml 2016-01-22 10:23:17 +0000
+++ src/app/webbrowser/Browser.qml 2016-01-29 09:32:29 +0000
@@ -22,6 +22,7 @@
22import com.canonical.Oxide 1.8 as Oxide22import com.canonical.Oxide 1.8 as Oxide
23import Ubuntu.Components 1.323import Ubuntu.Components 1.3
24import Ubuntu.Components.Popups 1.324import Ubuntu.Components.Popups 1.3
25import Unity.InputInfo 0.1
25import webbrowserapp.private 0.126import webbrowserapp.private 0.1
26import webbrowsercommon.private 0.127import webbrowsercommon.private 0.1
27import "../actions" as Actions28import "../actions" as Actions
@@ -95,6 +96,16 @@
95 onMediaAccessPermissionRequested: PopupUtils.open(mediaAccessDialogComponent, null, { request: request })96 onMediaAccessPermissionRequested: PopupUtils.open(mediaAccessDialogComponent, null, { request: request })
96 }97 }
9798
99 InputDeviceModel {
100 id: miceModel
101 deviceFilter: InputInfo.Mouse
102 }
103
104 InputDeviceModel {
105 id: touchPadModel
106 deviceFilter: InputInfo.TouchPad
107 }
108
98 Component {109 Component {
99 id: mediaAccessDialogComponent110 id: mediaAccessDialogComponent
100 MediaAccessDialog { }111 MediaAccessDialog { }
@@ -181,7 +192,7 @@
181 right: parent.right192 right: parent.right
182 top: parent.top193 top: parent.top
183 }194 }
184 height: parent.height - osk.height195 height: parent.height - osk.height - bottomEdgeBar.height
185196
186 focus: !errorSheetLoader.focus &&197 focus: !errorSheetLoader.focus &&
187 !invalidCertificateErrorSheetLoader.focus &&198 !invalidCertificateErrorSheetLoader.focus &&
@@ -531,23 +542,6 @@
531 onTriggered: historyViewLoader.active = true542 onTriggered: historyViewLoader.active = true
532 },543 },
533 Action {544 Action {
534 objectName: "tabs"
535 text: i18n.tr("Open tabs")
536 iconName: "browser-tabs"
537 enabled: (formFactor != "mobile") && !browser.wide
538 onTriggered: {
539 recentView.state = "shown"
540 recentToolbar.state = "shown"
541 }
542 },
543 Action {
544 objectName: "newtab"
545 text: i18n.tr("New tab")
546 iconName: browser.incognito ? "private-tab-new" : "tab-new"
547 enabled: (formFactor != "mobile") && !browser.wide
548 onTriggered: browser.openUrlInNewTab("", true)
549 },
550 Action {
551 objectName: "findinpage"545 objectName: "findinpage"
552 text: i18n.tr("Find in page")546 text: i18n.tr("Find in page")
553 iconName: "search"547 iconName: "search"
@@ -697,8 +691,8 @@
697 }691 }
698 height: units.gu(2)692 height: units.gu(2)
699693
700 enabled: (formFactor == "mobile") && !browser.wide &&694 enabled: !browser.wide && (recentView.state == "") &&
701 (recentView.state == "") && browser.currentWebview &&695 browser.currentWebview &&
702 (Screen.orientation == Screen.primaryOrientation)696 (Screen.orientation == Screen.primaryOrientation)
703697
704 onDraggingChanged: {698 onDraggingChanged: {
@@ -728,7 +722,7 @@
728 Image {722 Image {
729 id: bottomEdgeHint723 id: bottomEdgeHint
730 objectName: "bottomEdgeHint"724 objectName: "bottomEdgeHint"
731 source: (formFactor == "mobile") ? "assets/bottom_edge_hint.png" : ""725 source: "assets/bottom_edge_hint.png"
732 property bool forceShow: false726 property bool forceShow: false
733 anchors {727 anchors {
734 horizontalCenter: parent.horizontalCenter728 horizontalCenter: parent.horizontalCenter
@@ -738,7 +732,7 @@
738 UbuntuNumberAnimation {}732 UbuntuNumberAnimation {}
739 }733 }
740 }734 }
741 visible: bottomEdgeHandle.enabled735 visible: bottomEdgeHandle.enabled && !internal.hasMouse
742 opacity: recentView.visible ? 0 : 1736 opacity: recentView.visible ? 0 : 1
743 Behavior on opacity {737 Behavior on opacity {
744 UbuntuNumberAnimation {}738 UbuntuNumberAnimation {}
@@ -757,6 +751,40 @@
757 }751 }
758 }752 }
759753
754 MouseArea {
755 id: bottomEdgeBar
756 anchors {
757 left: parent.left
758 right: parent.right
759 bottom: parent.bottom
760 }
761 enabled: !browser.wide && internal.hasMouse &&
762 (osk.state == "hidden") && (recentView.state == "")
763 visible: enabled
764 height: visible ? units.gu(4) : 0
765
766 onClicked: {
767 recentView.state = "shown"
768 recentToolbar.state = "shown"
769 }
770
771 Rectangle {
772 anchors.fill: parent
773 color: "#f7f7f7"
774 border {
775 width: units.dp(1)
776 color: "#cdcdcd"
777 }
778 }
779
780 Label {
781 anchors.centerIn: parent
782 color: "#5d5d5d"
783 // TRANSLATORS: %1 refers to the current number of tabs opened
784 text: i18n.tr("(%1)").arg(tabsModel ? tabsModel.count : 0)
785 }
786 }
787
760 Loader {788 Loader {
761 id: bookmarksViewLoader789 id: bookmarksViewLoader
762790
@@ -1403,6 +1431,8 @@
1403 }1431 }
1404 }1432 }
14051433
1434 readonly property bool hasMouse: (miceModel.count + touchPadModel.count) > 0
1435
1406 function getOpenPages() {1436 function getOpenPages() {
1407 var urls = []1437 var urls = []
1408 for (var i = 0; i < tabsModel.count; i++) {1438 for (var i = 0; i < tabsModel.count; i++) {

Subscribers

People subscribed via source and target branches

to status/vote changes: