Basic QPushButton keyboard shortcut test fails under KDE session

Elvis Stansvik elvstone at gmail.com
Wed May 11 06:20:11 UTC 2016


Hi David,

2016-05-08 19:41 GMT+02:00 David Edmundson <david at davidedmundson.co.uk>:
>
>
> On Sun, May 8, 2016 at 3:10 PM, Bhushan Shah <bhush94 at gmail.com> wrote:
>>
>> On Sunday, May 8, 2016 7:26:32 PM IST, Elvis Stansvik wrote:
>>>
>>> Hitting Ctrl+O would not print "clicked" as expected.
>>>
>>>
>>> But then I tested logging out and into an Openbox session, and it
>>> worked from there. The strange thing is that it works with Qt 4.8.7
>>> under the very same KDE session where it fails with Qt 5.6.0.
>>>
>>> Even stranger is that neither:
>>>
>>>     killall kwin_x11
>>>     openbox &
>>>     ./test
>>>
>>> which I would have thought would give the same result as a logout +
>>> login to Openbox, nor
>>>
>>>     kquitapp5 plasmashell
>>>     ./test
>>>
>>> works, if I do that in the running KDE session. So there must be some
>>> other KDE process I'm unaware of which intercepts the shortcut.
>>>
>>> I'm now unsure whether the problem is with Qt 5.6.0, with some
>>> KDE/Plasma component, or somehow with both.
>>>
>>> Would appreciate a lot if someone could check and see if they can
>>> reproduce.
>>>
>>
>> Given I debugged this earlier and can't think of any nicer solution, would
>> be useful for you..
>>
>> This comes from
>> kde:plasma-integration/src/platformtheme/kdeplatformtheme.cpp
>>
>> QList<QKeySequence>
>> KdePlatformTheme::keyBindings(QKeySequence::StandardKey key) const
>>
>
> It's nothing to do with the KdePlatformTheme stuff or the standard keys in
> system settings, that only affects shortcuts using QStandardKeys.
>
> This is caused by the KAcceleratorManager from KWidgetAddons [1]
>
> It's the bug/feature which means we see & signs all over QtCreator.
>
> We have a class that watches for widgets and makes sure they all have a
> valid accelerator. It's a clever manager with a complex in-built weighting
> system.
>
> Your push button doesn't have an accelerator so we automatically add one.
> In adding an accelerator, QPushButton changes the shortcut[2]. Hence yours
> doesn't work.
>
> If you change your code to:
>  button = new PushButton("Click &me (crtl+o))"
>  button->setShortcut(QString("Ctrl+O"));
>
> control+o will work
> (but alt+m won't as it should)
>
> The main code of this is kwidgetaddons/kacceleratormanager . Though I think
> this is loaded from KXmlGui which starts tracking things with a
> Q_COREAPP_STARTUP_FUNCTION in kcheckaccelerators - so simply linking the
> library launches this tracking.
>
> The reason this bug is newly affecting Qt apps in Qt5 but not before is
> because of the QPT we're now linking against this library from every Qt app.
> Whereas previously it only affected those that linked it explicitly.

Thanks a lot for the thorough analysis, now I know what is happening.

>
> One could argue that we shouldn't be messing with other widgets, but equally
> I think we can argue that Qt should use two shortcuts for setShortcut and
> the one from the accelerator as any translation file could introduce a
> mnemonic, which would also break your shortcut in exactly the same way.

Yes, I would be fine if it only affected KDE apps, but I don't think
plain Qt apps should be affected.

So consider me sceptical to the way it now affects everything :)

Elvis

>
> David
>
> [1] https://paste.kde.org/pxscewbyt
> [2] https://paste.kde.org/pylds2vth
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>


More information about the Plasma-devel mailing list