on xenial help sign in
Refactor PhysicalKeysFilter to PhysicalKeysMapper
1e92296Josh Arenson
qml/Components/PhysicalKeysFilter.qml → qml/Components/PhysicalKeysMapper.qmlrenamed+2−2
@@ -16,9 +16,9 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18/*!
18/*!
19− \brief A filter for the physical keys on the device
19+ \brief A mapper for the physical keys on the device
20
20
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.
22 Keys included are
22 Keys included are
23 * Volume Decrease
23 * Volume Decrease
24 * Volume Increase
24 * Volume Increase
qml/Shell.qml+5−5
@@ -154,8 +154,8 @@ Item {
154 objectName: "dashCommunicator"
154 objectName: "dashCommunicator"
155 }
155 }
156
156
157− PhysicalKeysFilter {
157+ PhysicalKeysMapper {
158− id: physicalKeysFilter
158+ id: physicalKeysMapper
159
159
160 onVolumeDownPressed: volumeControl.volumeDown()
160 onVolumeDownPressed: volumeControl.volumeDown()
161 onVolumeUpPressed: volumeControl.volumeUp()
161 onVolumeUpPressed: volumeControl.volumeUp()
@@ -176,11 +176,11 @@ Item {
176
176
177 WindowKeysFilter {
177 WindowKeysFilter {
178 Keys.onPressed: {
178 Keys.onPressed: {
179− event.accepted = physicalKeysFilter.onKeyPressed(event.key);
179+ event.accepted = physicalKeysMapper.onKeyPressed(event.key);
180 }
180 }
181
181
182 Keys.onReleased: {
182 Keys.onReleased: {
183− event.accepted = physicalKeysFilter.onKeyReleased(event.key);
183+ event.accepted = physicalKeysMapper.onKeyReleased(event.key);
184 }
184 }
185 }
185 }
186
186
@@ -805,7 +805,7 @@ Item {
805 }
805 }
806
806
807 Connections {
807 Connections {
808− target: physicalKeysFilter
808+ target: physicalKeysMapper
809 onPowerKeyLongPress: dialogs.showPowerDialog();
809 onPowerKeyLongPress: dialogs.showPowerDialog();
810 }
810 }
811 }
811 }
tests/qmltests/CMakeLists.txt+1−1
@@ -27,7 +27,7 @@ add_qml_test(Components DraggingArea)
27add_qml_test(Components EdgeDemoOverlay)
27add_qml_test(Components EdgeDemoOverlay)
28add_qml_test(Components LazyImage)
28add_qml_test(Components LazyImage)
29add_qml_test(Components Lockscreen)
29add_qml_test(Components Lockscreen)
30−add_qml_test(Components PhysicalKeysFilter)
30+add_qml_test(Components PhysicalKeysMapper)
31add_qml_test(Components Rating)
31add_qml_test(Components Rating)
32add_qml_test(Components ResponsiveGridView)
32add_qml_test(Components ResponsiveGridView)
33add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
33add_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 {
30 property int onVolumeDownPressedCount: 0
30 property int onVolumeDownPressedCount: 0
31 property int onVolumeUpPressedCount: 0
31 property int onVolumeUpPressedCount: 0
32
32
33− PhysicalKeysFilter {
33+ PhysicalKeysMapper {
34− id: physicalKeysFilter
34+ id: physicalKeysMapper
35
35
36 onBothVolumeKeysPressed: onBothVolumeKeysPressedCount += 1
36 onBothVolumeKeysPressed: onBothVolumeKeysPressedCount += 1
37 onPowerKeyLongPress: onPowerKeyLongPressCount += 1
37 onPowerKeyLongPress: onPowerKeyLongPressCount += 1
@@ -41,14 +41,14 @@ Item {
41 }
41 }
42
42
43 UT.UnityTestCase {
43 UT.UnityTestCase {
44− name: "PhysicalKeyFilter"
44+ name: "PhysicalKeyMapper"
45 when: windowShown
45 when: windowShown
46
46
47 function cleanup() {
47 function cleanup() {
48− physicalKeysFilter.onKeyReleased(Qt.Key_PowerDown);
48+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerDown);
49− physicalKeysFilter.onKeyReleased(Qt.Key_PowerOff);
49+ physicalKeysMapper.onKeyReleased(Qt.Key_PowerOff);
50− physicalKeysFilter.onKeyReleased(Qt.Key_VolumeDown);
50+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeDown);
51− physicalKeysFilter.onKeyReleased(Qt.Key_VolumeUp);
51+ physicalKeysMapper.onKeyReleased(Qt.Key_VolumeUp);
52
52
53 onBothVolumeKeysPressedCount = 0;
53 onBothVolumeKeysPressedCount = 0;
54 onPowerKeyLongPressCount = 0;
54 onPowerKeyLongPressCount = 0;
@@ -58,8 +58,8 @@ Item {
58 }
58 }
59
59
60 function test_both_volume_keys_simultaneously() {
60 function test_both_volume_keys_simultaneously() {
61− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
61+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
62− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
62+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
63
63
64 compare(onBothVolumeKeysPressedCount, 1);
64 compare(onBothVolumeKeysPressedCount, 1);
65
65
@@ -69,15 +69,15 @@ Item {
69 }
69 }
70
70
71 function test_long_press_power_button() {
71 function test_long_press_power_button() {
72− physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
72+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
73 wait(3000);
73 wait(3000);
74
74
75 compare(onPowerKeyLongPressCount, 1);
75 compare(onPowerKeyLongPressCount, 1);
76 }
76 }
77
77
78 function test_screenshot_buttons() {
78 function test_screenshot_buttons() {
79− physicalKeysFilter.onKeyPressed(Qt.Key_PowerDown);
79+ physicalKeysMapper.onKeyPressed(Qt.Key_PowerDown);
80− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
80+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
81
81
82 compare(onScreenshotPressedCount, 1);
82 compare(onScreenshotPressedCount, 1);
83 compare(onVolumeDownPressedCount, 0);
83 compare(onVolumeDownPressedCount, 0);
@@ -88,12 +88,12 @@ Item {
88 }
88 }
89
89
90 function test_volume_down_button() {
90 function test_volume_down_button() {
91− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeDown);
91+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeDown);
92 compare(onVolumeDownPressedCount, 1);
92 compare(onVolumeDownPressedCount, 1);
93 }
93 }
94
94
95 function test_volume_up_button() {
95 function test_volume_up_button() {
96− physicalKeysFilter.onKeyPressed(Qt.Key_VolumeUp);
96+ physicalKeysMapper.onKeyPressed(Qt.Key_VolumeUp);
97 compare(onVolumeUpPressedCount, 1);
97 compare(onVolumeUpPressedCount, 1);
98 }
98 }
99 }
99 }