KAccel Class Reference
Handle shortcuts. Configurable shortcut support for widgets. More...
#include <kaccel.h>
Inheritance diagram for KAccel:


Signals | |
void | keycodeChanged () |
Public Member Functions | |
KAccel (QWidget *pParent, const char *psName=0) | |
KAccel (QWidget *watch, QObject *parent, const char *psName=0) | |
KAccelActions & | actions () |
const KAccelActions & | actions () const |
bool | isEnabled () |
void | setEnabled (bool bEnabled) |
bool | setAutoUpdate (bool bAuto) |
KAccelAction * | insert (const QString &sAction, const QString &sLabel, const QString &sWhatsThis, const KShortcut &cutDef, const QObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true) |
KAccelAction * | insert (const QString &sAction, const QString &sLabel, const QString &sWhatsThis, const KShortcut &cutDef3, const KShortcut &cutDef4, const QObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true) |
KAccelAction * | insert (const char *psAction, const KShortcut &cutDef, const QObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true) |
KAccelAction * | insert (KStdAccel::StdAccel id, const QObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true) |
bool | remove (const QString &sAction) |
bool | updateConnections () |
const KShortcut & | shortcut (const QString &sAction) const |
bool | setShortcut (const QString &sAction, const KShortcut &shortcut) |
bool | setSlot (const QString &sAction, const QObject *pObjSlot, const char *psMethodSlot) |
bool | setEnabled (const QString &sAction, bool bEnabled) |
const QString & | configGroup () const |
void | setConfigGroup (const QString &name) |
bool | readSettings (KConfigBase *pConfig=0) |
bool | writeSettings (KConfigBase *pConfig=0) const |
void | emitKeycodeChanged () |
bool | insertItem (const QString &sLabel, const QString &sAction, const char *psKey, int nIDMenu=0, QPopupMenu *pMenu=0, bool bConfigurable=true) KDE_DEPRECATED |
bool | insertItem (const QString &sLabel, const QString &sAction, int key, int nIDMenu=0, QPopupMenu *pMenu=0, bool bConfigurable=true) KDE_DEPRECATED |
bool | insertStdItem (KStdAccel::StdAccel id, const QString &descr=QString::null) KDE_DEPRECATED |
bool | connectItem (const QString &sAction, const QObject *pObjSlot, const char *psMethodSlot, bool bActivate=true) KDE_DEPRECATED |
KDE_DEPRECATED bool | connectItem (KStdAccel::StdAccel accel, const QObject *pObjSlot, const char *psMethodSlot) |
bool | removeItem (const QString &sAction) KDE_DEPRECATED |
bool | setItemEnabled (const QString &sAction, bool bEnable) KDE_DEPRECATED |
void | changeMenuAccel (QPopupMenu *menu, int id, const QString &action) KDE_DEPRECATED |
void | changeMenuAccel (QPopupMenu *menu, int id, KStdAccel::StdAccel accel) KDE_DEPRECATED |
int | currentKey (const QString &action) const KDE_DEPRECATED |
QString | findKey (int key) const KDE_DEPRECATED |
Static Public Member Functions | |
int | stringToKey (const QString &) KDE_DEPRECATED |
Protected Member Functions | |
virtual void | virtual_hook (int id, void *data) |
Detailed Description
Handle shortcuts. Configurable shortcut support for widgets.Allow a user to configure shortcuts through application configuration files or through the KKeyChooser GUI.
A KAccel contains a list of accelerator actions.
For example, CTRL+Key_P could be a shortcut for printing a document. The key codes are listed in qnamespace.h. "Print" could be the action name for printing. The action name identifies the shortcut in configuration files and the KKeyChooser GUI.
A KAccel object handles key events sent to its parent widget and to all children of this parent widget. The most recently created KAccel object has precedence over any KAccel objects created before it. When a shortcut pressed, KAccel calls the slot to which it has been connected. If you want to set global accelerators, independent of the window which has the focus, use KGlobalAccel.
Reconfiguration of a given shortcut can be prevented by specifying that an accelerator item is not configurable when it is inserted. A special group of non-configurable key bindings are known as the standard accelerators.
The standard accelerators appear repeatedly in applications for standard document actions such as printing and saving. A convenience method is available to insert and connect these accelerators which are configurable on a desktop-wide basis.
It is possible for a user to choose to have no key associated with an action.
The translated first argument for insertItem() is used only in the configuration dialog.
KAccel* pAccel = new KAccel( this ); // Insert an action "Scroll Up" which is associated with the "Up" key: pAccel->insert( "Scroll Up", i18n("Scroll up"), i18n("Scroll up the current document by one line."), Qt::Key_Up, this, SLOT(slotScrollUp()) ); // Insert an standard acclerator action. pAccel->insert( KStdAccel::Print, this, SLOT(slotPrint()) ); // Update the shortcuts by read any user-defined settings from the // application's config file. pAccel->readSettings(); *
Definition at line 93 of file kaccel.h.
Constructor & Destructor Documentation
|
Creates a new KAccel that watches
Definition at line 373 of file kaccel.cpp. References endl(), and KAccel(). Referenced by KAccel(). |
|
Creates a new KAccel that watches
Definition at line 380 of file kaccel.cpp. |
Member Function Documentation
|
Checks whether the KAccel is active.
Definition at line 397 of file kaccel.cpp. |
|
Enables or disables the KAccel.
Definition at line 398 of file kaccel.cpp. References setEnabled(). Referenced by setEnabled(), and setItemEnabled(). |
|
Enable auto-update of connections. This means that the signals are automatically disconnected when you disable an action, and re-enabled when you enable it. By default auto update is turned on. If you disable auto-update, you need to call updateConnections() after changing actions.
Definition at line 399 of file kaccel.cpp. References setAutoUpdate(). Referenced by setAutoUpdate(). |
|
Create an accelerator action. Usage:
Definition at line 401 of file kaccel.cpp. References insert(). Referenced by insert(). |
|
Same as first insert(), but with separate shortcuts defined for 3- and 4- modifier defaults.
Definition at line 412 of file kaccel.cpp. References insert(). |
|
This is an overloaded function provided for convenience. The advantage of this is when you want to use the same text for the name of the action as for the user-visible label. Usage:
Definition at line 423 of file kaccel.cpp. References insert(). |
|
Similar to the first insert() method, but with the action name, short description, help text, and default shortcuts all set according to one of the standard accelerators.
Definition at line 433 of file kaccel.cpp. References insert(), and KStdAccel::name(). |
|
Removes the accelerator action identified by the name. Remember to also call updateConnections().
Definition at line 451 of file kaccel.cpp. References remove(). Referenced by remove(). |
|
Updates the connections of the accelerations after changing them. This is only necessary if you have disabled auto updates which are on by default.
Definition at line 453 of file kaccel.cpp. |
|
Return the shortcut associated with the action named by
Definition at line 456 of file kaccel.cpp. References KShortcut::null(), and shortcut(). Referenced by shortcut(). |
|
Set the shortcut to be associated with the action named by
Definition at line 468 of file kaccel.cpp. References endl(), and setShortcut(). Referenced by setShortcut(). |
|
Set the slot to be called when the shortcut of the action named by
Definition at line 462 of file kaccel.cpp. References setSlot(). Referenced by connectItem(), and setSlot(). |
|
Enable or disable the action named by
Definition at line 465 of file kaccel.cpp. References setEnabled(). |
|
Returns the configuration group of the settings.
Definition at line 480 of file kaccel.cpp. Referenced by KAccelShortcutList::KAccelShortcutList(). |
|
Returns the configuration group of the settings.
Definition at line 483 of file kaccel.cpp. References setConfigGroup(). Referenced by setConfigGroup(). |
|
Read all shortcuts from The group in which the configuration is stored can be set with setConfigGroup().
Definition at line 486 of file kaccel.cpp. References readSettings(). Referenced by readSettings(). |
|
Write the current shortcuts to
Definition at line 492 of file kaccel.cpp. References writeSettings(). Referenced by writeSettings(). |
|
Emits the keycodeChanged() signal.
Definition at line 495 of file kaccel.cpp. References endl(), and keycodeChanged(). |
|
Emitted when one of the key codes has changed.
Referenced by emitKeycodeChanged(). |
|
Definition at line 506 of file kaccel.cpp. References insertItem(). Referenced by insertItem(). |
|
Definition at line 518 of file kaccel.cpp. References insertItem(). |
|
Definition at line 532 of file kaccel.cpp. References insertStdItem(). Referenced by insertStdItem(). |
|
Definition at line 543 of file kaccel.cpp. References connectItem(), endl(), and setSlot(). Referenced by connectItem(). |
|
|
|
Definition at line 554 of file kaccel.cpp. References removeItem(). Referenced by removeItem(). |
|
Definition at line 557 of file kaccel.cpp. References setEnabled(), and setItemEnabled(). Referenced by setItemEnabled(). |
|
Definition at line 560 of file kaccel.cpp. References changeMenuAccel(). Referenced by changeMenuAccel(). |
|
Definition at line 587 of file kaccel.cpp. References changeMenuAccel(). |
|
Definition at line 592 of file kaccel.cpp. References stringToKey(). Referenced by stringToKey(). |
|
action , or zero if either the action name cannot be found or the current key is set to no key.
Definition at line 597 of file kaccel.cpp. References currentKey(). Referenced by currentKey(). |
|
key , or QString::null if the item cannot be found.
Definition at line 605 of file kaccel.cpp. References findKey(). Referenced by findKey(). |
The documentation for this class was generated from the following files: