Bug 310611 - Missing accelerators in QML lock screen
Summary: Missing accelerators in QML lock screen
Status: RESOLVED FIXED
Alias: None
Product: kscreensaver
Classification: Unmaintained
Component: locker-qml (show other bugs)
Version: 4.9.80 Beta1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-24 16:57 UTC by Elias Probst
Modified: 2013-01-11 14:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screenshot showing accelerator keys on the logout dialog. (53.63 KB, image/png)
2012-11-24 17:15 UTC, Elias Probst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Probst 2012-11-24 16:57:43 UTC
The old non-QML lockscreen had accelerator keys for the buttons of the lockscreen ("Switch User", "Unlock", etc.).

The new QML based lockscreen is missing accelerators in all dialogs.

Please re-add the accelerators before 4.10 final.

Unfortunately I couldn't find any documentation regarding accelerators in QML, even in QML dialogs which render accelerators (e.g. Shutdown dialog) I couldn't find any reference to accelerators in the code.
Comment 1 Martin Flöser 2012-11-24 17:11:26 UTC
AFAIK accelerator keys are not yet supported in QML in general.
Comment 2 Elias Probst 2012-11-24 17:15:37 UTC
Created attachment 75454 [details]
Screenshot showing accelerator keys on the logout dialog.

Isn't the shutdown dialog also QML? There I have accelerator keys (see attached screenshot) and they are working.
Comment 3 Elias Probst 2012-11-24 17:18:09 UTC
(In reply to comment #2)
> Created attachment 75454 [details]
> Screenshot showing accelerator keys on the logout dialog.
> 
> Isn't the shutdown dialog also QML? There I have accelerator keys (see
> attached screenshot) and they are working.

Hmm, now that I looked into the code again, it looks like it is that simple:
/usr/share/apps/ksmserver/themes/default/main.qml:310:
text: i18n("&Restart Computer")
Comment 4 Elias Probst 2012-11-24 17:20:44 UTC
Hmm, and doing this:
text: i18n("&Unlock")
in /usr/share/apps/ksmserver/screenlocker/org.kde.passworddialog/contents/ui/Greeter.qml:125 just results in & being rendered onto the button instead of having it evaluated as accelerator.

Something must be missing…
Comment 5 Elias Probst 2012-11-24 17:24:04 UTC
The logout dialog uses a "KSMButton{}" whereas the greeter of the passworddialog uses a plain "PlasmaComponents.Button{}".

Couldn't find out yet, where KSMButton is defined, but I assume it's a special button derived from PlasmaComponents.Button which handles the accelerators.

Digging deeper now… ;)
Comment 6 Elias Probst 2012-11-24 17:28:42 UTC
Ok, found this snippet in /usr/share/apps/ksmserver/themes/default/main.qml:

        // implement label accelerators in the buttons (the '&' in button's text).
        var buttons = [ logoutButton, shutdownButton, rebootButton, cancelButton ]
        for (var b = 0; b < buttons.length; ++b ) {
            if (buttons[b].accelKey > -1) {
                Helper.buttonForAccel[String.fromCharCode(buttons[b].accelKey)] = buttons[b];
            }
        }
    }

    // trigger action on Alt+'accelerator' key press. For example: if KSMButton.text == &Cancel,
    // pressing Alt+'C' or Alt+'c' will trigger KSMButton.clicked().
    Keys.onPressed: {
        if ((event.modifiers & Qt.AltModifier) && Helper.buttonForAccel[String.fromCharCode(event.key)] != undefined) {
            Helper.buttonForAccel[String.fromCharCode(event.key)].clicked()
        }
    }
Comment 7 Aaron J. Seigo 2013-01-11 14:44:49 UTC
Git commit ca18bf25ff49bfe128078b5fee1d861b6538ebaf by Aaron Seigo.
Committed on 11/01/2013 at 15:43.
Pushed by aseigo into branch 'master'.

hack in keyboard accel for buttons

horribly ugly in implementation, but until QML gets proper key accel handling
this is probably what we stuck with for now

A  +24   -0    ksmserver/screenlocker/greeter/themes/org.kde.passworddialog/contents/ui/AccelButton.qml     [License: UNKNOWN]  *
M  +35   -11   ksmserver/screenlocker/greeter/themes/org.kde.passworddialog/contents/ui/Greeter.qml
M  +27   -6    ksmserver/screenlocker/greeter/themes/org.kde.passworddialog/contents/ui/SessionSwitching.qml
M  +9    -4    ksmserver/screenlocker/greeter/themes/org.kde.passworddialog/contents/ui/main.qml

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


http://commits.kde.org/kde-workspace/ca18bf25ff49bfe128078b5fee1d861b6538ebaf