Workaround fact that Qt 5.5 does not allow shortcuts to be triggered by playing QKeyEvents
ClosedPublic

Authored by sstjames on Jun 15 2016, 3:06 PM.

Details

Reviewers
michalhumpula
dhaumann
Group Reviewers
KTextEditor
Summary

(This patch is based against my other pending patch, https://phabricator.kde.org/D1892)

Annoyingly, in Qt 5.5 we can no longer trigger shortcuts by replaying QKeyEvents (something that the Vi Mode - which stores and swallows all key events by default in case they are part of a Mapping and replays them if it turns out they weren't - depends on), so if we are stealing shortcuts, they will no longer be triggered e.g. pressing Ctrl+S will not save! This patch reworks the whole mechanism, moving from "swallow all QKeyEvents and maybe replay later" to "decide whether to swallow shortcuts, but if not, let Qt's shortcut handling system despatch the QShortcutOverride itself". This mostly fixes things, though we can't e.g. create a mapping that, when triggered, saves the document or triggers any of Kate's shortcuts, plus some other small edge cases :(

BUG:353332

Test Plan

Would be good to get more people manually testing this - in the future, hopefully we'll be able to test via QTestLib.

Diff Detail

Repository
R39 KTextEditor
Lint
Lint Skipped
Unit
Unit Tests Skipped
sstjames updated this revision to Diff 4512.Jun 15 2016, 3:06 PM
sstjames retitled this revision from to Workaround fact that Qt 5.5 does not allow shortcuts to be triggered by playing QKeyEvents.
sstjames updated this object.
sstjames edited the test plan for this revision. (Show Details)
sstjames set the repository for this revision to R39 KTextEditor.
Restricted Application added a subscriber: kwrite-devel. · View Herald TranscriptJun 15 2016, 3:06 PM
dhaumann accepted this revision.Jun 15 2016, 4:21 PM
dhaumann added a reviewer: dhaumann.
dhaumann added a subscriber: dhaumann.

Looks ok to me.
(You can consider using the style if () { ... } else {... where {} are on the same line as if, and else. But no showstopper ;)

This revision is now accepted and ready to land.Jun 15 2016, 4:21 PM
michalhumpula accepted this revision.Jun 16 2016, 5:51 PM
michalhumpula added a reviewer: michalhumpula.
michalhumpula added a subscriber: michalhumpula.

Seems to be working correctly. Compiled, tested (tests and manual) on my computer with Qt5.6.1. One of the vim_keys test is failing, but at least the vi mode is back functioning, so ship it.

Seems to be working correctly. Compiled, tested (tests and manual) on my computer with Qt5.6.1. One of the vim_keys test is failing, but at least the vi mode is back functioning, so ship it.

Thanks for testing :) Which vim_keys test is failing? They seem to all be working here, though I'm using Qt 5.5.1.

Seems to be working correctly. Compiled, tested (tests and manual) on my computer with Qt5.6.1. One of the vim_keys test is failing, but at least the vi mode is back functioning, so ship it.

Thanks for testing :) Which vim_keys test is failing? They seem to all be working here, though I'm using Qt 5.5.1.

It might be just a new bug in Qt5.6 :)

>>> running command  "qa"  on text  ""
FAIL!  : KeysTest::MacroTests() 'kate_view->viewModeHuman().contains(macroIsRecordingStatus)' returned FALSE. ()
   Loc: [/amonsul/kde/ktexteditor/autotests/src/vimode/keys.cpp(707)]
QDEBUG : KeysTest::MarkTests()

Seems to be working correctly. Compiled, tested (tests and manual) on my computer with Qt5.6.1. One of the vim_keys test is failing, but at least the vi mode is back functioning, so ship it.

Thanks for testing :) Which vim_keys test is failing? They seem to all be working here, though I'm using Qt 5.5.1.

It might be just a new bug in Qt5.6 :)

>>> running command  "qa"  on text  ""
 FAIL!  : KeysTest::MacroTests() 'kate_view->viewModeHuman().contains(macroIsRecordingStatus)' returned FALSE. ()
    Loc: [/amonsul/kde/ktexteditor/autotests/src/vimode/keys.cpp(707)]
 QDEBUG : KeysTest::MarkTests()

Thanks Michal - fingers crossed :) Can you manually check whether simple macros appear to work OK (and whether the (recording) appears in the status bar)? I'm a bit concerned that something fundamental has gone wrong here (this is the very first macro test, and the others won't be run if that one fails).

Seems to be working correctly. Compiled, tested (tests and manual) on my computer with Qt5.6.1. One of the vim_keys test is failing, but at least the vi mode is back functioning, so ship it.

Thanks for testing :) Which vim_keys test is failing? They seem to all be working here, though I'm using Qt 5.5.1.

It might be just a new bug in Qt5.6 :)

>>> running command  "qa"  on text  ""
 FAIL!  : KeysTest::MacroTests() 'kate_view->viewModeHuman().contains(macroIsRecordingStatus)' returned FALSE. ()
    Loc: [/amonsul/kde/ktexteditor/autotests/src/vimode/keys.cpp(707)]
 QDEBUG : KeysTest::MarkTests()

Thanks Michal - fingers crossed :) Can you manually check whether simple macros appear to work OK (and whether the (recording) appears in the status bar)? I'm a bit concerned that something fundamental has gone wrong here (this is the very first macro test, and the others won't be run if that one fails).

As far as I can tell, the macro replay doubles every keystroke. For example the sequence qaitest<esc>q@a will yield test\ntteesstt.

sstjames updated this revision to Diff 4590.Jun 17 2016, 12:51 PM
sstjames edited the test plan for this revision. (Show Details)
sstjames edited edge metadata.

UPDATE: Hopefully fix the "replay macro/ last change duplicates characters" bug - no automated test for this yet (for some reason, the tests fail for Michal, but not for me!). Michal - would you mind acting as Guinea Pig again? :)

UPDATE: Hopefully fix the "replay macro/ last change duplicates characters" bug - no automated test for this yet (for some reason, the tests fail for Michal, but not for me!). Michal - would you mind acting as Guinea Pig again? :)

All the tests are passing now. Manual macro test works as expected.

The ui tests in vimode_keys were failing, because the whole thing depends on C locale to pass correctly, which is silly.