on xenial help sign in
Refactor PhysicalKeysFilter to PhysicalKeysMapper
commit1e92296b7f336f1d1f7a1ff6353349027ff957f5 authorJosh Arenson <joshua.arenson@canonical.com> dateWed 10 Dec 2014, 12:14 (12 years ago) parent7c6231d
4 files changed+22−22
qml/Components/PhysicalKeysFilter.qml → qml/Components/PhysicalKeysMapper.qml+2−2 qml/Shell.qml+5−5 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Components/tst_PhysicalKeysFilter.qml → tests/qmltests/Components/tst_PhysicalKeysMapper.qml+14−14
qml/Components/PhysicalKeysFilter.qml → qml/Components/PhysicalKeysMapper.qmlrenamed+2−2
@@ -16,9 +16,9 @@
1616
1717import QtQuick 2.0
1818/*!
19− \brief A filter for the physical keys on the device
19+ \brief A mapper for the physical keys on the device
2020
21− A filter to handle events triggered by pressing physical keys on a device.
21+ A mapper to handle events triggered by pressing physical keys on a device.
2222 Keys included are
2323 * Volume Decrease
2424 * Volume Increase
qml/Shell.qml+5−5
@@ -154,8 +154,8 @@ Item {
154154 objectName: "dashCommunicator"
155155 }
156156
157− PhysicalKeysFilter {
158− id: physicalKeysFilter
157+ PhysicalKeysMapper {
158+ id: physicalKeysMapper
159159
160160 onVolumeDownPressed: volumeControl.volumeDown()
161161 onVolumeUpPressed: volumeControl.volumeUp()
@@ -176,11 +176,11 @@ Item {
176176
177177 WindowKeysFilter {
178178 Keys.onPressed: {
179− event.accepted = physicalKeysFilter.onKeyPressed(event.key);
179+ event.accepted = physicalKeysMapper.onKeyPressed(event.key);
180180 }
181181
182182 Keys.onReleased: {
183− event.accepted = physicalKeysFilter.onKeyReleased(event.key);
183+ event.accepted = physicalKeysMapper.onKeyReleased(event.key);
184184 }
185185 }
186186
@@ -805,7 +805,7 @@ Item {
805805 }
806806
807807 Connections {
808− target: physicalKeysFilter
808+ target: physicalKeysMapper
809809 onPowerKeyLongPress: dialogs.showPowerDialog();
810810 }
811811 }
tests/qmltests/CMakeLists.txt+1−1
@@ -27,7 +27,7 @@ add_qml_test(Components DraggingArea)
2727add_qml_test(Components EdgeDemoOverlay)
2828add_qml_test(Components LazyImage)
2929add_qml_test(Components Lockscreen)
30−add_qml_test(Components PhysicalKeysFilter)
30+add_qml_test(Components PhysicalKeysMapper)
3131add_qml_test(Components Rating)
3232add_qml_test(Components ResponsiveGridView)
3333add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/Components/tst_PhysicalKeysFilter.qml → tests/qmltests/Components/tst_PhysicalKeysMapper.qmlrenamed+14−14
@@ -30,8 +30,8 @@ Item {
3030 property int onVolumeDownPressedCount: 0
3131 property int onVolumeUpPressedCount: 0
3232
33− PhysicalKeysFilter {
34− id: physicalKeysFilter
33+ PhysicalKeysMapper {
34+ id: physicalKeysMapper
3535
3636 onBothVolumeKeysPressed: onBothVolumeKeysPressedCount += 1
3737 onPowerKeyLongPress: onPowerKeyLongPressCount += 1
@@ -41,14 +41,14 @@ Item {
4141 }
4242
4343 UT.UnityTestCase {
44− name: "PhysicalKeyFilter"
44+ name: "PhysicalKeyMapper"
4545 when: windowShown
4646
4747 function cleanup() {
48− physicalKeysFilter.onKeyReleased(Qt.Key_PowerDown);
49− physicalKeysFilter.onKeyReleased(Qt.Key_PowerOff);
50− physicalKeysFilter.onKeyReleased(Qt.Key_VolumeDown);
51− physicalKeysFilter.onKeyReleased(Qt.Key_VolumeUp);
48+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
49+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
50+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
51+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
5252
5353 onBothVolumeKeysPressedCount = 0;
5454 onPowerKeyLongPressCount = 0;
@@ -58,8 +58,8 @@ Item {
5858 }
5959
6060 function test_both_volume_keys_simultaneously() {
61− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
62− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
61+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
62+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
6363
6464 compare(onBothVolumeKeysPressedCount, 1);
6565
@@ -69,15 +69,15 @@ Item {
6969 }
7070
7171 function test_long_press_power_button() {
72− physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
72+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
7373 wait(3000);
7474
7575 compare(onPowerKeyLongPressCount, 1);
7676 }
7777
7878 function test_screenshot_buttons() {
79− physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
80− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
79+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
80+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
8181
8282 compare(onScreenshotPressedCount, 1);
8383 compare(onVolumeDownPressedCount, 0);
@@ -88,12 +88,12 @@ Item {
8888 }
8989
9090 function test_volume_down_button() {
91− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
91+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
9292 compare(onVolumeDownPressedCount, 1);
9393 }
9494
9595 function test_volume_up_button() {
96− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
96+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
9797 compare(onVolumeUpPressedCount, 1);
9898 }
9999 }