KSelectAction

Hamish Rodda rodda at kde.org
Wed Jul 26 09:42:33 BST 2006


On Friday 21 July 2006 18:10, Clarence Dang wrote:
> On Wednesday 19 July 2006 16:11, Stephan Kulow wrote:
> > Am Dienstag, 18. Juli 2006 15:45 schrieb Clarence Dang:
> > > 3. currentText() returns "&MyString" (i.e. it adds the accelerator)
> > > instead of "MyString" (where "MyString" is passed to setItems()).  This
> > > is unexpected and a subtle change from KDE 3.
> >
> > The accelerators are added most likely by kcheckaccelerator
>
> yep, KApplication -> KCheckAccelerator -> KAcceleratorManager ->
> KPopupAccelManager
>
> This behaviour appears to be a global KAction bug/feature, not limited to
> KSelectAction.  text() returns what you passed to setText() or the KAction
> ctors, but with an extra accelerator.  This is due to increased coupling of
> actions with the GUI:
>
> KDE 4 sets the action's text to have an accelerator:
> void KPopupAccelManager::setMenuEntries(const KAccelStringList &list)
> {
>   QAction *maction;
> [...]
>   maction->setText(list[cnt].accelerated());
>
> KDE 3 does not act on the action's text directly:
> void KPopupAccelManager::setMenuEntries(const KAccelStringList &list)
> {
>   QMenuItem *mitem;
> [...]
>   mitem->setText(list[cnt].accelerated());
>
> I'm not sure whether the new behaviour makes sense.  Probably not though as
> text() and setText() should be "symmetric"?

Firstly, KAction doesn't change QAction's handling of text()/setText(), so 
we're really talking about QAction (and the consequences of porting to it).

Secondly, if you read the QAction docs you will see that text()/setText() is 
symmetric... the only trick is that text passed to the constructor will have 
processing applied (ampersands removed and accelerator applied), whereas text 
passed to setText() will not.  This means we need to port calls to setText() 
(don't set ampersands, use the shortcut instead); I'll add it to 
KDE4PORTING.html.

As a side note, I also take issue with the usability of accelerator managers - 
they produce inconsistent results especially with dynamic GUIs - and think 
that instead we should be using "type what you see to select" behaviour, such 
as that provided by KMenu::setKeyboardShortcutsEnabled() (and also, I am lead 
to believe, similar functionality is present in Qt 4.2 (and enabled by 
default for all menus for Qt on Mac OS)).

Cheers,
Hamish.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060726/a5bbd794/attachment.sig>


More information about the kde-core-devel mailing list