@@ -35,17 +35,17 @@ import Powerd 0.1
38− signal powerKeyLongPress();
38+ signal powerKeyLongPress;
39−
39+ signal volumeDownTrigger;
40− property bool screenshotPressed: d.volumeUpKeyPressed && d.volumeDownKeyPressed
40+ signal volumeUpTrigger;
41− property bool volumeDownPressed: d.volumeDownKeyPressed && !d.volumeUpKeyPressed
41+ signal screenshotTrigger;
42− property bool volumeUpPressed: d.volumeUpKeyPressed && !d.volumeDownKeyPressed
44 QtObject {
43 QtObject {
47 property bool volumeDownKeyPressed: false
46 property bool volumeDownKeyPressed: false
48 property bool volumeUpKeyPressed: false
47 property bool volumeUpKeyPressed: false
48+ property bool ignoreVolumeEvents: false
@@ -57,10 +57,9 @@ Item {
59 function onKeyPressed(event) {
59 function onKeyPressed(event) {
60− var eventAccepted = false;
62 /* Determine what key was pressed */
60 /* Determine what key was pressed */
63− if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
61+ if ((event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff)
62+ && !event.isAutoRepeat) {
65 // FIXME: We only consider power key presses if the screen is
64 // FIXME: We only consider power key presses if the screen is
66 // on because of bugs 1410830/1409003. The theory is that when
65 // on because of bugs 1410830/1409003. The theory is that when
@@ -71,34 +70,45 @@ Item {
71 // initiate any dialogs when the screen is off.
70 // initiate any dialogs when the screen is off.
72 // This also prevents taking screenshots when the screen is off.
71 // This also prevents taking screenshots when the screen is off.
73 if (Powerd.status === Powerd.On) {
72 if (Powerd.status === Powerd.On) {
74− if (!event.isAutoRepeat) {
75− powerKeyLongPressTimer.restart();
73+ powerKeyLongPressTimer.restart();
76− }
74+ event.accepted = true;
77− eventAccepted = true;
79− } else if (event.key == Qt.Key_MediaTogglePlayPause || event.key == Qt.Key_MediaPlay) {
76+ } else if ((event.key == Qt.Key_MediaTogglePlayPause || event.key == Qt.Key_MediaPlay)
77+ && !event.isAutoRepeat) {
80− eventAccepted = callManager.handleMediaKey(false);
78+ event.accepted = callManager.handleMediaKey(false);
81 } else if (event.key == Qt.Key_VolumeDown) {
79 } else if (event.key == Qt.Key_VolumeDown) {
80+ if (event.isAutoRepeat && !d.ignoreVolumeEvents) root.volumeDownTrigger();
81+ else if (!event.isAutoRepeat) {
82+ if (d.volumeUpKeyPressed) {
83+ root.screenshotTrigger();
84+ d.ignoreVolumeEvents = true;
82− d.volumeDownKeyPressed = true;
86+ d.volumeDownKeyPressed = true;
83 } else if (event.key == Qt.Key_VolumeUp) {
88 } else if (event.key == Qt.Key_VolumeUp) {
89+ if (event.isAutoRepeat && !d.ignoreVolumeEvents) root.volumeUpTrigger();
90+ else if (!event.isAutoRepeat) {
91+ if (d.volumeDownKeyPressed) {
92+ root.screenshotTrigger();
93+ d.ignoreVolumeEvents = true;
84− d.volumeUpKeyPressed = true;
95+ d.volumeUpKeyPressed = true;
87− return eventAccepted;
90 function onKeyReleased(event) {
100 function onKeyReleased(event) {
91− var eventAccepted = false;
93 if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
101 if (event.key == Qt.Key_PowerDown || event.key == Qt.Key_PowerOff) {
94 powerKeyLongPressTimer.stop();
102 powerKeyLongPressTimer.stop();
95− eventAccepted = true;
103+ event.accepted = true;
96 } else if (event.key == Qt.Key_VolumeDown) {
104 } else if (event.key == Qt.Key_VolumeDown) {
105+ if (!d.ignoreVolumeEvents) root.volumeDownTrigger();
97 d.volumeDownKeyPressed = false;
106 d.volumeDownKeyPressed = false;
107+ if (!d.volumeUpKeyPressed) d.ignoreVolumeEvents = false;
98 } else if (event.key == Qt.Key_VolumeUp) {
108 } else if (event.key == Qt.Key_VolumeUp) {
109+ if (!d.ignoreVolumeEvents) root.volumeUpTrigger();
99 d.volumeUpKeyPressed = false;
110 d.volumeUpKeyPressed = false;
111+ if (!d.volumeDownKeyPressed) d.ignoreVolumeEvents = false;
102− return eventAccepted;