experimental support for auto mnemonics
ClosedPublic

Authored by mart on Nov 15 2017, 5:13 PM.

Details

Summary

use auto mnemonics for common widgets as buttons,
checkboxes and tabs
A feature similar to KXMLGui apps

Test Plan

tested in kirigami gallery

Diff Detail

Repository
R858 Qt Quick Controls 2: Desktop Style
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mart created this revision.Nov 15 2017, 5:13 PM
Restricted Application added a project: Plasma. · View Herald TranscriptNov 15 2017, 5:13 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik added inline comments.
org.kde.desktop/Button.qml
43

How does it behave if text contains an && ie. user explicitly wants an ampersand but not a mnemonic?

plugin/kquickstyleitem.cpp
1636

Check watched == m_window?

1637

You could just check KeyPress || KeyRelease since you're doing the same thing in both branches

broulik added inline comments.Nov 15 2017, 5:42 PM
org.kde.desktop/ToolButton.qml
36

Btw probably

Qt.styleHints.hasOwnProperty("useHoverEffects") ? Qt.styleHints.useHoverEffects : true
mart added inline comments.Nov 15 2017, 5:50 PM
org.kde.desktop/Button.qml
43

hm, yeah, will be terrible :/

mart added inline comments.Nov 15 2017, 6:27 PM
org.kde.desktop/Button.qml
43

eww, even worse, in Qt 5.10 the mnemonics are removed in setText so is impossible to know what the original text was /o\

mart added inline comments.Nov 15 2017, 6:31 PM
org.kde.desktop/Button.qml
43

which, they noticed it was terrible and reverted in Qt 5.11, but 5.10 is still meh, so the best i can do is to do something that fully correctly works only on 5.11 :/

mart updated this revision to Diff 22409.Nov 15 2017, 6:40 PM
  • && means we want & and not a mnemonic
hein added a subscriber: hein.Nov 27 2017, 2:32 PM

How heavy will be all these Shortcut instances? Is that a lot of QObjects?

Otherwise it looks pretty good.

mart added a comment.Nov 28 2017, 10:50 AM
In D8827#172520, @hein wrote:

How heavy will be all these Shortcut instances? Is that a lot of QObjects?

Otherwise it looks pretty good.

yeah, it's many qobjects, but there aren't other ways to do shortcuts without it (the way to directly do shortcuts even in c++ it's completely private api)

hein added a comment.Nov 28 2017, 10:54 AM

yeah, it's many qobjects, but there aren't other ways to do shortcuts without it (the way to directly do shortcuts even in c++ it's completely private api)

Not even event filtering or something?

broulik added a comment.EditedNov 29 2017, 1:26 PM

A shortcut is registered by the Shortcut item by doing

QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, shortcut.keySequence, context, *ctxMatcher());

QShortcut is in widgets and also another QObject. I don't see a way to do that using public API. QShortcutMap is in gui and exported but marked "internal".
We could have a global Shortcut that registers everythign and propagates it along but that would make things utterly complicated and ugly.

mart updated this revision to Diff 28926.Mar 7 2018, 12:55 PM
  • Merge branch 'master' into arcpatch-D8827
  • better shortcut management for MenuItem
mart updated this revision to Diff 28954.Mar 7 2018, 4:41 PM
  • kirigami 2.3 needed
apol added a subscriber: apol.Mar 7 2018, 5:23 PM

Big +1, missed it earlier.

Won't upstream QQC2 come up with something in this regard?

This revision was not accepted when it landed; it landed in state Needs Review.Mar 27 2018, 11:07 AM
This revision was automatically updated to reflect the committed changes.
ratijas added inline comments.
org.kde.desktop/Button.qml
43

So, it has landed, and it is still broken with respect to &&. I filed a bug report about it: https://bugs.kde.org/show_bug.cgi?id=454778