Merge lp:~mzanetti/unity8/update-inputinfo into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 2001
Merged at revision: 2050
Proposed branch: lp:~mzanetti/unity8/update-inputinfo
Merge into: lp:unity8
Diff against target: 2544 lines (+903/-1079)
26 files modified
plugins/Unity/InputInfo/CMakeLists.txt (+1/-1)
plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp (+146/-98)
plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h (+13/-6)
plugins/Unity/InputInfo/plugin.cpp (+2/-2)
plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp (+0/-143)
plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h (+0/-86)
plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp (+196/-0)
plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h (+102/-0)
plugins/Unity/InputInfo/qinputinfo.cpp (+140/-29)
plugins/Unity/InputInfo/qinputinfo.h (+57/-57)
qml/Components/UnityInputInfo/UnityInputInfo.qml (+0/-93)
qml/Components/UnityInputInfo/qmldir (+0/-1)
qml/OrientedShell.qml (+16/-7)
tests/mocks/Unity/InputInfo/CMakeLists.txt (+7/-2)
tests/mocks/Unity/InputInfo/mockcontroller.cpp (+35/-0)
tests/mocks/Unity/InputInfo/mockcontroller.h (+34/-0)
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp (+0/-173)
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h (+0/-94)
tests/mocks/Unity/InputInfo/mockqinputinfo.cpp (+0/-124)
tests/mocks/Unity/InputInfo/mockqinputinfo.h (+0/-139)
tests/mocks/Unity/InputInfo/plugin.cpp (+17/-3)
tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp (+52/-0)
tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.h (+58/-0)
tests/qmltests/Notifications/tst_Notifications.qml (+5/-6)
tests/qmltests/Notifications/tst_SwipeToAct.qml (+5/-6)
tests/qmltests/tst_OrientedShell.qml (+17/-9)
To merge this branch: bzr merge lp:~mzanetti/unity8/update-inputinfo
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Abstain
PS Jenkins bot (community) continuous-integration Needs Fixing
Lukáš Tinkl (community) Approve
Daniel d'Andrada (community) Abstain
Review via email: mp+273248@code.launchpad.net

Commit message

update inputinfo api to the latest upstream snapshot

* Import latest update of api from gerrit.
* drop all the old mock code
* instead of mocking the whole api, add mocks for the backend only. This should simplify future updates and moving to upstream implementation a lot.
* update tests to use new mocking system

Description of the change

Everything in plugins/Unity/InputInfo is taken from https://codereview.qt-project.org/#/c/101049/ as is.

Everything in tests/mocks is our own additions for testing it.

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

nope

 * 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?

n/a

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

n/a

To post a comment you must log in.
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 :

FAILED: Continuous integration, rev:1991
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~mzanetti/unity8/update-inputinfo/+merge/273248/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity8-ci/6446/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4583
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/828
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1158
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/477
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1053
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1054
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/685
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/686
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3715
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4580
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4580/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24116
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/494
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/828
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/828/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24111

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

review: Needs Fixing (continuous-integration)
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)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1995
http://jenkins.qa.ubuntu.com/job/unity8-ci/6520/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4778
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/903
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1232
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/548
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1127
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1128
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/759
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/760
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3851
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4775
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4775/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24484
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/532
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/903
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/903/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24483

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Given that this is (i understand) upstream code, how much review do we want to put in it?

review: Needs Information
Revision history for this message
Michael Zanetti (mzanetti) wrote :

I'd say it'd be good to check it for big mistakes, test if it doesn't break the switching of windowed mode and osk show/hide.

Wouldn't spend to much time reviewing the code itself, as this is basically a review of upstream code. If you spot something, you are welcome to add comments here: https://codereview.qt-project.org/#/c/101049/

Revision history for this message
Albert Astals Cid (aacid) wrote :

I had a look at the code and it looks good, i'll leave someone else with more experience in the windowed mode to have a look at it.

review: Approve (code)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

+ onCountChanged: print("*****************", count)

Forgotten debug output, otherwise code looks good. Gonna test it locally

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> + onCountChanged: print("*****************", count)
>
> Forgotten debug output, otherwise code looks good. Gonna test it locally

oops. fixed

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Does the new upstream code fix the bug I explained in revision 1918?

Copy pasting it here:
"""
- QInputDeviceInfoPrivate::addDevice was bailing out before
  setting the device path, making it impossible for
  indexOf() to find the input device.
  This happens on a desktop/laptop as the user where unity8
  runs cannot open input device files but it's still able to
  get info about it trough udev API
"""

review: Needs Information
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Does the new upstream code fix the bug I explained in revision 1918?
>
> Copy pasting it here:
> """
> - QInputDeviceInfoPrivate::addDevice was bailing out before
> setting the device path, making it impossible for
> indexOf() to find the input device.
> This happens on a desktop/laptop as the user where unity8
> runs cannot open input device files but it's still able to
> get info about it trough udev API
> """

Yes. Seems wherever a valid QInputDevice object is created, the setDevicePath() call always happens immediately after the "new" call now.

Revision history for this message
Daniel d'Andrada (dandrader) :
review: Abstain
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 :

FAILED: Continuous integration, rev:1996
http://jenkins.qa.ubuntu.com/job/unity8-ci/6606/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4941
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/21/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1318
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/21
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1213
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1214
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/20
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/20
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3968
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4938
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4938/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24745
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-mako/11/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/21
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/21/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24743

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Code works fine but this test doesn't succeed: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1318

Running it locally, it crashes with:

Totals: 31 passed, 0 failed, 0 skipped, 0 blacklisted
********* Finished testing of qmltestrunner *********
*** Error in `/usr/lib/x86_64-linux-gnu/qt5/bin/qmltestrunner': free(): invalid pointer: 0x00007fbb3acbb380 ***

review: Needs Fixing
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

^^ make testOrientedShell

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Here's the backtrace:

[Thread 0x7fffe09d9700 (LWP 30234) exited]
*** Error in `/usr/lib/x86_64-linux-gnu/qt5/bin/qmltestrunner': free(): invalid pointer: 0x00007fffda0b6380 ***
[New Thread 0x7fffd355d700 (LWP 30235)]
[New Thread 0x7fffeb5df700 (LWP 30233)]

Program received signal SIGABRT, Aborted.
0x00007ffff7a44267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7a44267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1 0x00007ffff7a45eca in __GI_abort () at abort.c:89
#2 0x00007ffff7a87c53 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff7ba01a8 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff7a8fc69 in malloc_printerr (ptr=<optimized out>, str=0x7ffff7b9c2fa "free(): invalid pointer", action=1) at malloc.c:4965
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3834
#5 0x00007ffff7a9389c in __GI___libc_free (mem=<optimized out>) at malloc.c:2950
#6 0x00007ffff631de91 in QQmlType::SingletonInstanceInfo::destroy(QQmlEngine*) () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#7 0x00007ffff62f4373 in QQmlEngine::~QQmlEngine() () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#8 0x00007ffff62f4499 in QQmlEngine::~QQmlEngine() () from /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#9 0x00007ffff6be869c in QObjectPrivate::deleteChildren() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff6bf2d03 in QObject::~QObject() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff668a959 in QQuickWindow::~QQuickWindow() () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#12 0x00007ffff6739f79 in QQuickView::~QQuickView() () from /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5
#13 0x00007ffff7fbf393 in quick_test_main(int, char**, char const*, char const*) () from /usr/lib/x86_64-linux-gnu/libQt5QuickTest.so.5
#14 0x00007ffff7a2fa40 in __libc_start_main (main=0x4005d0, argc=7, argv=0x7fffffffd9e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd9d8) at libc-start.c:289
#15 0x0000000000400619 in ?? ()

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Turns out the crash was caused by Q_GLOBAL_STATIC and qmlRegisterSingletonType both wanting to delete the object. Had to resort to a rather ugly workaround of adding a proxy object to control the mock backend through qml. This way everyone can delete things and is happy.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Yup, that works for me

* 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.

Xenial tests still broken

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

Yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1996
http://jenkins.qa.ubuntu.com/job/unity8-ci/6624/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4970
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/39/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1336
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/39
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1231
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1232
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/38
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/38
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3991
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4967
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4967/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24795
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-mako/26/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/39
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/39/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24794

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

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

Note: was already top approved

Conflict: can't delete qml/Components/UnityInputInfo because it is not empty. Not deleting.
Conflict because qml/Components/UnityInputInfo is not versioned, but has versioned children. Versioned directory.
Contents conflict in qml/Components/UnityInputInfo/UnityInputInfo.qml
Text conflict in qml/OrientedShell.qml
Text conflict in tests/qmltests/Notifications/tst_Notifications.qml
Text conflict in tests/qmltests/Notifications/tst_SwipeToAct.qml
6 conflicts encountered.

review: Needs Fixing
lp:~mzanetti/unity8/update-inputinfo updated
2000. By Michael Zanetti

merge trunk

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Note: was already top approved
>
> Conflict: can't delete qml/Components/UnityInputInfo because it is not empty.
> Not deleting.
> Conflict because qml/Components/UnityInputInfo is not versioned, but has
> versioned children. Versioned directory.
> Contents conflict in qml/Components/UnityInputInfo/UnityInputInfo.qml
> Text conflict in qml/OrientedShell.qml
> Text conflict in tests/qmltests/Notifications/tst_Notifications.qml
> Text conflict in tests/qmltests/Notifications/tst_SwipeToAct.qml
> 6 conflicts encountered.

merged

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Note: was already top approved
>
> Conflict: can't delete qml/Components/UnityInputInfo because it is not empty.
> Not deleting.
> Conflict because qml/Components/UnityInputInfo is not versioned, but has
> versioned children. Versioned directory.
> Contents conflict in qml/Components/UnityInputInfo/UnityInputInfo.qml
> Text conflict in qml/OrientedShell.qml
> Text conflict in tests/qmltests/Notifications/tst_Notifications.qml
> Text conflict in tests/qmltests/Notifications/tst_SwipeToAct.qml
> 6 conflicts encountered.

merged

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

tests/mocks/Unity/InputInfo/mockcontroller.cpp UNKNOWN *No copyright*

review: Needs Fixing
lp:~mzanetti/unity8/update-inputinfo updated
2001. By Michael Zanetti

add missing copyright header

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> tests/mocks/Unity/InputInfo/mockcontroller.cpp UNKNOWN *No copyright*

