Bug 424890 - Shortcuts not working with german language
Summary: Shortcuts not working with german language
Alias: None
Product: Elisa
Classification: Applications
Component: general (show other bugs)
Version: 20.04.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Matthieu Gallien
Depends on:
Reported: 2020-08-01 11:22 UTC by george fb
Modified: 2022-03-08 23:11 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.04

showcasing the bug, about window opens when shortcut is A, but not when it's Ctrl+A (448.98 KB, video/mp4)
2020-08-01 11:22 UTC, george fb

Note You need to log in before you can comment on or make changes to this bug.
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

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

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

About window DOES NOT open

About window DOES open

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

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

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