kcmoduleqml: simplify and improve focus handling
This is an alternative to !250 (closed) that works better and handles more cases. It's a massive improvement in keyboard user experience and accessibility support in my eyes.
kcmoduleqml contains some old tricks to make passing focus between the qml and qtwidgets bits, but they are fragile, and break in many cases - especially with systemsettings adding another layer of qml. The hacks may have been necessary in the past, but things actually work well now, so we can essentially just set a focusProxy and be done ... as long as we don't care about accessibility. The qml bits receive focus before the widgets parts fully hand it over, so the first qml item receiving focus will not be announced over screen readers. We do care though, and thus some special handling is still needed.
We switch to using focusProxy, and add a bit of surgery to the focus transition so that screen readers always stay in the loop about what things are focused. We also need a bit of special handling for the backtab case, which doesn't quite work automatically with activeFocusOnTab set on the qml root.
As before, the experience in systemsettings is best when paired with plasma/systemsettings!346 (merged) but it should still work and be a clear improvement without it (didn't do much testing though).
In my testing I didn't notice any obvious regressions. Not all is optimal yet:
-
focus can get stuck on an invisible sidebar page when backtabbing out of kcm_landingpage (and potentially other kcms where no dialog buttons are active). This is a systemsettings issue and can be fixed by not having invisible pages take focus.Fixed with plasma/systemsettings!349 (merged) - kcm_touchpad still works rather badly. This kcm is actually qtwidgets that loads its qml manually instead of using kcmoduleqml (and should probably just be changed to use it instead, see plasma/plasma-desktop!2770 (merged)
- While the readout of accessibility metadata is much better now (and with fewer LayeredPane announcements), it's still very much improvable. In particular, orca seems to consider switching to a new qml element leaving and reentering the window, which causes way too much information to be read out each time. This is a pre-existing issue though, just not fixed by this patch (as I naively hoped at one point). [ETA] I think I know why and this is likely a Qt bug (it reports two things as focused simulataneously to atspi), but will need to spend some more time properly isolating things before I report it.
- backtabbing through systemsettings never hits the sidebar listview (only hamburger and search field), tabbing is the other way around. Likely a systemsettings issue and preexisting (if it worked at all). Similarly, for kcm_landingpage and some other kcms not in a subcategory, backtabbing from the sidebar ends in a short loop; pre-existing and I suspect also a systemsettings issue.