Skip to content

QKeySequence: Add missing modifier names

Aleix Pol Gonzalez requested to merge apol/qtbase:work/shortcuts into kde/5.15

The issue is that when someone is trying to use the following code:

QKeySequence keySequence(Qt::Key_Shift); qDebug() << keySequence.toString();

This will print seemingly gibberish output. It is unicode in practice. For Qt::Key_Shift, this would be: "�_@\uDC20"

The reason why this is happening is because we have platform-specific ways to handle this due to Mac glyphs which are not available on Linux or Windows. This works fine on Mac.

But for the Linux and Windows codepaths, there is not really any mapping like for other keys. It seems that modifiers were left out.

The solution is to simply amend the list of mapping from these modifier key codes to raw strings for Linux and Windows like it is done for other key codes. So, now, modifiers will also be included in the list.

So, the expected output will be generated for the above code, as: "Shift".

[ChangeLog][QtGui][QKeySequence] Added missing modifier names

Fixes: QTBUG-69715 Fixes: QTBUG-40030 Change-Id: I460d54bc8e593b350ff95894f23c5b4a7c819a44 Reviewed-by: Volker Hilsheimer (cherry picked from commit d8344134)

It can be seen as soon as you start using KGlobalAccel with modifier-only shortcuts (e.g. "Shift"). It's a bit meh because it adds translatable strings, but it's always better to read "Shift" than "�_@\uDC20", IMO.

Merge request reports