# class KGlobalAccel | The KGlobalAccel class handles global keyboard accelerators, allowing a user to configure key bindings through application configuration files or through the KKeyChooser GUI. More...
Definition | `#include <kglobalaccel.h>`
Inherits | QObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- KGlobalAccel ( bool _do_not_grab = false)
- KGlobalAccel (QWidget * parent, const char *name = 0, bool _do_not_grab = false)
- ~KGlobalAccel ()
- void clear ()
- void connectItem ( const QString& action, const QObject* receiver, const char *member, bool activate = true )
- uint count () const
- int currentKey ( const QString& action ) const
- int defaultKey ( const QString& action) const
- void disconnectItem ( const QString& action, const QObject* receiver, const char *member )
- QString findKey ( int key ) const
- bool grabKey (uint keysym, uint mod)
- bool insertItem ( const QString& descr, const QString& action, int defaultKeyCode, bool configurable = true )
- bool insertItem ( const QString& descr, const QString& action, const QString& defaultKeyCode, bool configurable = true )
- bool isEnabled () const
- bool isItemEnabled ( const QString& action ) const
- KKeyEntryMap keyDict () const
- void readSettings ()
- void removeItem ( const QString& action )
- void setConfigGroup ( const QString& group )
- QString configGroup () const
- void setEnabled ( bool activate )
- void setItemEnabled ( const QString& action, bool activate )
- bool setKeyDict ( const KKeyEntryMap& nKeyMap )
- bool ungrabKey (uint keysym, uint mod)
- void writeSettings () const
- bool x11EventFilter (const XEvent *)

#### Signals

- void activated ()

#### Protected Members

- int aAvailableId
- KKeyEntryMap aKeyMap
- bool bEnabled
- QString aGroup
- bool do_not_grab
- KGlobalAccelPrivate* d

## Detailed Description

The KGlobalAccel class handles global keyboard accelerators, allowing a user to configure key bindings through application configuration files or through the KKeyChooser GUI.

A KGlobalAccel contains a list of accelerator items. Each accelerator item consists of an action name and a keyboard code combined with modifiers (SHIFT, CTRL and ALT.)

For example, "CTRL+SHIFT+M" could be a shortcut for popping-up a menu of monitor setting choices anywhere on the desktop. The key codes are listed in kckey.cpp. "Monitor settings" could be the action name for this accelerator. The action name indentifies the key binding in configuration files and the KKeyChooser GUI.

When pressed,an accelerator key calls the slot to which it has been connected. Accelerator items can be connected so that a key will activate two different slots.

Key binding configuration during run time can be prevented by specifying that an accelerator item is not configurable when it is inserted.

It is possible for a user to choose to have no key associated with an action.

The translated first argument for insertItem is only used in the configuration dialog.

...

ga = new KGlobalAccel(); ga->insertItem( i18n("Monitor settings"), "Monitor settings", "CTRL+SHIFT+M" ); ga->connectItem( "Monitor settings", myObject, SLOT( popupMenu() ) );

ga->readSettings();

KGlobalAccel ( bool _do_not_grab = false) | ### KGlobalAccel

Creates a KGlobalAccel object.

KGlobalAccel (QWidget * parent, const char *name = 0, bool _do_not_grab = false) | ### KGlobalAccel

Creates a KGlobalAccel object with a parent and a name. The parent has the only effect that the KGlobalAccel object will be automatically destroyed in the parent's destructor, thus releaseing the keys.

~KGlobalAccel () | ### ~KGlobalAccel

Destroys the accelerator object.and ungrabs any allocated key bindings.

void clear () | ### clear

Removes all accelerator items.

void connectItem ( const QString& action, const QObject* receiver, const char *member, bool activate = true ) | ### connectItem

Connect an accelerator item to a slot/signal in another object.

Arguments:

Parameters:

action | is the accelerator item action name.
receiver | is the object to receive a signal
member | is a slot or signal in the receiver
activate | indicates whether the accelrator item should be enabled immediately

uint count () | ### count

[const]

Returns the number of accelerator items.

int currentKey ( const QString& action ) | ### currentKey

[const]

Returns the key code of the accelerator item with the action name action, or zero if either the action name cannot be found or the current key is set to no key.