fixed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2001
http://jenkins.qa.ubuntu.com/job/unity8-ci/6681/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/5083
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/96/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1393
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/96
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1288
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1289
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/95
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/95
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/4071
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5088
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/5088/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25014
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-mako/51/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/96
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/96/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/25012

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Merged and CI is "good"

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/InputInfo/CMakeLists.txt'
2--- plugins/Unity/InputInfo/CMakeLists.txt 2015-06-22 12:16:38 +0000
3+++ plugins/Unity/InputInfo/CMakeLists.txt 2015-11-09 09:23:42 +0000
4@@ -21,7 +21,7 @@
5 set(InputInfo_SOURCES
6 plugin.cpp
7 qinputinfo.cpp
8- qdeclarativeinputdeviceinfo.cpp
9+ qdeclarativeinputdevicemodel.cpp
10 linux/qinputdeviceinfo_linux.cpp
11 )
12
13
14=== modified file 'plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp'
15--- plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 2015-08-19 13:56:21 +0000
16+++ plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux.cpp 2015-11-09 09:23:42 +0000
17@@ -47,39 +47,46 @@
18 #include <QDebug>
19 #include <QSocketNotifier>
20 #include <QTimer>
21-
22-QInputDeviceInfoPrivate::QInputDeviceInfoPrivate(QObject *parent) :
23- QObject(parent)
24- , udev(0)
25-{
26- QTimer::singleShot(250, this, &QInputDeviceInfoPrivate::init);
27-}
28-
29-void QInputDeviceInfoPrivate::init()
30-{
31- if (!udev)
32- udev = udev_new();
33-
34- struct udev_list_entry *devices, *dev_list_entry;
35- struct udev_device *dev;
36+#include <QDir>
37+
38+QInputDeviceManagerPrivate::QInputDeviceManagerPrivate(QObject *parent) :
39+ QObject(parent),
40+ currentFilter(QInputDevice::Unknown),
41+ udevice(0)
42+{
43+ QTimer::singleShot(250,this,SLOT(init()));
44+}
45+
46+QInputDeviceManagerPrivate::~QInputDeviceManagerPrivate()
47+{
48+ udev_unref(udevice);
49+ udev_monitor_unref(udevMonitor);
50+}
51+
52+void QInputDeviceManagerPrivate::init()
53+{
54+ if (!udevice)
55+ udevice = udev_new();
56+
57+ udev_list_entry *devices;
58+ udev_list_entry *dev_list_entry;
59+ udev_device *dev;
60
61 QString subsystem = QStringLiteral("input");
62 struct udev_enumerate *enumerate = 0;
63
64- if (udev) {
65+ if (udevice) {
66
67- udevMonitor = udev_monitor_new_from_netlink(udev, "udev");
68+ udevMonitor = udev_monitor_new_from_netlink(udevice, "udev");
69 udev_monitor_filter_add_match_subsystem_devtype(udevMonitor, subsystem.toLatin1(), NULL);
70- enumerate = udev_enumerate_new(udev);
71+ enumerate = udev_enumerate_new(udevice);
72 udev_enumerate_add_match_subsystem(enumerate, subsystem.toLatin1());
73
74-
75 udev_monitor_enable_receiving(udevMonitor);
76 notifierFd = udev_monitor_get_fd(udevMonitor);
77
78 notifier = new QSocketNotifier(notifierFd, QSocketNotifier::Read, this);
79- connect(notifier, &QSocketNotifier::activated, this, &QInputDeviceInfoPrivate::onUDevChanges);
80-
81+ connect(notifier, SIGNAL(activated(int)), this, SLOT(onUDevChanges()));
82
83 udev_enumerate_scan_devices(enumerate);
84 devices = udev_enumerate_get_list_entry(enumerate);
85@@ -88,78 +95,80 @@
86 const char *path;
87 path = udev_list_entry_get_name(dev_list_entry);
88
89- dev = udev_device_new_from_syspath(udev, path);
90-
91- QString eventPath = QString::fromLatin1(udev_device_get_sysname(dev));
92-
93+ dev = udev_device_new_from_syspath(udevice, path);
94 if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) {
95-
96- if (eventPath.contains(QStringLiteral("event"))) {
97- eventPath.prepend(QStringLiteral("/dev/input/"));
98-
99- QInputDevice *iDevice = addDevice(eventPath);
100- if (!iDevice)
101- continue;
102-
103- iDevice->setTypes(getInputTypes(dev));
104-
105- if (iDevice->switches().count() > 0 && iDevice->buttons().count() == 0)
106- iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Switch);
107-
108- if (iDevice->buttons().count() > 0 && iDevice->types() == QInputDeviceInfo::Unknown)
109- iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Button);
110-
111- deviceList.append(iDevice);
112- deviceMap.insert(eventPath,iDevice);
113- Q_EMIT newDevice(eventPath);
114-
115+ QInputDevice *iDevice = addDevice(dev);
116+ if (iDevice && !iDevice->devicePath().isEmpty()) {
117+ deviceMap.insert(iDevice->devicePath(),iDevice);
118 }
119 }
120+ udev_device_unref(dev);
121 }
122 udev_enumerate_unref(enumerate);
123 }
124+ // udev_unref(udevice);
125+ Q_FOREACH (const QString &devicePath, deviceMap.keys()) {
126+ Q_EMIT deviceAdded(devicePath);
127+ }
128 Q_EMIT ready();
129 }
130
131-QInputDeviceInfo::InputTypes QInputDeviceInfoPrivate::getInputTypes( struct udev_device *dev)
132+QInputDevice::InputTypeFlags QInputDeviceManagerPrivate::getInputTypeFlags(struct udev_device *dev)
133 {
134- QInputDeviceInfo::InputTypes types = QInputDeviceInfo::Unknown;
135- if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )
136- types |= QInputDeviceInfo::Keyboard;
137-
138- if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0)
139- types |= QInputDeviceInfo::Mouse;
140-
141- if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0)
142- types |= QInputDeviceInfo::TouchPad;
143-
144+ QInputDevice::InputTypeFlags flags = QInputDevice::Unknown;
145+ if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEY"), "1") == 0 ) {
146+ flags |= QInputDevice::Button;
147+ }
148+ if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0) {
149+ flags |= QInputDevice::Mouse;
150+ }
151+ if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0) {
152+ flags |= QInputDevice::TouchPad;
153+ }
154 if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0
155- || qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TABLET"), "1") == 0)
156- types |= QInputDeviceInfo::TouchScreen;
157+ || qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TABLET"), "1") == 0) {
158+ flags |= QInputDevice::TouchScreen;
159+ }
160+ if (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 ) {
161+ flags |= QInputDevice::Keyboard;
162+ }
163+ if (!QString::fromLatin1(udev_device_get_property_value(dev, "SW")).isEmpty()) {
164+ flags |= QInputDevice::Switch;
165+ }
166
167- return types;
168+ return flags;
169 }
170
171-QInputDevice *QInputDeviceInfoPrivate::addDevice(const QString &path)
172+QInputDevice *QInputDeviceManagerPrivate::addDevice(struct udev_device *udev)
173 {
174- QInputDevice *inputDevice = new QInputDevice(this);
175- inputDevice->setDevicePath(path);
176-
177+ QString eventPath = QString::fromLatin1(udev_device_get_sysname(udev));
178+
179+ if (eventPath.contains(QStringLiteral("event")))
180+ eventPath.prepend(QStringLiteral("/dev/input/"));
181+
182+ if (deviceMap.contains(eventPath)) {
183+ return Q_NULLPTR;
184+ }
185 struct libevdev *dev = NULL;
186 int fd;
187 int rc = 1;
188- fd = open(path.toLatin1(), O_RDONLY|O_NONBLOCK);
189+ QInputDevice *inputDevice;
190+ inputDevice = addUdevDevice(udev);
191+ if (!inputDevice) {
192+ return Q_NULLPTR;
193+ }
194+ eventPath = inputDevice->devicePath();
195
196+ fd = open(eventPath.toLatin1(), O_RDONLY|O_NONBLOCK);
197 if (fd == -1) {
198 return inputDevice;
199 }
200 rc = libevdev_new_from_fd(fd, &dev);
201 if (rc < 0) {
202 qWarning() << "Failed to init libevdev ("<< strerror(-rc) << ")";
203- return inputDevice;
204+ return Q_NULLPTR;
205 }
206
207- inputDevice->setName(QString::fromLatin1(libevdev_get_name(dev)));
208 for (int i = 0; i < EV_MAX; i++) {
209 if (i == EV_KEY || i == EV_SW || i == EV_REL
210 || i == EV_REL || i == EV_ABS) {
211@@ -183,54 +192,93 @@
212 }
213 }
214 }
215+
216 return inputDevice;
217 }
218
219-void QInputDeviceInfoPrivate::removeDevice(const QString &path)
220-{
221- for (int i = 0; i < deviceList.size(); ++i) {
222- if (deviceList.at(i)->devicePath() == path) {
223- delete deviceList.takeAt(i);
224- deviceMap.remove(path);
225- Q_EMIT deviceRemoved(path);
226- }
227- }
228-}
229-
230-void QInputDeviceInfoPrivate::onUDevChanges()
231-{
232- struct udev_device *dev = udev_monitor_receive_device(udevMonitor);
233+void QInputDeviceManagerPrivate::addDetails(struct udev_device *)
234+{
235+}
236+
237+void QInputDeviceManagerPrivate::removeDevice(const QString &path)
238+{
239+ // this path is not a full evdev path
240+ Q_FOREACH (const QString devicePath, deviceMap.keys()) {
241+ if (devicePath.contains(path)) {
242+ deviceMap.remove(devicePath);
243+ Q_EMIT deviceRemoved(devicePath);
244+ }
245+ }
246+}
247+
248+QInputDevice *QInputDeviceManagerPrivate::addUdevDevice(struct udev_device *udev)
249+{
250+ QInputDevice *iDevice;
251+
252+ struct udev_list_entry *list;
253+ struct udev_list_entry *node;
254+
255+ list = udev_device_get_properties_list_entry (udev);
256+ QString syspath = QString::fromLatin1(udev_device_get_syspath(udev));
257+ QDir sysdir(syspath);
258+
259+ QStringList infoList = sysdir.entryList(QStringList() << QStringLiteral("event*"),QDir::Dirs);
260+
261+ if (infoList.count() > 0) {
262+ QString token = infoList.at(0);
263+
264+ token.prepend(QStringLiteral("/dev/input/"));
265+ iDevice = new QInputDevice(this);
266+ iDevice->setDevicePath(token);
267+ } else {
268+ return Q_NULLPTR;
269+ }
270+ udev_list_entry_foreach (node, list) {
271+
272+ QString key = QString::fromLatin1(udev_list_entry_get_name(node));
273+ QString value = QString::fromLatin1(udev_list_entry_get_value(node));
274+
275+ if (key == QStringLiteral("NAME")) {
276+ iDevice->setName(value.remove(QStringLiteral("\"")));
277+ }
278+ }
279+ iDevice->setType(getInputTypeFlags(udev));
280+ return iDevice;
281+}
282+
283+void QInputDeviceManagerPrivate::onUDevChanges()
284+{
285+ if (!udevMonitor)
286+ return;
287+
288+ udev_device *dev = udev_monitor_receive_device(udevMonitor);
289+
290 if (dev) {
291 if (qstrcmp(udev_device_get_subsystem(dev), "input") == 0 ) {
292 QString eventPath = QString::fromLatin1(udev_device_get_sysname(dev));
293
294- if (eventPath.contains(QStringLiteral("input")))
295- return;
296-
297 QString action = QString::fromStdString(udev_device_get_action(dev));
298
299 if (!eventPath.contains(QStringLiteral("/dev/input/")))
300 eventPath.prepend(QStringLiteral("/dev/input/"));
301
302 if (action == QStringLiteral("add")) {
303-
304- QInputDevice *iDevice = addDevice(eventPath);
305- if (!iDevice)
306- return;
307-
308- iDevice->setTypes(getInputTypes(dev));
309+ if (deviceMap.contains(eventPath)){
310 udev_device_unref(dev);
311-
312- if (iDevice->switches().count() > 0 && iDevice->buttons().count() == 0)
313- iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Switch);
314-
315- if (iDevice->buttons().count() > 0 && iDevice->types() == QInputDeviceInfo::Unknown)
316- iDevice->setTypes(iDevice->types() | QInputDeviceInfo::Button);
317-
318- deviceList.append(iDevice);
319+ return;
320+ }
321+
322+ QInputDevice *iDevice = addDevice(dev);
323+ if (!iDevice) {
324+ delete iDevice;
325+ return;
326+ }
327+ iDevice->setType(getInputTypeFlags(dev));
328+ udev_device_unref(dev);
329+
330 deviceMap.insert(eventPath,iDevice);
331
332- Q_EMIT newDevice(eventPath);
333+ Q_EMIT deviceAdded(eventPath);
334
335 } else if (action == QStringLiteral("remove")) {
336 removeDevice(eventPath);
337
338=== modified file 'plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h'
339--- plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 2015-05-05 11:19:15 +0000
340+++ plugins/Unity/InputInfo/linux/qinputdeviceinfo_linux_p.h 2015-11-09 09:23:42 +0000
341@@ -58,30 +58,37 @@
342 QList <int> switches;
343 QList <int> relativeAxis;
344 QList <int> absoluteAxis;
345- QInputDeviceInfo::InputTypes types;
346+ QInputDevice::InputTypeFlags type;
347 };
348
349-class QInputDeviceInfoPrivate : public QObject
350+class QInputDeviceManagerPrivate : public QObject
351 {
352 Q_OBJECT
353 public:
354- explicit QInputDeviceInfoPrivate(QObject *parent = 0);
355+ explicit QInputDeviceManagerPrivate(QObject *parent = 0);
356+ ~QInputDeviceManagerPrivate();
357 QVector <QInputDevice *> deviceList;
358 QMap <QString, QInputDevice *> deviceMap;
359+ static QInputDeviceManagerPrivate * instance();
360+ QInputDevice::InputType currentFilter;
361
362 Q_SIGNALS:
363- void newDevice(const QString &);
364+ void deviceAdded(const QString &);
365 void deviceRemoved(const QString &);
366 void ready();
367
368 private:
369- struct udev *udev;
370+ QInputDevice *addDevice(struct udev_device *udev);
371+ QInputDevice *addUdevDevice(struct udev_device *);
372+
373 QInputDevice *addDevice(const QString &path);
374 void removeDevice(const QString &path);
375 QSocketNotifier *notifier;
376 int notifierFd;
377 struct udev_monitor *udevMonitor;
378- QInputDeviceInfo::InputTypes getInputTypes( struct udev_device *);
379+ QInputDevice::InputTypeFlags getInputTypeFlags(struct udev_device *);
380+ struct udev *udevice;
381+ void addDetails(struct udev_device *);
382
383 private Q_SLOTS:
384 void onUDevChanges();
385
386=== modified file 'plugins/Unity/InputInfo/plugin.cpp'
387--- plugins/Unity/InputInfo/plugin.cpp 2015-05-05 11:19:15 +0000
388+++ plugins/Unity/InputInfo/plugin.cpp 2015-11-09 09:23:42 +0000
389@@ -21,12 +21,12 @@
390 #include "plugin.h"
391
392 // local
393-#include "qdeclarativeinputdeviceinfo_p.h"
394+#include "qdeclarativeinputdevicemodel_p.h"
395
396 void InputInfoPlugin::registerTypes(const char *uri)
397 {
398 int major = 0;
399 int minor = 1;
400- qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo");
401+ qmlRegisterType<QDeclarativeInputDeviceModel>(uri, major, minor, "InputDeviceModel");
402 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
403 }
404
405=== removed file 'plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp'
406--- plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp 2015-08-19 13:56:21 +0000
407+++ plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo.cpp 1970-01-01 00:00:00 +0000
408@@ -1,143 +0,0 @@
409-/****************************************************************************
410-**
411-** Copyright (C) 2015 Jolla.
412-** Contact: http://www.qt-project.org/legal
413-**
414-** This file is part of the QtSystems module of the Qt Toolkit.
415-**
416-** $QT_BEGIN_LICENSE:LGPL$
417-** Commercial License Usage
418-** Licensees holding valid commercial Qt licenses may use this file in
419-** accordance with the commercial license agreement provided with the
420-** Software or, alternatively, in accordance with the terms contained in
421-** a written agreement between you and Digia. For licensing terms and
422-** conditions see http://qt.digia.com/licensing. For further information
423-** use the contact form at http://qt.digia.com/contact-us.
424-**
425-** GNU Lesser General Public License Usage
426-** Alternatively, this file may be used under the terms of the GNU Lesser
427-** General Public License version 2.1 as published by the Free Software
428-** Foundation and appearing in the file LICENSE.LGPL included in the
429-** packaging of this file. Please review the following information to
430-** ensure the GNU Lesser General Public License version 2.1 requirements
431-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
432-**
433-** In addition, as a special exception, Digia gives you certain additional
434-** rights. These rights are described in the Digia Qt LGPL Exception
435-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
436-**
437-** GNU General Public License Usage
438-** Alternatively, this file may be used under the terms of the GNU
439-** General Public License version 3.0 as published by the Free Software
440-** Foundation and appearing in the file LICENSE.GPL included in the
441-** packaging of this file. Please review the following information to
442-** ensure the GNU General Public License version 3.0 requirements will be
443-** met: http://www.gnu.org/copyleft/gpl.html.
444-**
445-**
446-** $QT_END_LICENSE$
447-**
448-****************************************************************************/
449-#include "qdeclarativeinputdeviceinfo_p.h"
450-
451-QDeclarativeInputDeviceInfo::QDeclarativeInputDeviceInfo(QObject *parent) :
452- QAbstractListModel(parent),
453- deviceInfo(new QInputDeviceInfo)
454-{
455- connect(deviceInfo, &QInputDeviceInfo::ready, this, &QDeclarativeInputDeviceInfo::updateDeviceList);
456- connect(deviceInfo, &QInputDeviceInfo::deviceAdded,this,&QDeclarativeInputDeviceInfo::addedDevice);
457- connect(deviceInfo, &QInputDeviceInfo::deviceRemoved,this,&QDeclarativeInputDeviceInfo::removedDevice);
458-}
459-
460-QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo()
461-{
462- delete deviceInfo;
463-}
464-
465-QVariant QDeclarativeInputDeviceInfo::data(const QModelIndex &index, int role) const
466-{
467- switch (role) {
468- case ServiceRole:
469- return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row())));
470- }
471-
472- return QVariant();
473-}
474-
475-int QDeclarativeInputDeviceInfo::rowCount(const QModelIndex &parent) const
476-{
477- Q_UNUSED(parent);
478-
479- return inputDevices.count();
480-}
481-
482-int QDeclarativeInputDeviceInfo::indexOf(const QString &devicePath) const
483-{
484- int idx(-1);
485- Q_FOREACH (QInputDevice *device, inputDevices) {
486- idx++;
487- if (device->devicePath() == devicePath) return idx;
488- }
489-
490- return -1;
491-}
492-
493-QInputDevice *QDeclarativeInputDeviceInfo::get(int index) const
494-{
495- if (index < 0 || index > inputDevices.count())
496- return 0;
497- return inputDevices.value(index);
498-}
499-
500-void QDeclarativeInputDeviceInfo::updateDeviceList()
501-{
502- QVector <QInputDevice *> newDevices = deviceInfo->deviceList();
503-
504- int numNew = newDevices.count();
505-
506- for (int i = 0; i < numNew; i++) {
507- int j = inputDevices.indexOf(newDevices.value(i));
508- if (j == -1) {
509- // not found -> remove from list
510- beginInsertRows(QModelIndex(), i, i);
511- inputDevices.insert(i, newDevices.value(i));
512- endInsertRows();
513- } else if (i != j) {
514- // changed its position -> move it
515- QInputDevice* device = inputDevices.value(j);
516- beginMoveRows(QModelIndex(), j, j, QModelIndex(), i);
517- inputDevices.remove(j);
518- inputDevices.insert(i, device);
519- endMoveRows();
520- } else {
521- QModelIndex changedIndex(this->index(j, 0, QModelIndex()));
522- Q_EMIT dataChanged(changedIndex, changedIndex);
523- }
524- }
525-
526- int numOld = inputDevices.count();
527- if (numOld > numNew) {
528- beginRemoveRows(QModelIndex(), numNew, numOld - 1);
529- inputDevices.remove(numNew, numOld - numNew);
530- endRemoveRows();
531- }
532-}
533-
534-void QDeclarativeInputDeviceInfo::addedDevice(const QString &devicePath)
535-{
536- updateDeviceList();
537- Q_EMIT newDevice(devicePath);
538-}
539-
540-void QDeclarativeInputDeviceInfo::removedDevice(const QString &devicePath)
541-{
542- updateDeviceList();
543- Q_EMIT deviceRemoved(devicePath);
544-}
545-
546-QHash<int, QByteArray> QDeclarativeInputDeviceInfo::roleNames() const
547-{
548- QHash<int, QByteArray> roles;
549- roles.insert(ServiceRole, "service");
550- return roles;
551-}
552
553=== removed file 'plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h'
554--- plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h 2015-05-05 11:19:15 +0000
555+++ plugins/Unity/InputInfo/qdeclarativeinputdeviceinfo_p.h 1970-01-01 00:00:00 +0000
556@@ -1,86 +0,0 @@
557-/****************************************************************************
558-**
559-** Copyright (C) 2015 Jolla.
560-** Contact: http://www.qt-project.org/legal
561-**
562-** This file is part of the QtSystems module of the Qt Toolkit.
563-**
564-** $QT_BEGIN_LICENSE:LGPL$
565-** Commercial License Usage
566-** Licensees holding valid commercial Qt licenses may use this file in
567-** accordance with the commercial license agreement provided with the
568-** Software or, alternatively, in accordance with the terms contained in
569-** a written agreement between you and Digia. For licensing terms and
570-** conditions see http://qt.digia.com/licensing. For further information
571-** use the contact form at http://qt.digia.com/contact-us.
572-**
573-** GNU Lesser General Public License Usage
574-** Alternatively, this file may be used under the terms of the GNU Lesser
575-** General Public License version 2.1 as published by the Free Software
576-** Foundation and appearing in the file LICENSE.LGPL included in the
577-** packaging of this file. Please review the following information to
578-** ensure the GNU Lesser General Public License version 2.1 requirements
579-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
580-**
581-** In addition, as a special exception, Digia gives you certain additional
582-** rights. These rights are described in the Digia Qt LGPL Exception
583-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
584-**
585-** GNU General Public License Usage
586-** Alternatively, this file may be used under the terms of the GNU
587-** General Public License version 3.0 as published by the Free Software
588-** Foundation and appearing in the file LICENSE.GPL included in the
589-** packaging of this file. Please review the following information to
590-** ensure the GNU General Public License version 3.0 requirements will be
591-** met: http://www.gnu.org/copyleft/gpl.html.
592-**
593-**
594-** $QT_END_LICENSE$
595-**
596-****************************************************************************/
597-
598-#ifndef QDECLARATIVEINPUTDEVICEINFO_H
599-#define QDECLARATIVEINPUTDEVICEINFO_H
600-
601-#include <QObject>
602-#include <QAbstractListModel>
603-#include "qinputinfo.h"
604-
605-class QDeclarativeInputDeviceInfo : public QAbstractListModel
606-{
607- Q_OBJECT
608- Q_DISABLE_COPY(QDeclarativeInputDeviceInfo)
609-
610-public:
611- enum ItemRoles {
612- ServiceRole = Qt::UserRole + 1
613- };
614-
615- explicit QDeclarativeInputDeviceInfo(QObject *parent = 0);
616- virtual ~QDeclarativeInputDeviceInfo();
617-
618- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
619- int rowCount(const QModelIndex &parent = QModelIndex()) const;
620-
621- QHash<int, QByteArray> roleNames() const;
622-
623- Q_INVOKABLE int indexOf(const QString &devicePath) const;
624-
625- Q_INVOKABLE QInputDevice *get(int index) const;
626-
627-Q_SIGNALS:
628- void newDevice(const QString &devicePath);
629- void deviceRemoved(const QString &devicePath);
630-
631-public Q_SLOTS:
632- void updateDeviceList();
633-private:
634- QInputDeviceInfo *deviceInfo;
635- QVector<QInputDevice *> inputDevices;
636-private Q_SLOTS:
637- void addedDevice(const QString &);
638- void removedDevice(const QString &path);
639-
640-};
641-
642-#endif // QDECLARATIVEINPUTDEVICEINFO_H
643
644=== added file 'plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp'
645--- plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp 1970-01-01 00:00:00 +0000
646+++ plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp 2015-11-09 09:23:42 +0000
647@@ -0,0 +1,196 @@
648+/****************************************************************************
649+**
650+** Copyright (C) 2015 Jolla.
651+** Contact: http://www.qt-project.org/legal
652+**
653+** This file is part of the QtSystems module of the Qt Toolkit.
654+**
655+** $QT_BEGIN_LICENSE:LGPL$
656+** Commercial License Usage
657+** Licensees holding valid commercial Qt licenses may use this file in
658+** accordance with the commercial license agreement provided with the
659+** Software or, alternatively, in accordance with the terms contained in
660+** a written agreement between you and Digia. For licensing terms and
661+** conditions see http://qt.digia.com/licensing. For further information
662+** use the contact form at http://qt.digia.com/contact-us.
663+**
664+** GNU Lesser General Public License Usage
665+** Alternatively, this file may be used under the terms of the GNU Lesser
666+** General Public License version 2.1 as published by the Free Software
667+** Foundation and appearing in the file LICENSE.LGPL included in the
668+** packaging of this file. Please review the following information to
669+** ensure the GNU Lesser General Public License version 2.1 requirements
670+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
671+**
672+** In addition, as a special exception, Digia gives you certain additional
673+** rights. These rights are described in the Digia Qt LGPL Exception
674+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
675+**
676+** GNU General Public License Usage
677+** Alternatively, this file may be used under the terms of the GNU
678+** General Public License version 3.0 as published by the Free Software
679+** Foundation and appearing in the file LICENSE.GPL included in the
680+** packaging of this file. Please review the following information to
681+** ensure the GNU General Public License version 3.0 requirements will be
682+** met: http://www.gnu.org/copyleft/gpl.html.
683+**
684+**
685+** $QT_END_LICENSE$
686+**
687+****************************************************************************/
688+#include "qdeclarativeinputdevicemodel_p.h"
689+#include "qinputinfo.h"
690+
691+QDeclarativeInputDeviceModel::QDeclarativeInputDeviceModel(QObject *parent) :
692+ QAbstractListModel(parent),
693+ deviceInfo(new QInputDeviceManager),
694+ currentFilter(QInputDevice::Unknown)
695+{
696+ connect(deviceInfo,SIGNAL(ready()),this,SLOT(updateDeviceList()));
697+ connect(deviceInfo, &QInputDeviceManager::deviceAdded,this,&QDeclarativeInputDeviceModel::addedDevice);
698+ connect(deviceInfo, &QInputDeviceManager::deviceRemoved,this,&QDeclarativeInputDeviceModel::removedDevice);
699+}
700+
701+QDeclarativeInputDeviceModel::~QDeclarativeInputDeviceModel()
702+{
703+ delete deviceInfo;
704+}
705+
706+QVariant QDeclarativeInputDeviceModel::data(const QModelIndex &index, int role) const
707+{
708+ switch (role) {
709+ case ServiceRole:
710+ return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row())));
711+ break;
712+ case NameRole:
713+ return QVariant::fromValue(static_cast<QString>(inputDevices.value(index.row())->name()));
714+ break;
715+ case DevicePathRole:
716+ return QVariant::fromValue(static_cast<QString>(inputDevices.value(index.row())->devicePath()));
717+ break;
718+ case ButtonsRole:
719+ return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->buttons()));
720+ break;
721+ case SwitchesRole:
722+ return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->switches()));
723+ break;
724+ case RelativeAxisRole:
725+ return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->relativeAxis()));
726+ break;
727+ case AbsoluteAxisRole:
728+ return QVariant::fromValue(static_cast<QList <int> >(inputDevices.value(index.row())->absoluteAxis()));
729+ break;
730+ case TypesRole:
731+ return QVariant::fromValue(static_cast<int>(inputDevices.value(index.row())->type()));
732+ break;
733+ };
734+
735+ return QVariant();
736+}
737+
738+int QDeclarativeInputDeviceModel::rowCount(const QModelIndex &parent) const
739+{
740+ Q_UNUSED(parent);
741+
742+ return inputDevices.count();
743+}
744+
745+int QDeclarativeInputDeviceModel::indexOf(const QString &devicePath) const
746+{
747+ int idx(-1);
748+ Q_FOREACH (QInputDevice *device, inputDevices) {
749+ idx++;
750+ if (device->devicePath() == devicePath) return idx;
751+ }
752+
753+ return -1;
754+}
755+
756+QInputDevice *QDeclarativeInputDeviceModel::get(int index) const
757+{
758+ if (index < 0 || index > inputDevices.count())
759+ return 0;
760+ return inputDevices.value(index);
761+}
762+
763+void QDeclarativeInputDeviceModel::updateDeviceList()
764+{
765+ QVector <QInputDevice *> newDevices = deviceInfo->deviceListOfType(currentFilter);
766+
767+ int numNew = newDevices.count();
768+
769+ for (int i = 0; i < numNew; i++) {
770+ int j = inputDevices.indexOf(newDevices.value(i));
771+
772+ if (j == -1) {
773+ beginInsertRows(QModelIndex(), i, i);
774+ inputDevices.insert(i, newDevices.value(i));
775+ endInsertRows();
776+ Q_EMIT countChanged();
777+ } else if (i != j) {
778+ // changed its position -> move it
779+ QInputDevice* device = inputDevices.value(j);
780+ beginMoveRows(QModelIndex(), j, j, QModelIndex(), i);
781+ inputDevices.remove(j);
782+ inputDevices.insert(i, device);
783+ endMoveRows();
784+ Q_EMIT countChanged();
785+ } //else {
786+ QModelIndex changedIndex(this->index(j, 0, QModelIndex()));
787+ Q_EMIT dataChanged(changedIndex, changedIndex);
788+ }
789+
790+ int numOld = inputDevices.count();
791+ if (numOld > numNew) {
792+ beginRemoveRows(QModelIndex(), numNew, numOld - 1);
793+ inputDevices.remove(numNew, numOld - numNew);
794+ endRemoveRows();
795+ Q_EMIT countChanged();
796+ }
797+}
798+
799+void QDeclarativeInputDeviceModel::addedDevice(const QString &devicePath)
800+{
801+ updateDeviceList();
802+ Q_EMIT deviceAdded(devicePath);
803+}
804+
805+void QDeclarativeInputDeviceModel::removedDevice(const QString &devicePath)
806+{
807+ updateDeviceList();
808+ Q_EMIT deviceRemoved(devicePath);
809+}
810+
811+QHash<int,QByteArray> QDeclarativeInputDeviceModel::roleNames() const
812+{
813+ QHash<int, QByteArray> roles;
814+ roles[NameRole] = "name";
815+ roles[DevicePathRole] = "devicePath";
816+ roles[ButtonsRole] = "buttons";
817+ roles[SwitchesRole] = "switches";
818+ roles[RelativeAxisRole] = "rAxis";
819+ roles[AbsoluteAxisRole] = "aAxis";
820+ roles[TypesRole] = "types";
821+ return roles;
822+}
823+
824+/*
825+ * Returns the currently set device filter.
826+ * */
827+QInputDevice::InputType QDeclarativeInputDeviceModel::deviceFilter()
828+{
829+ return currentFilter;
830+}
831+
832+/*
833+ * Sets the current input device filter to filter.
834+ * */
835+void QDeclarativeInputDeviceModel::setDeviceFilter(QInputDevice::InputType filter)
836+{
837+ if (filter != currentFilter) {
838+ deviceInfo->setDeviceFilter(filter);
839+ currentFilter = filter;
840+ updateDeviceList();
841+ Q_EMIT deviceFilterChanged(filter);
842+ }
843+}
844
845=== added file 'plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h'
846--- plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h 1970-01-01 00:00:00 +0000
847+++ plugins/Unity/InputInfo/qdeclarativeinputdevicemodel_p.h 2015-11-09 09:23:42 +0000
848@@ -0,0 +1,102 @@
849+/****************************************************************************
850+**
851+** Copyright (C) 2015 Jolla.
852+** Contact: http://www.qt-project.org/legal
853+**
854+** This file is part of the QtSystems module of the Qt Toolkit.
855+**
856+** $QT_BEGIN_LICENSE:LGPL$
857+** Commercial License Usage
858+** Licensees holding valid commercial Qt licenses may use this file in
859+** accordance with the commercial license agreement provided with the
860+** Software or, alternatively, in accordance with the terms contained in
861+** a written agreement between you and Digia. For licensing terms and
862+** conditions see http://qt.digia.com/licensing. For further information
863+** use the contact form at http://qt.digia.com/contact-us.
864+**
865+** GNU Lesser General Public License Usage
866+** Alternatively, this file may be used under the terms of the GNU Lesser
867+** General Public License version 2.1 as published by the Free Software
868+** Foundation and appearing in the file LICENSE.LGPL included in the
869+** packaging of this file. Please review the following information to
870+** ensure the GNU Lesser General Public License version 2.1 requirements
871+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
872+**
873+** In addition, as a special exception, Digia gives you certain additional
874+** rights. These rights are described in the Digia Qt LGPL Exception
875+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
876+**
877+** GNU General Public License Usage
878+** Alternatively, this file may be used under the terms of the GNU
879+** General Public License version 3.0 as published by the Free Software
880+** Foundation and appearing in the file LICENSE.GPL included in the
881+** packaging of this file. Please review the following information to
882+** ensure the GNU General Public License version 3.0 requirements will be
883+** met: http://www.gnu.org/copyleft/gpl.html.
884+**
885+**
886+** $QT_END_LICENSE$
887+**
888+****************************************************************************/
889+
890+#ifndef QDECLARATIVEINPUTDEVICEMODEL_H
891+#define QDECLARATIVEINPUTDEVICEMODEL_H
892+
893+#include <QObject>
894+#include <QAbstractListModel>
895+#include "qinputinfo.h"
896+
897+class QDeclarativeInputDeviceModel : public QAbstractListModel
898+{
899+ Q_OBJECT
900+ Q_DISABLE_COPY(QDeclarativeInputDeviceModel)
901+ Q_PROPERTY(QInputDevice::InputType deviceFilter READ deviceFilter WRITE setDeviceFilter NOTIFY deviceFilterChanged)
902+
903+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
904+
905+public:
906+ enum ItemRoles {
907+ ServiceRole = Qt::UserRole + 1,
908+ NameRole,
909+ DevicePathRole,
910+ ButtonsRole,
911+ SwitchesRole,
912+ RelativeAxisRole,
913+ AbsoluteAxisRole,
914+ TypesRole
915+ };
916+
917+ explicit QDeclarativeInputDeviceModel(QObject *parent = 0);
918+ virtual ~QDeclarativeInputDeviceModel();
919+
920+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
921+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
922+
923+ void setDeviceFilter(QInputDevice::InputType filter);
924+ QInputDevice::InputType deviceFilter();
925+
926+ Q_INVOKABLE int indexOf(const QString &devicePath) const;
927+
928+ Q_INVOKABLE QInputDevice *get(int index) const;
929+ QHash<int, QByteArray> roleNames() const;
930+
931+Q_SIGNALS:
932+ void deviceAdded(const QString &devicePath);
933+ void deviceRemoved(const QString &devicePath);
934+ void deviceFilterChanged(const QInputDevice::InputType filter);
935+ void countChanged();
936+
937+public Q_SLOTS:
938+ void updateDeviceList();
939+private:
940+ QInputDeviceManager *deviceInfo;
941+ QVector<QInputDevice *> inputDevices;
942+ QInputDevice::InputType currentFilter;
943+
944+private Q_SLOTS:
945+ void addedDevice(const QString &);
946+ void removedDevice(const QString &path);
947+
948+};
949+
950+#endif // QDECLARATIVEINPUTDEVICEMODEL_H
951
952=== modified file 'plugins/Unity/InputInfo/qinputinfo.cpp'
953--- plugins/Unity/InputInfo/qinputinfo.cpp 2015-08-19 13:56:21 +0000
954+++ plugins/Unity/InputInfo/qinputinfo.cpp 2015-11-09 09:23:42 +0000
955@@ -41,16 +41,25 @@
956
957 #include "qinputinfo.h"
958
959-#if defined(Q_OS_LINUX)
960+#if defined(UNITY_MOCKS)
961+#include "qinputdeviceinfo_mock_p.h"
962+#elif defined(Q_OS_LINUX)
963 #include "linux/qinputdeviceinfo_linux_p.h"
964 #endif
965
966+Q_GLOBAL_STATIC(QInputDeviceManagerPrivate, inputDeviceManagerPrivate)
967+
968 QT_BEGIN_NAMESPACE
969
970+QInputDeviceManagerPrivate * QInputDeviceManagerPrivate::instance()
971+{
972+ QInputDeviceManagerPrivate *priv = inputDeviceManagerPrivate();
973+ return priv;
974+}
975
976 QInputDevicePrivate::QInputDevicePrivate(QObject *parent) :
977 QObject(parent),
978- types(QInputDeviceInfo::Unknown)
979+ type(QInputDevice::Unknown)
980 {
981 }
982
983@@ -60,100 +69,202 @@
984 {
985 }
986
987+/*
988+ * Returns the name of this input device.
989+ */
990 QString QInputDevice::name() const
991 {
992 return d_ptr->name;
993 }
994
995+/*
996+ * Sets the name of this input device to \b name.
997+ */
998 void QInputDevice::setName(const QString &name)
999 {
1000 d_ptr->name = name;
1001 }
1002
1003+/*
1004+ * Returns the device path of this device.
1005+ */
1006 QString QInputDevice::devicePath() const
1007 {
1008 return d_ptr->devicePath;
1009 }
1010
1011+/*
1012+ * Sets the device ppath of this device to /b path.
1013+ */
1014 void QInputDevice::setDevicePath(const QString &path)
1015 {
1016 d_ptr->devicePath = path;
1017 }
1018
1019+/*
1020+ * Returns the number of buttons this device has.
1021+ */
1022 QList <int> QInputDevice::buttons() const
1023 {
1024 return d_ptr->buttons;
1025 }
1026
1027+/*
1028+ * Adds a button
1029+ */
1030 void QInputDevice::addButton(int buttonCode)
1031 {
1032 d_ptr->buttons.append(buttonCode);
1033 }
1034
1035+/*
1036+ * Returns the number of switch of this device.
1037+ */
1038 QList <int> QInputDevice::switches() const
1039 {
1040 return d_ptr->switches;
1041 }
1042
1043+/*
1044+ * Adds a switch
1045+ */
1046 void QInputDevice::addSwitch(int switchCode)
1047 {
1048 d_ptr->switches.append(switchCode);
1049 }
1050
1051+/*
1052+ * Returns a list of the relative axis of this device
1053+ */
1054 QList <int> QInputDevice::relativeAxis() const
1055 {
1056 return d_ptr->relativeAxis;
1057 }
1058
1059+/*
1060+ */
1061 void QInputDevice::addRelativeAxis(int axisCode)
1062 {
1063 d_ptr->relativeAxis.append(axisCode);
1064 }
1065
1066+/*
1067+ * Returns a list of the absolute axis of this device
1068+ */
1069 QList <int> QInputDevice::absoluteAxis() const
1070 {
1071 return d_ptr->absoluteAxis;
1072 }
1073
1074+/*
1075+ */
1076 void QInputDevice::addAbsoluteAxis(int axisCode)
1077 {
1078 d_ptr->absoluteAxis.append(axisCode);
1079 }
1080
1081-QInputDeviceInfo::InputTypes QInputDevice::types()
1082-{
1083- return d_ptr->types;
1084-}
1085-
1086-void QInputDevice::setTypes(QInputDeviceInfo::InputTypes types)
1087-{
1088- d_ptr->types = types;
1089-}
1090-
1091-
1092-QInputDeviceInfo::QInputDeviceInfo(QObject *parent) :
1093+/*
1094+ * Returns a QInputDevice::InputTypeFlags of all the types of types.
1095+ */
1096+QInputDevice::InputTypeFlags QInputDevice::type() const
1097+{
1098+ return d_ptr->type;
1099+}
1100+
1101+/*
1102+ */
1103+void QInputDevice::setType(QInputDevice::InputTypeFlags type) //? setTypes?
1104+{
1105+ d_ptr->type = type;
1106+}
1107+
1108+QInputDeviceManager::QInputDeviceManager(QObject *parent) :
1109 QObject(parent),
1110- d_ptr(new QInputDeviceInfoPrivate(this))
1111-{
1112- connect(d_ptr, &QInputDeviceInfoPrivate::newDevice,this,&QInputDeviceInfo::addedDevice);
1113- connect(d_ptr, &QInputDeviceInfoPrivate::deviceRemoved,this,&QInputDeviceInfo::deviceRemoved);
1114-
1115- connect(d_ptr, &QInputDeviceInfoPrivate::ready, this, &QInputDeviceInfo::ready);
1116-}
1117-
1118-QVector <QInputDevice *> QInputDeviceInfo::deviceList()
1119-{
1120- return d_ptr->deviceList;
1121-}
1122-
1123-QMap <QString, QInputDevice *> QInputDeviceInfo::deviceMap()
1124+ d_ptr(inputDeviceManagerPrivate)
1125+{
1126+ connect(d_ptr, &QInputDeviceManagerPrivate::deviceAdded,this,&QInputDeviceManager::addedDevice);
1127+ connect(d_ptr, &QInputDeviceManagerPrivate::deviceRemoved,this,&QInputDeviceManager::deviceRemoved);
1128+
1129+ connect(d_ptr,SIGNAL(ready()),this,SIGNAL(ready()));
1130+}
1131+
1132+/*
1133+ * Returns a QMap of known input devices.
1134+ */
1135+QMap <QString, QInputDevice *> QInputDeviceManager::deviceMap()
1136 {
1137 return d_ptr->deviceMap;
1138 }
1139
1140-void QInputDeviceInfo::addedDevice(const QString & devicePath)
1141+/*
1142+ */
1143+void QInputDeviceManager::addedDevice(const QString & devicePath)
1144 {
1145 Q_EMIT deviceAdded(devicePath);
1146 }
1147
1148+/*
1149+ * Returns a QVector of InputDevices of type filter
1150+ * */
1151+QVector <QInputDevice *> QInputDeviceManager::deviceListOfType(QInputDevice::InputType filter)
1152+{
1153+ QVector <QInputDevice *> dList;
1154+ QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
1155+ while (i.hasNext()) {
1156+ i.next();
1157+ if (i.value()->type().testFlag(filter) || filter == QInputDevice::Unknown) {
1158+ dList.append(i.value());
1159+ }
1160+ }
1161+ return dList;
1162+}
1163+
1164+/*
1165+ * Returns the number of input devices with the currently set QInputDevice::InputType filter.
1166+ * If no device filter has been set, returns number of all available input devices.
1167+ * If filter has not been set, returns all available input devices
1168+ */
1169+int QInputDeviceManager::deviceCount() const
1170+{
1171+ return deviceCount(static_cast< QInputDevice::InputType >(d_ptr->currentFilter));
1172+}
1173+
1174+/*
1175+ * Returns the number of input devices of the type filter.
1176+ */
1177+int QInputDeviceManager::deviceCount(const QInputDevice::InputType filter) const
1178+{
1179+ int dList = 0;
1180+ QMapIterator<QString, QInputDevice *> i(d_ptr->deviceMap);
1181+ while (i.hasNext()) {
1182+ i.next();
1183+// qDebug() << i.value()->name() << i.value()->devicePath();
1184+// qDebug() << i.value()->type() << i.value()->type().testFlag(filter);
1185+
1186+ if (i.value()->type().testFlag(filter)) {
1187+ dList++;
1188+ }
1189+ }
1190+ return dList;
1191+}
1192+
1193+/*
1194+ * Returns the currently set device filter.
1195+ * */
1196+QInputDevice::InputType QInputDeviceManager::deviceFilter()
1197+{
1198+ return d_ptr->currentFilter;
1199+}
1200+
1201+/*
1202+ * Sets the current input device filter to filter.
1203+ * */
1204+void QInputDeviceManager::setDeviceFilter(QInputDevice::InputType filter)
1205+{
1206+ if (filter != d_ptr->currentFilter) {
1207+ d_ptr->currentFilter = filter;
1208+ Q_EMIT deviceFilterChanged(filter);
1209+ }
1210+}
1211+
1212 QT_END_NAMESPACE
1213
1214=== modified file 'plugins/Unity/InputInfo/qinputinfo.h'
1215--- plugins/Unity/InputInfo/qinputinfo.h 2015-05-05 11:19:15 +0000
1216+++ plugins/Unity/InputInfo/qinputinfo.h 2015-11-09 09:23:42 +0000
1217@@ -48,15 +48,19 @@
1218 #include <QSocketNotifier>
1219 #include <QDebug>
1220
1221-class QInputDeviceInfoPrivate;
1222+class QInputDeviceManagerPrivate;
1223 class QInputDevicePrivate;
1224 class QInputDevice;
1225
1226-class QInputDeviceInfoPrivate;
1227-class QInputDeviceInfo : public QObject
1228+class QInputDeviceManager;
1229+
1230+class QInputDevice : public QObject
1231 {
1232 Q_OBJECT
1233- Q_PROPERTY(int deviceCount READ deviceCount)
1234+ Q_ENUMS(InputType)
1235+ Q_FLAGS(InputType InputTypeFlags)
1236+ friend class QInputDeviceManagerPrivate;
1237+
1238 public:
1239
1240 enum InputType {
1241@@ -69,67 +73,19 @@
1242 Switch = 32
1243 };
1244 Q_ENUMS(InputType)
1245- Q_FLAGS(InputTypes)
1246- Q_DECLARE_FLAGS(InputTypes, InputType)
1247-
1248- explicit QInputDeviceInfo(QObject *parent = 0);
1249-
1250- Q_INVOKABLE QVector <QInputDevice *> deviceList();
1251-
1252- Q_INVOKABLE QMap <QString, QInputDevice *> deviceMap();
1253- int deviceCount() { return deviceList().count(); }
1254-Q_SIGNALS:
1255-
1256- void deviceAdded(const QString & devicePath);
1257- void deviceRemoved(const QString & devicePath);
1258-
1259- void ready();
1260-
1261-public Q_SLOTS:
1262- void addedDevice(const QString & devicePath);
1263-
1264-private:
1265- Q_DISABLE_COPY(QInputDeviceInfo)
1266-#if !defined(QT_SIMULATOR)
1267- QInputDeviceInfoPrivate *const d_ptr;
1268- Q_DECLARE_PRIVATE(QInputDeviceInfo)
1269-#endif
1270-};
1271-
1272-class QInputDevice : public QObject
1273-{
1274- friend class QInputDeviceInfoPrivate;
1275- Q_OBJECT
1276- Q_ENUMS(InputType)
1277- Q_FLAGS(InputTypes)
1278- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
1279- Q_PROPERTY(QString devicePath READ devicePath NOTIFY devicePathChanged)
1280- Q_PROPERTY(QList <int> buttons READ buttons NOTIFY buttonsChanged)
1281- Q_PROPERTY(QList <int> switches READ switches NOTIFY switchesChanged)
1282- Q_PROPERTY(QList <int> relativeAxis READ relativeAxis NOTIFY relativeAxisChanged)
1283- Q_PROPERTY(QList <int> absoluteAxis READ absoluteAxis NOTIFY absoluteAxisChanged)
1284- Q_PROPERTY(QInputDeviceInfo::InputTypes types READ types NOTIFY typesChanged)
1285-
1286-public:
1287+ Q_DECLARE_FLAGS(InputTypeFlags, InputType)
1288+
1289 explicit QInputDevice(QObject *parent = 0);
1290-
1291 QString name() const;
1292 QString devicePath() const;
1293 QList <int> buttons() const; //keys event code
1294 QList <int> switches() const;
1295 QList <int> relativeAxis() const;
1296 QList <int> absoluteAxis() const;
1297+ QInputDevice::InputTypeFlags type() const;
1298
1299- QInputDeviceInfo::InputTypes types();
1300-Q_SIGNALS:
1301- void nameChanged();
1302- void devicePathChanged();
1303- void buttonsChanged();
1304- void switchesChanged();
1305- void relativeAxisChanged();
1306- void absoluteAxisChanged();
1307- void typesChanged();
1308 private:
1309+
1310 QInputDevicePrivate *d_ptr;
1311 void setName(const QString &);
1312 void setDevicePath(const QString &);
1313@@ -137,7 +93,51 @@
1314 void addSwitch(int);
1315 void addRelativeAxis(int);
1316 void addAbsoluteAxis(int);
1317- void setTypes(QInputDeviceInfo::InputTypes);
1318+ void setType(QInputDevice::InputTypeFlags flags);
1319+
1320+};
1321+
1322+Q_DECLARE_METATYPE(QInputDevice::InputType)
1323+Q_DECLARE_METATYPE(QInputDevice::InputTypeFlags)
1324+
1325+class QInputDeviceManagerPrivate;
1326+
1327+class QInputDeviceManager : public QObject
1328+{
1329+ Q_OBJECT
1330+ Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
1331+ Q_PROPERTY(QInputDevice::InputType deviceFilter READ deviceFilter WRITE setDeviceFilter NOTIFY deviceFilterChanged)
1332+public:
1333+
1334+ explicit QInputDeviceManager(QObject *parent = 0);
1335+
1336+ int deviceCount() const;
1337+ int deviceCount(const QInputDevice::InputType filter) const;
1338+
1339+ void setDeviceFilter(QInputDevice::InputType filter);
1340+ QInputDevice::InputType deviceFilter();
1341+
1342+ QMap <QString, QInputDevice *> deviceMap();
1343+ Q_INVOKABLE QVector <QInputDevice *> deviceListOfType(QInputDevice::InputType filter);
1344+
1345+Q_SIGNALS:
1346+
1347+ void deviceAdded(const QString & devicePath);
1348+ void deviceRemoved(const QString & devicePath);
1349+
1350+ void ready();
1351+ void deviceCountChanged(int count);
1352+ void deviceFilterChanged(const QInputDevice::InputType filter);
1353+
1354+public Q_SLOTS:
1355+ void addedDevice(const QString & devicePath);
1356+
1357+private:
1358+ Q_DISABLE_COPY(QInputDeviceManager)
1359+#if !defined(QT_SIMULATOR)
1360+ QInputDeviceManagerPrivate *const d_ptr;
1361+ Q_DECLARE_PRIVATE(QInputDeviceManager)
1362+#endif
1363 };
1364
1365 #endif // QINPUTINFO_H
1366
1367=== removed directory 'qml/Components/UnityInputInfo'
1368=== removed file 'qml/Components/UnityInputInfo/UnityInputInfo.qml'
1369--- qml/Components/UnityInputInfo/UnityInputInfo.qml 2015-08-13 09:08:15 +0000
1370+++ qml/Components/UnityInputInfo/UnityInputInfo.qml 1970-01-01 00:00:00 +0000
1371@@ -1,93 +0,0 @@
1372-/*
1373- * Copyright 2015 Canonical Ltd.
1374- *
1375- * This program is free software; you can redistribute it and/or modify
1376- * it under the terms of the GNU Lesser General Public License as published by
1377- * the Free Software Foundation; version 3.
1378- *
1379- * This program is distributed in the hope that it will be useful,
1380- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1381- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1382- * GNU Lesser General Public License for more details.
1383- *
1384- * You should have received a copy of the GNU Lesser General Public License
1385- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1386- */
1387-
1388-pragma Singleton
1389-
1390-import QtQuick 2.4
1391-import Unity.InputInfo 0.1
1392-// Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
1393-import Ubuntu.Components 1.3
1394-
1395-Item {
1396- id: root
1397- readonly property alias mice: priv.miceCount
1398- readonly property alias keyboards: priv.keyboardCount
1399-
1400- property alias inputInfo: inputInfo
1401-
1402- QtObject {
1403- id: priv
1404-
1405- property var mice: []
1406- property var keyboards: []
1407-
1408- property int miceCount: 0
1409- property int keyboardCount: 0
1410-
1411- function addMouse(devicePath) {
1412- mice.push(devicePath);
1413- miceCount++;
1414- }
1415-
1416- function addKeyboard(devicePath) {
1417- keyboards.push(devicePath);
1418- keyboardCount++;
1419- }
1420-
1421- function removeDevice(devicePath) {
1422- for (var i = 0; i < priv.mice.length; i++) {
1423- if (priv.mice[i] == devicePath) {
1424- priv.mice.splice(i, 1);
1425- priv.miceCount--;
1426- }
1427- }
1428- for (var i = 0; i < priv.keyboards.length; i++) {
1429- if (priv.keyboards[i] == devicePath) {
1430- priv.keyboards.splice(i, 1);
1431- priv.keyboardCount--;
1432- }
1433- }
1434- }
1435- }
1436-
1437- InputDeviceInfo {
1438- id: inputInfo
1439- objectName: "inputDeviceInfo"
1440-
1441- onNewDevice: {
1442- var device = inputInfo.get(inputInfo.indexOf(devicePath));
1443- if (device === null) {
1444- return;
1445- }
1446-
1447- var hasMouse = (device.types & InputInfo.Mouse) == InputInfo.Mouse
1448- var hasTouchpad = (device.types & InputInfo.TouchPad) == InputInfo.TouchPad
1449- var hasKeyboard = (device.types & InputInfo.Keyboard) == InputInfo.Keyboard
1450-
1451- if (hasMouse || hasTouchpad) {
1452- priv.addMouse(devicePath);
1453- } else if (hasKeyboard) {
1454- // Only accepting keyboards that do not claim to be a mouse too
1455- // This will be a bit buggy for real hybrid devices, but doesn't
1456- // fall for Microsoft mice that claim to be Keyboards too.
1457- priv.addKeyboard(devicePath)
1458- }
1459- }
1460- onDeviceRemoved: {
1461- priv.removeDevice(devicePath)
1462- }
1463- }
1464-}
1465
1466=== removed file 'qml/Components/UnityInputInfo/qmldir'
1467--- qml/Components/UnityInputInfo/qmldir 2015-06-23 16:36:51 +0000
1468+++ qml/Components/UnityInputInfo/qmldir 1970-01-01 00:00:00 +0000
1469@@ -1,1 +0,0 @@
1470-singleton UnityInputInfo 1.0 UnityInputInfo.qml
1471
1472=== modified file 'qml/OrientedShell.qml'
1473--- qml/OrientedShell.qml 2015-11-04 14:57:45 +0000
1474+++ qml/OrientedShell.qml 2015-11-09 09:23:42 +0000
1475@@ -16,13 +16,12 @@
1476
1477 import QtQuick 2.4
1478 import QtQuick.Window 2.2
1479+import Unity.InputInfo 0.1
1480 import Unity.Session 0.1
1481 import GSettings 1.0
1482 import "Components"
1483-import "Components/UnityInputInfo"
1484 import "Rotation"
1485-// Backup Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
1486-// in case we remove the UnityInputInfo import
1487+// Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
1488 import Ubuntu.Components 1.3
1489
1490 Rectangle {
1491@@ -64,6 +63,16 @@
1492 property bool orientationLocked: OrientationLock.enabled
1493 property var orientationLock: OrientationLock
1494
1495+ InputDeviceModel {
1496+ id: miceModel
1497+ deviceFilter: InputInfo.Mouse
1498+ }
1499+
1500+ InputDeviceModel {
1501+ id: keyboardsModel
1502+ deviceFilter: InputInfo.Keyboard
1503+ }
1504+
1505 property int orientation
1506 onPhysicalOrientationChanged: {
1507 if (!orientationLocked) {
1508@@ -83,7 +92,7 @@
1509 }
1510 // We need to manually update this on startup as the binding
1511 // below doesn't seem to have any effect at that stage
1512- oskSettings.stayHidden = UnityInputInfo.keyboards > 0
1513+ oskSettings.stayHidden = keyboardsModel.count > 0
1514 oskSettings.disableHeight = shell.usageScenario == "desktop"
1515 }
1516
1517@@ -96,7 +105,7 @@
1518 Binding {
1519 target: oskSettings
1520 property: "stayHidden"
1521- value: UnityInputInfo.keyboards > 0
1522+ value: keyboardsModel.count > 0
1523 }
1524
1525 Binding {
1526@@ -174,7 +183,7 @@
1527 nativeWidth: root.width
1528 nativeHeight: root.height
1529 mode: applicationArguments.mode
1530- hasMouse: UnityInputInfo.mice > deviceConfiguration.ignoredMice
1531+ hasMouse: miceModel.count > deviceConfiguration.ignoredMice
1532
1533 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
1534 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
1535@@ -188,7 +197,7 @@
1536 return "tablet";
1537 }
1538 } else { // automatic
1539- if (UnityInputInfo.mice > deviceConfiguration.ignoredMice) {
1540+ if (miceModel.count > deviceConfiguration.ignoredMice) {
1541 return "desktop";
1542 } else {
1543 return deviceConfiguration.category;
1544
1545=== modified file 'tests/mocks/Unity/InputInfo/CMakeLists.txt'
1546--- tests/mocks/Unity/InputInfo/CMakeLists.txt 2015-06-30 11:51:25 +0000
1547+++ tests/mocks/Unity/InputInfo/CMakeLists.txt 2015-11-09 09:23:42 +0000
1548@@ -9,12 +9,17 @@
1549 include_directories(
1550 ${CMAKE_CURRENT_SOURCE_DIR}
1551 ${CMAKE_CURRENT_BINARY_DIR}
1552+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/
1553 )
1554
1555+add_definitions(-DUNITY_MOCKS)
1556+
1557 set(MockInputInfo_SOURCES
1558 plugin.cpp
1559- mockqinputinfo.cpp
1560- mockqdeclarativeinputdeviceinfo.cpp
1561+ qinputdeviceinfo_mock.cpp
1562+ mockcontroller.cpp
1563+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/qinputinfo.cpp
1564+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp
1565 )
1566
1567 add_library(MockInputInfo SHARED
1568
1569=== added file 'tests/mocks/Unity/InputInfo/mockcontroller.cpp'
1570--- tests/mocks/Unity/InputInfo/mockcontroller.cpp 1970-01-01 00:00:00 +0000
1571+++ tests/mocks/Unity/InputInfo/mockcontroller.cpp 2015-11-09 09:23:42 +0000
1572@@ -0,0 +1,35 @@
1573+/*
1574+ * Copyright 2015 Canonical Ltd.
1575+ *
1576+ * This program is free software; you can redistribute it and/or modify
1577+ * it under the terms of the GNU Lesser General Public License as published by
1578+ * the Free Software Foundation; version 3.
1579+ *
1580+ * This program is distributed in the hope that it will be useful,
1581+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1582+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1583+ * GNU Lesser General Public License for more details.
1584+ *
1585+ * You should have received a copy of the GNU Lesser General Public License
1586+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1587+ */
1588+
1589+#include "mockcontroller.h"
1590+
1591+#include "qinputdeviceinfo_mock_p.h"
1592+
1593+MockController::MockController(QObject *parent):
1594+ QObject(parent)
1595+{
1596+
1597+}
1598+
1599+QInputDevice *MockController::addMockDevice(const QString &devicePath, QInputDevice::InputType type)
1600+{
1601+ return QInputDeviceManagerPrivate::instance()->addMockDevice(devicePath, type);
1602+}
1603+
1604+void MockController::removeDevice(const QString &devicePath)
1605+{
1606+ QInputDeviceManagerPrivate::instance()->removeDevice(devicePath);
1607+}
1608
1609=== added file 'tests/mocks/Unity/InputInfo/mockcontroller.h'
1610--- tests/mocks/Unity/InputInfo/mockcontroller.h 1970-01-01 00:00:00 +0000
1611+++ tests/mocks/Unity/InputInfo/mockcontroller.h 2015-11-09 09:23:42 +0000
1612@@ -0,0 +1,34 @@
1613+/*
1614+ * Copyright 2015 Canonical Ltd.
1615+ *
1616+ * This program is free software; you can redistribute it and/or modify
1617+ * it under the terms of the GNU Lesser General Public License as published by
1618+ * the Free Software Foundation; version 3.
1619+ *
1620+ * This program is distributed in the hope that it will be useful,
1621+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1622+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1623+ * GNU Lesser General Public License for more details.
1624+ *
1625+ * You should have received a copy of the GNU Lesser General Public License
1626+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1627+ */
1628+
1629+#ifndef MOCKCONTROLLER_H
1630+#define MOCKCONTROLLER_H
1631+
1632+#include <QObject>
1633+#include "qinputinfo.h"
1634+
1635+class MockController: public QObject
1636+{
1637+ Q_OBJECT
1638+public:
1639+ MockController(QObject *parent = 0);
1640+ ~MockController() = default;
1641+
1642+ Q_INVOKABLE QInputDevice* addMockDevice(const QString &devicePath, QInputDevice::InputType type);
1643+ Q_INVOKABLE void removeDevice(const QString &devicePath);
1644+};
1645+
1646+#endif
1647
1648=== removed file 'tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp'
1649--- tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp 2015-06-23 17:40:03 +0000
1650+++ tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp 1970-01-01 00:00:00 +0000
1651@@ -1,173 +0,0 @@
1652-/****************************************************************************
1653-**
1654-** Copyright (C) 2015 Jolla.
1655-** Copyright (C) 2015 Canonical Ltd.
1656-** Contact: http://www.qt-project.org/legal
1657-**
1658-** This file is part of the QtSystems module of the Qt Toolkit.
1659-**
1660-** $QT_BEGIN_LICENSE:LGPL$
1661-** Commercial License Usage
1662-** Licensees holding valid commercial Qt licenses may use this file in
1663-** accordance with the commercial license agreement provided with the
1664-** Software or, alternatively, in accordance with the terms contained in
1665-** a written agreement between you and Digia. For licensing terms and
1666-** conditions see http://qt.digia.com/licensing. For further information
1667-** use the contact form at http://qt.digia.com/contact-us.
1668-**
1669-** GNU Lesser General Public License Usage
1670-** Alternatively, this file may be used under the terms of the GNU Lesser
1671-** General Public License version 2.1 as published by the Free Software
1672-** Foundation and appearing in the file LICENSE.LGPL included in the
1673-** packaging of this file. Please review the following information to
1674-** ensure the GNU Lesser General Public License version 2.1 requirements
1675-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
1676-**
1677-** In addition, as a special exception, Digia gives you certain additional
1678-** rights. These rights are described in the Digia Qt LGPL Exception
1679-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
1680-**
1681-** GNU General Public License Usage
1682-** Alternatively, this file may be used under the terms of the GNU
1683-** General Public License version 3.0 as published by the Free Software
1684-** Foundation and appearing in the file LICENSE.GPL included in the
1685-** packaging of this file. Please review the following information to
1686-** ensure the GNU General Public License version 3.0 requirements will be
1687-** met: http://www.gnu.org/copyleft/gpl.html.
1688-**
1689-**
1690-** $QT_END_LICENSE$
1691-**
1692-****************************************************************************/
1693-#include "mockqdeclarativeinputdeviceinfo_p.h"
1694-
1695-QDeclarativeInputDeviceInfo::QDeclarativeInputDeviceInfo(QObject *parent) :
1696- QAbstractListModel(parent),
1697- deviceInfo(new QInputDeviceInfo)
1698-{
1699- connect(deviceInfo, &QInputDeviceInfo::deviceAdded,this,&QDeclarativeInputDeviceInfo::addedDevice);
1700- connect(deviceInfo, &QInputDeviceInfo::deviceRemoved,this,&QDeclarativeInputDeviceInfo::removedDevice);
1701-}
1702-
1703-QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo()
1704-{
1705- delete deviceInfo;
1706-}
1707-
1708-QVariant QDeclarativeInputDeviceInfo::data(const QModelIndex &index, int role) const
1709-{
1710- switch (role) {
1711- case ServiceRole:
1712- return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row())));
1713- }
1714-
1715- return QVariant();
1716-}
1717-
1718-int QDeclarativeInputDeviceInfo::rowCount(const QModelIndex &parent) const
1719-{
1720- Q_UNUSED(parent);
1721-
1722- return inputDevices.count();
1723-}
1724-
1725-int QDeclarativeInputDeviceInfo::indexOf(const QString &devicePath) const
1726-{
1727- int idx(-1);
1728- Q_FOREACH (QInputDevice *device, inputDevices) {
1729- idx++;
1730- if (device->devicePath() == devicePath) return idx;
1731- }
1732-
1733- return -1;
1734-}
1735-
1736-QInputDevice *QDeclarativeInputDeviceInfo::get(int index) const
1737-{
1738- if (index < 0 || index > inputDevices.count())
1739- return 0;
1740- return inputDevices.value(index);
1741-}
1742-
1743-void QDeclarativeInputDeviceInfo::addMockMouse()
1744-{
1745- deviceInfo->addMockDevice(QInputDeviceInfo::Mouse);
1746-}
1747-
1748-void QDeclarativeInputDeviceInfo::addMockKeyboard()
1749-{
1750- deviceInfo->addMockDevice(QInputDeviceInfo::Keyboard);
1751-}
1752-
1753-void QDeclarativeInputDeviceInfo::removeMockMouse()
1754-{
1755- for (int i = 0; i < inputDevices.count(); i++) {
1756- if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Mouse)) {
1757- deviceInfo->removeMockDevice(i);
1758- return;
1759- }
1760- }
1761-}
1762-
1763-void QDeclarativeInputDeviceInfo::removeMockKeyboard()
1764-{
1765- for (int i = 0; i < inputDevices.count(); i++) {
1766- if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Keyboard)) {
1767- deviceInfo->removeMockDevice(i);
1768- return;
1769- }
1770- }
1771-}
1772-
1773-void QDeclarativeInputDeviceInfo::updateDeviceList()
1774-{
1775- QVector <QInputDevice *> newDevices = deviceInfo->deviceList();
1776-
1777- int numNew = newDevices.count();
1778-
1779- for (int i = 0; i < numNew; i++) {
1780- int j = inputDevices.indexOf(newDevices.value(i));
1781- if (j == -1) {
1782- // not found -> remove from list
1783- beginInsertRows(QModelIndex(), i, i);
1784- inputDevices.insert(i, newDevices.value(i));
1785- endInsertRows();
1786- } else if (i != j) {
1787- // changed its position -> move it
1788- QInputDevice* device = inputDevices.value(j);
1789- beginMoveRows(QModelIndex(), j, j, QModelIndex(), i);
1790- inputDevices.remove(j);
1791- inputDevices.insert(i, device);
1792- endMoveRows();
1793- } else {
1794- QModelIndex changedIndex(this->index(j, 0, QModelIndex()));
1795- Q_EMIT dataChanged(changedIndex, changedIndex);
1796- }
1797- }
1798-
1799- int numOld = inputDevices.count();
1800- if (numOld > numNew) {
1801- beginRemoveRows(QModelIndex(), numNew, numOld - 1);
1802- inputDevices.remove(numNew, numOld - numNew);
1803- endRemoveRows();
1804- }
1805-}
1806-
1807-void QDeclarativeInputDeviceInfo::addedDevice(const QString &devicePath)
1808-{
1809- updateDeviceList();
1810- Q_EMIT newDevice(devicePath);
1811-}
1812-
1813-void QDeclarativeInputDeviceInfo::removedDevice(const QString &devicePath)
1814-{
1815- updateDeviceList();
1816- Q_EMIT deviceRemoved(devicePath);
1817-}
1818-
1819-QHash<int, QByteArray> QDeclarativeInputDeviceInfo::roleNames() const
1820-{
1821- QHash<int, QByteArray> roles;
1822- roles.insert(ServiceRole, "service");
1823- return roles;
1824-}
1825
1826=== removed file 'tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h'
1827--- tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h 2015-06-23 17:40:03 +0000
1828+++ tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h 1970-01-01 00:00:00 +0000
1829@@ -1,94 +0,0 @@
1830-/****************************************************************************
1831-**
1832-** Copyright (C) 2015 Jolla.
1833-** Copyright (C) 2015 Canoncal Ltd.
1834-** Contact: http://www.qt-project.org/legal
1835-**
1836-** This file is part of the QtSystems module of the Qt Toolkit.
1837-**
1838-** $QT_BEGIN_LICENSE:LGPL$
1839-** Commercial License Usage
1840-** Licensees holding valid commercial Qt licenses may use this file in
1841-** accordance with the commercial license agreement provided with the
1842-** Software or, alternatively, in accordance with the terms contained in
1843-** a written agreement between you and Digia. For licensing terms and
1844-** conditions see http://qt.digia.com/licensing. For further information
1845-** use the contact form at http://qt.digia.com/contact-us.
1846-**
1847-** GNU Lesser General Public License Usage
1848-** Alternatively, this file may be used under the terms of the GNU Lesser
1849-** General Public License version 2.1 as published by the Free Software
1850-** Foundation and appearing in the file LICENSE.LGPL included in the
1851-** packaging of this file. Please review the following information to
1852-** ensure the GNU Lesser General Public License version 2.1 requirements
1853-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
1854-**
1855-** In addition, as a special exception, Digia gives you certain additional
1856-** rights. These rights are described in the Digia Qt LGPL Exception
1857-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
1858-**
1859-** GNU General Public License Usage
1860-** Alternatively, this file may be used under the terms of the GNU
1861-** General Public License version 3.0 as published by the Free Software
1862-** Foundation and appearing in the file LICENSE.GPL included in the
1863-** packaging of this file. Please review the following information to
1864-** ensure the GNU General Public License version 3.0 requirements will be
1865-** met: http://www.gnu.org/copyleft/gpl.html.
1866-**
1867-**
1868-** $QT_END_LICENSE$
1869-**
1870-****************************************************************************/
1871-
1872-#ifndef QDECLARATIVEINPUTDEVICEINFO_H
1873-#define QDECLARATIVEINPUTDEVICEINFO_H
1874-
1875-#include <QObject>
1876-#include <QAbstractListModel>
1877-#include "mockqinputinfo.h"
1878-
1879-class QDeclarativeInputDeviceInfo : public QAbstractListModel
1880-{
1881- Q_OBJECT
1882- Q_DISABLE_COPY(QDeclarativeInputDeviceInfo)
1883-
1884-public:
1885- enum ItemRoles {
1886- ServiceRole = Qt::UserRole + 1
1887- };
1888-
1889- explicit QDeclarativeInputDeviceInfo(QObject *parent = 0);
1890- virtual ~QDeclarativeInputDeviceInfo();
1891-
1892- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
1893- int rowCount(const QModelIndex &parent = QModelIndex()) const;
1894-
1895- QHash<int, QByteArray> roleNames() const;
1896-
1897- Q_INVOKABLE int indexOf(const QString &devicePath) const;
1898-
1899- Q_INVOKABLE QInputDevice *get(int index) const;
1900-
1901- // For testing
1902- Q_INVOKABLE void addMockMouse();
1903- Q_INVOKABLE void addMockKeyboard();
1904- Q_INVOKABLE void removeMockMouse();
1905- Q_INVOKABLE void removeMockKeyboard();
1906-
1907-Q_SIGNALS:
1908- void newDevice(const QString &devicePath);
1909- void deviceRemoved(const QString &devicePath);
1910-
1911-public Q_SLOTS:
1912- void updateDeviceList();
1913-
1914-private:
1915- QInputDeviceInfo *deviceInfo;
1916- QVector<QInputDevice *> inputDevices;
1917-private Q_SLOTS:
1918- void addedDevice(const QString &);
1919- void removedDevice(const QString &path);
1920-
1921-};
1922-
1923-#endif // QDECLARATIVEINPUTDEVICEINFO_H
1924
1925=== removed file 'tests/mocks/Unity/InputInfo/mockqinputinfo.cpp'
1926--- tests/mocks/Unity/InputInfo/mockqinputinfo.cpp 2015-06-23 17:40:03 +0000
1927+++ tests/mocks/Unity/InputInfo/mockqinputinfo.cpp 1970-01-01 00:00:00 +0000
1928@@ -1,124 +0,0 @@
1929-/****************************************************************************
1930-**
1931-** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
1932-** Contact: http://www.qt-project.org/legal
1933-**
1934-** This file is part of the QtSystems module of the Qt Toolkit.
1935-**
1936-** $QT_BEGIN_LICENSE:LGPL$
1937-** Commercial License Usage
1938-** Licensees holding valid commercial Qt licenses may use this file in
1939-** accordance with the commercial license agreement provided with the
1940-** Software or, alternatively, in accordance with the terms contained in
1941-** a written agreement between you and Digia. For licensing terms and
1942-** conditions see http://qt.digia.com/licensing. For further information
1943-** use the contact form at http://qt.digia.com/contact-us.
1944-**
1945-** GNU Lesser General Public License Usage
1946-** Alternatively, this file may be used under the terms of the GNU Lesser
1947-** General Public License version 2.1 as published by the Free Software
1948-** Foundation and appearing in the file LICENSE.LGPL included in the
1949-** packaging of this file. Please review the following information to
1950-** ensure the GNU Lesser General Public License version 2.1 requirements
1951-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
1952-**
1953-** In addition, as a special exception, Digia gives you certain additional
1954-** rights. These rights are described in the Digia Qt LGPL Exception
1955-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
1956-**
1957-** GNU General Public License Usage
1958-** Alternatively, this file may be used under the terms of the GNU
1959-** General Public License version 3.0 as published by the Free Software
1960-** Foundation and appearing in the file LICENSE.GPL included in the
1961-** packaging of this file. Please review the following information to
1962-** ensure the GNU General Public License version 3.0 requirements will be
1963-** met: http://www.gnu.org/copyleft/gpl.html.
1964-**
1965-**
1966-** $QT_END_LICENSE$
1967-**
1968-****************************************************************************/
1969-
1970-#include "mockqinputinfo.h"
1971-
1972-
1973-QInputDevice::QInputDevice(QObject *parent) :
1974- QObject(parent)
1975-{
1976-}
1977-
1978-QString QInputDevice::name() const
1979-{
1980- return m_name;
1981-}
1982-
1983-void QInputDevice::setName(const QString &name)
1984-{
1985- m_name = name;
1986-}
1987-
1988-QString QInputDevice::devicePath() const
1989-{
1990- return m_devicePath;
1991-}
1992-
1993-void QInputDevice::setDevicePath(const QString &path)
1994-{
1995- m_devicePath = path;
1996-}
1997-
1998-QList <int> QInputDevice::buttons() const
1999-{
2000- return {1, 2 ,3};
2001-}
2002-
2003-QList <int> QInputDevice::switches() const
2004-{
2005- return {};
2006-}
2007-
2008-QList <int> QInputDevice::relativeAxis() const
2009-{
2010- return {};
2011-}
2012-
2013-QList <int> QInputDevice::absoluteAxis() const
2014-{
2015- return {};
2016-}
2017-
2018-QInputDeviceInfo::InputTypes QInputDevice::types()
2019-{
2020- return m_types;
2021-}
2022-
2023-void QInputDevice::setTypes(QInputDeviceInfo::InputTypes types)
2024-{
2025- m_types = types;
2026-}
2027-
2028-QInputDeviceInfo::QInputDeviceInfo(QObject *parent) :
2029- QObject(parent)
2030-{
2031-}
2032-
2033-QVector <QInputDevice *> QInputDeviceInfo::deviceList()
2034-{
2035- return m_list;
2036-}
2037-
2038-void QInputDeviceInfo::removeMockDevice(int index)
2039-{
2040- QInputDevice *device = m_list.takeAt(index);
2041- Q_EMIT deviceRemoved(device->devicePath());
2042- device->deleteLater();
2043-}
2044-
2045-void QInputDeviceInfo::addMockDevice(QInputDeviceInfo::InputType inputType)
2046-{
2047- QInputDevice *device = new QInputDevice(this);
2048- device->setDevicePath("/mock/device/" + QString::number(m_counter++));
2049- device->setTypes({inputType});
2050- m_list.append(device);
2051- Q_EMIT deviceAdded(device->devicePath());
2052-}
2053
2054=== removed file 'tests/mocks/Unity/InputInfo/mockqinputinfo.h'
2055--- tests/mocks/Unity/InputInfo/mockqinputinfo.h 2015-06-23 17:40:03 +0000
2056+++ tests/mocks/Unity/InputInfo/mockqinputinfo.h 1970-01-01 00:00:00 +0000
2057@@ -1,139 +0,0 @@
2058-/****************************************************************************
2059-**
2060-** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
2061-** Contact: http://www.qt-project.org/legal
2062-**
2063-** This file is part of the QtSystems module of the Qt Toolkit.
2064-**
2065-** $QT_BEGIN_LICENSE:LGPL$
2066-** Commercial License Usage
2067-** Licensees holding valid commercial Qt licenses may use this file in
2068-** accordance with the commercial license agreement provided with the
2069-** Software or, alternatively, in accordance with the terms contained in
2070-** a written agreement between you and Digia. For licensing terms and
2071-** conditions see http://qt.digia.com/licensing. For further information
2072-** use the contact form at http://qt.digia.com/contact-us.
2073-**
2074-** GNU Lesser General Public License Usage
2075-** Alternatively, this file may be used under the terms of the GNU Lesser
2076-** General Public License version 2.1 as published by the Free Software
2077-** Foundation and appearing in the file LICENSE.LGPL included in the
2078-** packaging of this file. Please review the following information to
2079-** ensure the GNU Lesser General Public License version 2.1 requirements
2080-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2081-**
2082-** In addition, as a special exception, Digia gives you certain additional
2083-** rights. These rights are described in the Digia Qt LGPL Exception
2084-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
2085-**
2086-** GNU General Public License Usage
2087-** Alternatively, this file may be used under the terms of the GNU
2088-** General Public License version 3.0 as published by the Free Software
2089-** Foundation and appearing in the file LICENSE.GPL included in the
2090-** packaging of this file. Please review the following information to
2091-** ensure the GNU General Public License version 3.0 requirements will be
2092-** met: http://www.gnu.org/copyleft/gpl.html.
2093-**
2094-**
2095-** $QT_END_LICENSE$
2096-**
2097-****************************************************************************/
2098-
2099-#ifndef MOCKQINPUTINFO_H
2100-#define MOCKQINPUTINFO_H
2101-
2102-#include <QObject>
2103-#include <QVector>
2104-#include <QMap>
2105-#include <QSocketNotifier>
2106-#include <QDebug>
2107-
2108-class QInputDevicePrivate;
2109-class QInputDevice;
2110-
2111-class QInputDeviceInfoPrivate;
2112-class QInputDeviceInfo : public QObject
2113-{
2114- Q_OBJECT
2115- Q_PROPERTY(int deviceCount READ deviceCount)
2116-public:
2117-
2118- enum InputType {
2119- Unknown = 0,
2120- Button = 1,
2121- Mouse = 2,
2122- TouchPad = 4,
2123- TouchScreen = 8,
2124- Keyboard = 16,
2125- Switch = 32
2126- };
2127- Q_ENUMS(InputType)
2128- Q_FLAGS(InputTypes)
2129- Q_DECLARE_FLAGS(InputTypes, InputType)
2130-
2131- explicit QInputDeviceInfo(QObject *parent = 0);
2132-
2133- Q_INVOKABLE QVector <QInputDevice *> deviceList();
2134-
2135- int deviceCount() { return deviceList().count(); }
2136-
2137- Q_INVOKABLE void addMockDevice(InputType inputType);
2138- Q_INVOKABLE void removeMockDevice(int index);
2139-
2140-Q_SIGNALS:
2141-
2142- void deviceAdded(const QString & devicePath);
2143- void deviceRemoved(const QString & devicePath);
2144-
2145-private:
2146- QVector<QInputDevice*> m_list;
2147-
2148- int m_counter = 0;
2149-};
2150-
2151-class QInputDevice : public QObject
2152-{
2153- friend class QInputDeviceInfoPrivate;
2154- Q_OBJECT
2155- Q_ENUMS(InputType)
2156- Q_FLAGS(InputTypes)
2157- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
2158- Q_PROPERTY(QString devicePath READ devicePath NOTIFY devicePathChanged)
2159- Q_PROPERTY(QList <int> buttons READ buttons NOTIFY buttonsChanged)
2160- Q_PROPERTY(QList <int> switches READ switches NOTIFY switchesChanged)
2161- Q_PROPERTY(QList <int> relativeAxis READ relativeAxis NOTIFY relativeAxisChanged)
2162- Q_PROPERTY(QList <int> absoluteAxis READ absoluteAxis NOTIFY absoluteAxisChanged)
2163- Q_PROPERTY(QInputDeviceInfo::InputTypes types READ types NOTIFY typesChanged)
2164-
2165-public:
2166- explicit QInputDevice(QObject *parent = 0);
2167-
2168- QString name() const;
2169- QString devicePath() const;
2170- QList <int> buttons() const; //keys event code
2171- QList <int> switches() const;
2172- QList <int> relativeAxis() const;
2173- QList <int> absoluteAxis() const;
2174-
2175- QInputDeviceInfo::InputTypes types();
2176-Q_SIGNALS:
2177- void nameChanged();
2178- void devicePathChanged();
2179- void buttonsChanged();
2180- void switchesChanged();
2181- void relativeAxisChanged();
2182- void absoluteAxisChanged();
2183- void typesChanged();
2184-private:
2185- void setName(const QString &name);
2186- void setTypes(QInputDeviceInfo::InputTypes types);
2187- void setDevicePath(const QString &path);
2188-
2189- QString m_name;
2190- QInputDeviceInfo::InputTypes m_types;
2191- QString m_devicePath;
2192-
2193- friend class QInputDeviceInfo;
2194-};
2195-
2196-#endif // MOCKQINPUTINFO_H
2197
2198=== modified file 'tests/mocks/Unity/InputInfo/plugin.cpp'
2199--- tests/mocks/Unity/InputInfo/plugin.cpp 2015-06-23 17:40:03 +0000
2200+++ tests/mocks/Unity/InputInfo/plugin.cpp 2015-11-09 09:23:42 +0000
2201@@ -15,18 +15,32 @@
2202 */
2203
2204 // Qt
2205-#include <QtQml/qqml.h>
2206+#include <QtQml>
2207
2208 // self
2209 #include "plugin.h"
2210
2211 // local
2212-#include "mockqdeclarativeinputdeviceinfo_p.h"
2213+#include "qdeclarativeinputdevicemodel_p.h"
2214+#include "mockcontroller.h"
2215+
2216+static QObject *backendProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
2217+{
2218+ Q_UNUSED(engine)
2219+ Q_UNUSED(scriptEngine)
2220+ return new MockController(engine);
2221+}
2222
2223 void InputInfoPlugin::registerTypes(const char *uri)
2224 {
2225 int major = 0;
2226 int minor = 1;
2227- qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo");
2228+ qmlRegisterType<QDeclarativeInputDeviceModel>(uri, major, minor, "InputDeviceModel");
2229 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
2230+
2231+ // We can't register the MockInputDeviceBackend directly because QML wants to delete singletons on its own
2232+ // Given that MockInputDeviceBackend is a Q_GLOBAL_STATIC it will also be cleaned up by other Qt internals
2233+ // This leads to a double-free on shutdown. So let's add a proxy to control the MockBackend through QML:
2234+ // MockController
2235+ qmlRegisterSingletonType<MockController>(uri, major, minor, "MockInputDeviceBackend", backendProvider);
2236 }
2237
2238=== added file 'tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp'
2239--- tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp 1970-01-01 00:00:00 +0000
2240+++ tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp 2015-11-09 09:23:42 +0000
2241@@ -0,0 +1,52 @@
2242+/*
2243+ * Copyright 2015 Canonical Ltd.
2244+ *
2245+ * This program is free software; you can redistribute it and/or modify
2246+ * it under the terms of the GNU Lesser General Public License as published by
2247+ * the Free Software Foundation; version 3.
2248+ *
2249+ * This program is distributed in the hope that it will be useful,
2250+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2251+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2252+ * GNU Lesser General Public License for more details.
2253+ *
2254+ * You should have received a copy of the GNU Lesser General Public License
2255+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2256+ */
2257+
2258+#include "qinputdeviceinfo_mock_p.h"
2259+
2260+#include <QTimer>
2261+#include <QDebug>
2262+
2263+QInputDeviceManagerPrivate::QInputDeviceManagerPrivate(QObject *parent) :
2264+ QObject(parent),
2265+ currentFilter(QInputDevice::Unknown)
2266+{
2267+ QTimer::singleShot(1, SIGNAL(ready()));
2268+}
2269+
2270+QInputDeviceManagerPrivate::~QInputDeviceManagerPrivate()
2271+{
2272+}
2273+
2274+QInputDevice *QInputDeviceManagerPrivate::addMockDevice(const QString &devicePath, QInputDevice::InputType type)
2275+{
2276+ QInputDevice *inputDevice = new QInputDevice(this);
2277+ inputDevice->setDevicePath(devicePath);
2278+ inputDevice->setName("Mock Device " + devicePath);
2279+ inputDevice->setType(type);
2280+ deviceMap.insert(devicePath, inputDevice);
2281+ Q_EMIT deviceAdded(devicePath);
2282+ return inputDevice;
2283+}
2284+
2285+void QInputDeviceManagerPrivate::removeDevice(const QString &path)
2286+{
2287+ Q_FOREACH (const QString devicePath, deviceMap.keys()) {
2288+ if (devicePath.contains(path)) {
2289+ deviceMap.remove(devicePath);
2290+ Q_EMIT deviceRemoved(devicePath);
2291+ }
2292+ }
2293+}
2294
2295=== added file 'tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.h'
2296--- tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.h 1970-01-01 00:00:00 +0000
2297+++ tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.h 2015-11-09 09:23:42 +0000
2298@@ -0,0 +1,58 @@
2299+/*
2300+ * Copyright 2015 Canonical Ltd.
2301+ *
2302+ * This program is free software; you can redistribute it and/or modify
2303+ * it under the terms of the GNU Lesser General Public License as published by
2304+ * the Free Software Foundation; version 3.
2305+ *
2306+ * This program is distributed in the hope that it will be useful,
2307+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2308+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2309+ * GNU Lesser General Public License for more details.
2310+ *
2311+ * You should have received a copy of the GNU Lesser General Public License
2312+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2313+ */
2314+
2315+#ifndef QINPUTDEVICEINFO_MOCK_H
2316+#define QINPUTDEVICEINFO_MOCK_H
2317+
2318+#include <QObject>
2319+#include "qinputinfo.h"
2320+
2321+class QInputDevicePrivate : public QObject
2322+{
2323+ Q_OBJECT
2324+public:
2325+ explicit QInputDevicePrivate(QObject *parent = 0);
2326+
2327+ QString name;
2328+ QString devicePath;
2329+ QList <int> buttons; //keys
2330+ QList <int> switches;
2331+ QList <int> relativeAxis;
2332+ QList <int> absoluteAxis;
2333+ QInputDevice::InputTypeFlags type;
2334+};
2335+
2336+class QInputDeviceManagerPrivate : public QObject
2337+{
2338+ Q_OBJECT
2339+public:
2340+ explicit QInputDeviceManagerPrivate(QObject *parent = 0);
2341+ ~QInputDeviceManagerPrivate();
2342+ QVector <QInputDevice *> deviceList;
2343+ QMap <QString, QInputDevice *> deviceMap;
2344+ static QInputDeviceManagerPrivate * instance();
2345+ QInputDevice::InputType currentFilter;
2346+
2347+ Q_INVOKABLE QInputDevice* addMockDevice(const QString &devicePath, QInputDevice::InputType type);
2348+ Q_INVOKABLE void removeDevice(const QString &devicePath);
2349+
2350+Q_SIGNALS:
2351+ void deviceAdded(const QString &);
2352+ void deviceRemoved(const QString &);
2353+ void ready();
2354+};
2355+
2356+#endif // QINPUTDEVICEINFO_MOCK_H
2357
2358=== modified file 'tests/qmltests/Notifications/tst_Notifications.qml'
2359--- tests/qmltests/Notifications/tst_Notifications.qml 2015-09-29 12:28:10 +0000
2360+++ tests/qmltests/Notifications/tst_Notifications.qml 2015-11-09 09:23:42 +0000
2361@@ -19,7 +19,6 @@
2362 import QtTest 1.0
2363 import ".."
2364 import "../../../qml/Notifications"
2365-import "../../../qml/Components/UnityInputInfo"
2366 import Ubuntu.Components 1.3
2367 import Unity.Test 0.1
2368 import Unity.Notifications 1.0
2369@@ -188,7 +187,7 @@
2370
2371 anchors.fill: parent
2372 model: mockModel
2373- hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
2374+ hasMouse: false
2375 }
2376 }
2377
2378@@ -264,9 +263,9 @@
2379 id: fakeMouseCB
2380 onClicked: {
2381 if (checked) {
2382- UnityInputInfo.inputInfo.addMockMouse();
2383+ notifications.hasMouse = true;
2384 } else {
2385- UnityInputInfo.inputInfo.removeMockMouse();
2386+ notifications.hasMouse = false;
2387 }
2388 }
2389 }
2390@@ -695,7 +694,7 @@
2391 }
2392
2393 function test_clickToClose_data() { // reuse the data
2394- UnityInputInfo.inputInfo.addMockMouse();
2395+ notifications.hasMouse = true;
2396 return test_NotificationRenderer_data();
2397 }
2398
2399@@ -726,7 +725,7 @@
2400 }
2401
2402 function cleanupTestCase() {
2403- UnityInputInfo.inputInfo.removeMockMouse();
2404+ notifications.hasMouse = false;
2405 }
2406 }
2407 }
2408
2409=== modified file 'tests/qmltests/Notifications/tst_SwipeToAct.qml'
2410--- tests/qmltests/Notifications/tst_SwipeToAct.qml 2015-09-29 12:28:10 +0000
2411+++ tests/qmltests/Notifications/tst_SwipeToAct.qml 2015-11-09 09:23:42 +0000
2412@@ -19,7 +19,6 @@
2413 import QtTest 1.0
2414 import ".."
2415 import "../../../qml/Notifications"
2416-import "../../../qml/Components/UnityInputInfo"
2417 import Ubuntu.Components 1.3
2418 import Unity.Test 0.1
2419 import Unity.Notifications 1.0
2420@@ -112,7 +111,7 @@
2421
2422 anchors.fill: parent
2423 model: mockModel
2424- hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
2425+ hasMouse: false
2426 }
2427 }
2428
2429@@ -152,9 +151,9 @@
2430 id: fakeMouseCB
2431 onClicked: {
2432 if (checked) {
2433- UnityInputInfo.inputInfo.addMockMouse();
2434+ notifications.hasMouse = true;
2435 } else {
2436- UnityInputInfo.inputInfo.removeMockMouse();
2437+ notifications.hasMouse = false;
2438 }
2439 }
2440 }
2441@@ -301,7 +300,7 @@
2442 }
2443
2444 // add a mock mouse, test clicking the left/right buttons
2445- UnityInputInfo.inputInfo.addMockMouse();
2446+ notifications.hasMouse = true;
2447 var leftButton = findChild(swipeButton, "leftButton");
2448 var rightButton = findChild(swipeButton, "rightButton");
2449
2450@@ -316,7 +315,7 @@
2451 compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action");
2452 actionSpy.clear();
2453 }
2454- UnityInputInfo.inputInfo.removeMockMouse();
2455+ notifications.hasMouse = false;
2456 }
2457 }
2458 }
2459
2460=== modified file 'tests/qmltests/tst_OrientedShell.qml'
2461--- tests/qmltests/tst_OrientedShell.qml 2015-11-04 14:57:45 +0000
2462+++ tests/qmltests/tst_OrientedShell.qml 2015-11-09 09:23:42 +0000
2463@@ -26,7 +26,6 @@
2464 import Unity.InputInfo 0.1
2465
2466 import "../../qml"
2467-import "../../qml/Components/UnityInputInfo"
2468
2469 Rectangle {
2470 id: root
2471@@ -55,6 +54,15 @@
2472 property bool stayHidden: false;
2473 }
2474
2475+ InputDeviceModel {
2476+ id: miceModel
2477+ deviceFilter: InputInfo.Mouse
2478+ }
2479+ InputDeviceModel {
2480+ id: keyboardsModel
2481+ deviceFilter: InputInfo.Keyboard
2482+ }
2483+
2484 property int physicalOrientation0
2485 property int physicalOrientation90
2486 property int physicalOrientation180
2487@@ -328,14 +336,14 @@
2488 text: "Add mouse"
2489 activeFocusOnPress: false
2490 onClicked: {
2491- UnityInputInfo.inputInfo.addMockMouse()
2492+ MockInputDeviceBackend.addMockDevice("/mouse" + miceModel.count, InputInfo.Mouse)
2493 }
2494 }
2495 Button {
2496 text: "Remove mouse"
2497 activeFocusOnPress: false
2498 onClicked: {
2499- UnityInputInfo.inputInfo.removeMockMouse()
2500+ MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1))
2501 }
2502 }
2503 }
2504@@ -344,14 +352,14 @@
2505 text: "Add kbd"
2506 activeFocusOnPress: false
2507 onClicked: {
2508- UnityInputInfo.inputInfo.addMockKeyboard()
2509+ MockInputDeviceBackend.addMockDevice("/kbd" + keyboardsModel.count, InputInfo.Keyboard)
2510 }
2511 }
2512 Button {
2513 activeFocusOnPress: false
2514 text: "Remove kbd"
2515 onClicked: {
2516- UnityInputInfo.inputInfo.removeMockKeyboard()
2517+ MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
2518 }
2519 }
2520 }
2521@@ -976,19 +984,19 @@
2522 tryCompare(shell, "usageScenario", "phone");
2523 tryCompare(mockOskSettings, "stayHidden", false);
2524
2525- UnityInputInfo.inputInfo.addMockKeyboard();
2526+ MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
2527 tryCompare(shell, "usageScenario", "phone");
2528 tryCompare(mockOskSettings, "stayHidden", true);
2529
2530- UnityInputInfo.inputInfo.addMockMouse();
2531+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
2532 tryCompare(shell, "usageScenario", "desktop");
2533 tryCompare(mockOskSettings, "stayHidden", true);
2534
2535- UnityInputInfo.inputInfo.removeMockKeyboard();
2536+ MockInputDeviceBackend.removeDevice("/kbd0");
2537 tryCompare(shell, "usageScenario", "desktop");
2538 tryCompare(mockOskSettings, "stayHidden", false);
2539
2540- UnityInputInfo.inputInfo.removeMockMouse();
2541+ MockInputDeviceBackend.removeDevice("/mouse0");
2542 tryCompare(shell, "usageScenario", "phone");
2543 tryCompare(mockOskSettings, "stayHidden", false);
2544 }

Subscribers

People subscribed via source and target branches