Bug 424890

Summary: Shortcuts not working with german language
Product: [Applications] Elisa Reporter: george fb <georgefb899>
Component: generalAssignee: Matthieu Gallien <matthieu_gallien>
Status: RESOLVED FIXED    
Severity: normal CC: freggel.doe, nate
Priority: NOR    
Version: 20.04.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 22.04
Attachments: showcasing the bug, about window opens when shortcut is A, but not when it's Ctrl+A

Description george fb 2020-08-01 11:22:48 UTC
Created attachment 130549 [details]
showcasing the bug, about window opens when shortcut is A, but not when it's Ctrl+A

SUMMARY
Some shortcuts do not work if language is not english, tested with german.

STEPS TO REPRODUCE
1. Set language to german
2. Open elisa shorcuts editor
3. Set "About Elisa" action shortcut to Ctrl+A
4. Press Ctrl+A

OBSERVED RESULT
About window DOES NOT open

EXPECTED RESULT
About window DOES open

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20200730
KDE Plasma Version: 5.19.4
KDE Frameworks Version: 5.72.0
Qt Version: 5.15.0
Kernel Version: 5.7.9-1-default
Elisa Version 20.4.3

ADDITIONAL INFORMATION
I think this is because QAction shortcuts can be translated, ctrl, shift, left, page up etc.
But the QML Action doesn't know how to handle the translated shortcut,
which is what the shortcut property is set to
https://invent.kde.org/multimedia/elisa/-/blob/master/src/qml/ApplicationMenu.qml#L85

A "fix" would be to get the untranslated shortcut and use that for the qml action shortcut,
either by subclassing or as is done with the icon.
The downside is that when using a non english language the shortcuts in menus will be in english.
Comment 1 Bug Janitor Service 2022-03-06 23:58:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/multimedia/elisa/-/merge_requests/336
Comment 2 Nate Graham 2022-03-08 23:09:52 UTC
Git commit fd858caf0e780f74275c56f4083517ef9e8056b4 by Nate Graham, on behalf of Olivier Trichet.
Committed on 08/03/2022 at 23:08.
Pushed by ngraham into branch 'master'.

Fix shortcut not working under non English locale

This change wraps calls to QAction::shortcut() done in QML files
to use the portable representation of QKeySequence.

The QKeySequence to QVariant operator return a string
representation using the native format not the portable format.
E.g., the sequence "Space", will be "Espace" under French locale.
The 'shortcut' attribute of QtQuick Action is stored as QVariant.
In qml file, when the QAction::shortcut() value (a QKeySequence)
is affected to a QtQuick Action shortcut, the previous operator is
used and the shortcut value may be bogus depending on translation.

    // A QAction* with the Qt::Key_Space shortcut
    property var playPauseAction: ElisaApplication.action("Play-Pause")
    Action {
        // - playPauseAction.shortcut returns QKeySequence(Qt::Key_Space).
        // - QKeySequence(Qt::Key_Space) is transform into a QVariant that
        //        contains native text "Espace".
        // - this QVariant is affected to shortcut: broken.
        shortcut: playPauseAction.shortcut
        onTriggered: ElisaApplication.audioControl.playPause()
    }
Related: bug 410110

M  +6    -0    src/elisaapplication.cpp
M  +1    -0    src/elisaapplication.h
M  +6    -6    src/qml/ApplicationMenu.qml
M  +8    -8    src/qml/ElisaMainWindow.qml
M  +1    -1    src/qml/MediaPlayerControl.qml
M  +1    -1    src/qml/NativeMenuItemFromAction.qml
M  +7    -7    src/qml/NativeTrayMenu.qml

https://invent.kde.org/multimedia/elisa/commit/fd858caf0e780f74275c56f4083517ef9e8056b4