int defaultKey ( const QString& action) | ### defaultKey

[const]

Returns the default key code of the accelerator item with the action name action, or zero if the action name cannot be found.

void disconnectItem ( const QString& action, const QObject* receiver, const char *member ) | ### disconnectItem

Disconnects an accelerator item from a function in another object.

QString findKey ( int key ) | ### findKey

[const]

Returns that identifier of the accelerator item with the keycode key, or zero if the item cannot be found.

bool grabKey (uint keysym, uint mod) | ### grabKey

Attempts to make a passive X server grab of the key specified by key symbol keysym and modifier mod. Returns false if unsuccessful.

Modifications with num lock and caps lock are also grabbed.

bool insertItem ( const QString& descr, const QString& action, int defaultKeyCode, bool configurable = true ) | ### insertItem

Inserts an accelerator item and returns false if the key code defaultKeyCode is not valid.

Arguments:

If an action already exists the old association and connections will be removed..

Parameters:

action | is the accelerator item action name.
defaultKeyCode | is a key code to be used as the default for the action.
configurable | indicates whether a user can configure the key binding using the KKeyChooser GUI and whether the key will be written back to configuration files on calling writeSettings.

bool insertItem ( const QString& descr, const QString& action, const QString& defaultKeyCode, bool configurable = true ) | ### insertItem

Inserts an accelerator item and returns false if the key code defaultKeyCode is not valid.

Arguments:

If an action already exists the old association and connections will be removed..

Parameters:

action | is the accelerator item action name.
defaultKeyCode | is a key plus a combination of SHIFT, CTRL and ALT to be used as the default for the action.
configurable | indicates whether a user can configure the key binding using the KKeyChooser GUI and whether the key will be written back to configuration files on calling writeSettings.

bool isEnabled () | ### isEnabled

[const]

bool isItemEnabled ( const QString& action ) | ### isItemEnabled

[const]

KKeyEntryMap keyDict () | ### keyDict

[const]

Returns the dictionary of accelerator action names and KKeyEntry objects. Note that only a shallow copy is returned so that items will be lost when the KKeyEntry objects are deleted.

void readSettings () | ### readSettings

Reads all key associations from the application's configuration files.

void removeItem ( const QString& action ) | ### removeItem

Removes the accelerator item with the action name action.

void setConfigGroup ( const QString& group ) | ### setConfigGroup

QString configGroup () | ### configGroup

[const]

void setEnabled ( bool activate ) | ### setEnabled

Enables the accelerator if activate is true, or disables it if activate is false...

Individual keys can also be enabled or disabled.

void setItemEnabled ( const QString& action, bool activate ) | ### setItemEnabled

Enables or disables an accelerator item.

Arguments:

Parameters:

action | is the accelerator item action name.
activate | specifies whether the item should be enabled or disabled.

bool setKeyDict ( const KKeyEntryMap& nKeyMap ) | ### setKeyDict

Sets the dictionary of accelerator action names and KKeyEntry objects to nKeyMap. Note that only a shallow copy is made so that items will be lost when the KKeyEntry objects are deleted.

bool ungrabKey (uint keysym, uint mod) | ### ungrabKey

Ungrabs the key specified by key symbol keysym and modifier mod. Returns false if unsuccessful.

Modifications with num lock and caps lock are also ungrabbed.

void writeSettings () | ### writeSettings

[const]

Writes the current configurable associations to the application's configuration files

bool x11EventFilter (const XEvent *) | ### x11EventFilter

Filters X11 events ev for key bindings in the accelerator dictionary. If a match is found the activated activated is emitted and the function returns true. Return false if the event is not processed.

This is public for compatibility only. You do not need to call it.

void activated () | ### activated

[signal]

int aAvailableId | ### aAvailableId

[protected]

KKeyEntryMap aKeyMap | ### aKeyMap

[protected]

bool bEnabled | ### bEnabled

[protected]

QString aGroup | ### aGroup

[protected]

bool do_not_grab | ### do_not_grab

[protected]

KGlobalAccelPrivate* d | ### d

[protected]

Generated by: root@sparc.ports.openbsd.org on Wed May 2 09:34:58 2001, using kdoc 2.0a53.