Improve keyboard handling for focused buttons in Crop and Reduce Red Eye tools
Summary:
Both Crop and Reduce Red Eye feature a Cancel button.
While normally pressing Enter or Space while a button has
keyboard focus should trigger the button's action, in this case
incorrect actions were executed: Enter accepted the modifications,
i.e. it did the opposite of what the label said, and Space even
jumped to the next image.
For Enter this can be solved by explicitely checking for keyboard
focus, which avoids the underlying problem, i.e. that
ViewMainPage::slotEnterPressed calls *Tool::keyPressEvent before
QDialogButtonBox had a chance to handle the event. For Space
forwarding in ViewMainPage::eventFilter is enough to override the
default shortcut handler, since *Tool::keyPressEvent will implicitely
call event->accept().
Note that this also prevents Space from navigating to the next
image even when the buttons are not focused. We could bring that back,
but it would actually be more consistent if we did not, since the arrow
keys are also blocked when a tool is active. To still navigate away
while a tool is active, users can set a secondary shortcut for
Next to avoid getting in conflict with how Space is supposed
to work on buttons.
FIXED-IN: 18.08.1
Test Plan:
Use ⇥ to focus any of the buttons in the Crop and
Reduce Red Eye tools, and press Enter and Space. Both
shortcuts should trigger the appropriate action, i.e. either OK or
Cancel depending on the button.
Press the same shortcuts while the image is focused. Space should
do nothing, and Enter should accept.
Reviewers: Gwenview, muhlenpfordt
Reviewed By: Gwenview, muhlenpfordt
Subscribers: ngraham, muhlenpfordt
Tags: Gwenview
Differential Revision: https://phabricator.kde.org/D14925