Automatically Generated Keyboard Accelerators (replacing kaccelgen.h)

Mark Summerfield mark at qtrac.eu
Fri Jun 13 08:20:15 BST 2008


On 2008-06-12, David Faure wrote:
> On Tuesday 10 June 2008, Chusslove Illich wrote:
> > Regardless, I'm more worried by the fact that lxr.kde.org reports
> > KAccelGen to be used only in one place, in Konqueror, and that whatever
> > *really* assigns accelerators (Qt?) completely ignores non-Latin
> > characters, thus leaving e.g. my Cyrillic menu items unaccelerated.
>
> Yes!! This is a very important issue that has been overlooked completely in
> this thread. Mark, I'm very happy that you want to improve kaccelgen.h, but
> I don't think that's the code you wanted to touch in the first place, if
> you were aiming at better default accelerators in KDE.
> KAccelGen is indeed very little used, it was added for apps which want to
> generate accelerators from a list of dynamic strings, before the much more
> general idea of all accelerators in all widgets being handled automatically
> by KDE was implemented: that's what KAcceleratorManager does
> (kdelibs/kdeui/shortcuts/kacceleratormanager.cpp).
>
> One solution would be to port KAcceleratorManager to KAccelGen, to benefit
> from this improved logic, if that makes sense. However I see that
> KAcceleratorManager uses the additional notion of weight, to give priority
> to some widgets over others, e.g. in case you run out of accelerators (or
> in case of conflicts, I guess? I don't know this code).
>
> Another solution would be to get rid of KAccelGen (which doesn't make sense
> from an API point of view -- apps don't need to do anything to get accels,
> with KAcceleratorManager, so the public API of KAccelGen is useless), and
> improve KAcceleratorManager's algorithm.
>
>
> ==> I think this shows that compiling kdelibs and testing your changes is
> essential; one can't just change code and unit test it and calculate its
> performance, it's very important to check that the code ends up doing what
> we wanted it to do, which includes among other things that the code must be
> called in the first place!

It was never my intention to do any KDE development, and as I mentioned
early on, I am not familiar with the KDE libraries.

I just wanted to let KDE developers know about my GUI Accelerator
program that can be used to create optimal accelerators.

I've had a quick look at kacceleratormanager.cpp, and although it uses
weights it is far from optimal (as its docs make clear). However, if the
implementation of

void KAccelManagerAlgorithm::findAccelerators(KAccelStringList &result, 
QString &used)

was replaced with my function (with "result" being my list_of_strings
and "used" being my alphabet, and using a fixed depth of 6000) you
should get much better results.

Unfortunately I don't have the time to pursue this: I had some free time
this week and last week but now I have to get back to my paid work.

-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu





More information about the kde-core-devel mailing list