KGlobalAccel Problems

Martin Gräßlin mgraesslin at kde.org
Fri Jun 20 08:13:38 UTC 2014


On Thursday 19 June 2014 19:26:45 Vishesh Handa wrote:
> Hey guys
> 
> I've been looking into kglobalaccel in order to fix some problems that I
> was having. I seems to have opened a can of worms.
> 
> Background Information: KGlobalAccel has 2 kinds of shortcuts - Active
> Shortcuts and Default Shortcuts. Active Shortcuts are the ones currently in
> use, whereas the default ones are just the ones which an application
> recommends that should be the default. Setting this default shortcut just
> results in it being written to a configuration file.
> 
> In the KDE4 days you would set a global shortcut via
> KShortcut::setGlobalShortcut(KShortcut, flags). The flags over here were by
> (Default | Active), so most of the applications would just set it as both
> the default and the active one. Everything was nice and simple.
> 
> Now, stuff that has changed -
> 1. The API has an explicit setDefaultShortcut and setShortcut command. This
> is bad because setting the deafult shortcut does not set the active one and
> vice versa. This means applications need to call both. No application
> currently does this.
> 
> 2. We allow multiple global shortcuts per application - This is awesome,
> cause it is super useful, but it also results in -
> * The KCM only showing one shortcut. And when you change that shortcut,
> then all the others are cleared.
> *  Having different lists of default and normal shortcuts results in the
> KCM flaking out and not showing the active shortcut properly. I've been
> trying to diagnose this, but haven't been successful. I'll try again
> tomorrow.
> 
> How do we go about fixing this? Options -
> 
> a.) Set the active shortcut whenever you set the default shortcut. This is
> a good compromise, but it also means that any successive call to
> setShortcut(..) will not do anything cause the shortcut has already been
> set.
> 
> Certain application such as KRunner which set one default shortcut, and
> multiple active shortcuts would break, and need to be fixed. (Which is
> fine, it's just what happens).
> 
> We should probably also add some documentation regarding this.
> 
> b.) Let stuff remain the way it is and add extra documentation. This would
> mean we would need to update every app using KGlobalAccel and make them set
> both the default and the active shortcut.
> 
> c.) Introduce the concept of flags in setShortcut where the default is
> active + default. This would make it similar to how it was in kdelibs4. The
> whole active + default thing is still confusing though and we would need
> better documentation.

I lean more towards c) with a simplified:

static KGlobalAccel::setGlobalShortcuts(QList<QKeySequence>, flags = Active | 
Default);
static KGlobalAccel::setGlobalShortcut(QKeySequence, flags = Active | 
Default);

I find the API difficult to use and wouldn't mind having a simplified version 
especially for the case that there is only one shortcut. Maybe one could even 
leave out the flags - if one wants to have more control, the more explicit API 
should be used.

> 
> ---
> 
> Fixing (2) - I like having multiple default shortcuts available, so I
> suppose we need to update the KCM? This means fixing up KShortcutEditor
> from kxmlgui. The code there is a little ambiguous, so I'm not looking
> forward to that. Also, not sure how it would look visually.

yeah, we probably want to fix it to support multiple shortcuts.

Cheers
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140620/4799de4e/attachment.sig>


More information about the Kde-frameworks-devel mailing list