org.kde.koala

Class KAccel

public class KAccel extends QAccel

Handle shortcuts. 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();
 
See KAccelSignals for signals emitted by KAccel

See Also: KGlobalAccel KAccelShortcutList KKeyChooser KKeyDialog

UNKNOWN: Configurable shortcut support for widgets.

Constructor Summary
protected KAccel(Class dummy)
KAccel(QWidget pParent, String psName)
Creates a new KAccel that watches pParent, which is also the QObject's parent.
KAccel(QWidget pParent)
KAccel(QWidget watch, QObject parent, String psName)
Creates a new KAccel that watches watch.
KAccel(QWidget watch, QObject parent)
Method Summary
KAccelActionsactions()
Returns the KAccel's KAccelActions, a list of KAccelAction.
StringclassName()
StringconfigGroup()
Returns the configuration group of the settings.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
voidemitKeycodeChanged()
Emits the keycodeChanged() signal.
protected voidfinalize()
Deletes the wrapped C++ instance
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
Create an accelerator action.
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot)
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
Same as first insert(), but with separate shortcuts defined for 3- and 4- modifier defaults.
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)
KAccelActioninsert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot)
KAccelActioninsert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
This is an overloaded function provided for convenience.
KAccelActioninsert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)
KAccelActioninsert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot)
KAccelActioninsert(int id, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
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.
KAccelActioninsert(int id, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)
KAccelActioninsert(int id, QObject pObjSlot, String psMethodSlot)
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisEnabled()
Checks whether the KAccel is active.
QMetaObjectmetaObject()
booleanreadSettings(KConfigBase pConfig)
Read all shortcuts from pConfig, or (if pConfig is zero) from the application's configuration file KGlobal.config().
booleanreadSettings()
booleanremove(String sAction)
Removes the accelerator action identified by the name.
booleansetAutoUpdate(boolean bAuto)
Enable auto-update of connections.
voidsetConfigGroup(String name)
Returns the configuration group of the settings.
voidsetEnabled(boolean bEnabled)
Enables or disables the KAccel.
booleansetEnabled(String sAction, boolean bEnabled)
Enable or disable the action named by sAction.
booleansetShortcut(String sAction, KShortcut shortcut)
Set the shortcut to be associated with the action named by sAction.
booleansetSlot(String sAction, QObject pObjSlot, String psMethodSlot)
Set the slot to be called when the shortcut of the action named by sAction is pressed.
KShortcutshortcut(String sAction)
Return the shortcut associated with the action named by sAction.
booleanupdateConnections()
Updates the connections of the accelerations after changing them.
booleanwriteSettings(KConfigBase pConfig)
Write the current shortcuts to pConfig, or (if pConfig is zero) to the application's configuration file.
booleanwriteSettings()

Constructor Detail

KAccel

protected KAccel(Class dummy)

KAccel

public KAccel(QWidget pParent, String psName)
Creates a new KAccel that watches pParent, which is also the QObject's parent.

Parameters: pParent the parent and widget to watch for key strokes psName the name of the QObject

UNKNOWN: Creates a new KAccel that watches pParent, which is also the QObject's parent.

KAccel

public KAccel(QWidget pParent)

KAccel

public KAccel(QWidget watch, QObject parent, String psName)
Creates a new KAccel that watches watch.

Parameters: watch the widget to watch for key strokes parent the parent of the QObject psName the name of the QObject

UNKNOWN: Creates a new KAccel that watches watch.

KAccel

public KAccel(QWidget watch, QObject parent)

Method Detail

actions

public KAccelActions actions()
Returns the KAccel's KAccelActions, a list of KAccelAction.

Returns: the KAccelActions of the KAccel

UNKNOWN:

className

public String className()

configGroup

public String configGroup()
Returns the configuration group of the settings.

Returns: the configuration group

See Also: KConfig

UNKNOWN: Returns the configuration group of the settings.

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

emitKeycodeChanged

public void emitKeycodeChanged()
Emits the keycodeChanged() signal.

UNKNOWN: Emits the keycodeChanged() signal.

finalize

protected void finalize()
Deletes the wrapped C++ instance

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
Create an accelerator action. Usage:
		 insert( "Do Something", i18n("Do Something"),
		   i18n("This action allows you to do something really great with this program to "
		        "the currently open document."),
		   ALT+Key_D, this, SLOT("slotDoSomething()") );
		

Parameters: sAction The internal name of the action. sLabel An i18n'ized short description of the action displayed when using KKeyChooser to reconfigure the shortcuts. sWhatsThis An extended description of the action. cutDef The default shortcut. pObjSlot Pointer to the slot object. psMethodSlot Pointer to the slot method. bConfigurable Allow the user to change this shortcut if set to 'true'. bEnabled The action will be activated by the shortcut if set to 'true'.

UNKNOWN: Create an accelerator action.

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef, QObject pObjSlot, String psMethodSlot)

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
Same as first insert(), but with separate shortcuts defined for 3- and 4- modifier defaults.

UNKNOWN: Same as first insert(), but with separate shortcuts defined for 3- and 4- modifier defaults.

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)

insert

public KAccelAction insert(String sAction, String sLabel, String sWhatsThis, KShortcut cutDef3, KShortcut cutDef4, QObject pObjSlot, String psMethodSlot)

insert

public KAccelAction insert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
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:
		 insert( i18n("Do Something"), ALT+Key_D, this, SLOT("slotDoSomething()") );
		 

Parameters: psAction The name AND label of the action. cutDef The default shortcut for this action. pObjSlot Pointer to the slot object. psMethodSlot Pointer to the slot method. bConfigurable Allow the user to change this shortcut if set to 'true'. bEnabled The action will be activated by the shortcut if set to 'true'.

UNKNOWN: This is an overloaded function provided for convenience.

insert

public KAccelAction insert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)

insert

public KAccelAction insert(String psAction, KShortcut cutDef, QObject pObjSlot, String psMethodSlot)

insert

public KAccelAction insert(int id, QObject pObjSlot, String psMethodSlot, boolean bConfigurable, boolean bEnabled)
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.

See Also: #

UNKNOWN: 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.

insert

public KAccelAction insert(int id, QObject pObjSlot, String psMethodSlot, boolean bConfigurable)

insert

public KAccelAction insert(int id, QObject pObjSlot, String psMethodSlot)

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

isEnabled

public boolean isEnabled()
Checks whether the KAccel is active.

Returns: true if the QAccel is enabled

UNKNOWN: Checks whether the KAccel is active.

metaObject

public QMetaObject metaObject()

readSettings

public boolean readSettings(KConfigBase pConfig)
Read all shortcuts from pConfig, or (if pConfig is zero) from the application's configuration file KGlobal.config(). The group in which the configuration is stored can be set with setConfigGroup().

Parameters: pConfig the configuration file, or 0 for the application configuration file

Returns: true if successful, false otherwise

UNKNOWN: Read all shortcuts from pConfig, or (if pConfig is zero) from the application's configuration file KGlobal.config().

readSettings

public boolean readSettings()

remove

public boolean remove(String sAction)
Removes the accelerator action identified by the name. Remember to also call updateConnections().

Parameters: sAction the name of the action to remove

Returns: true if successful, false otherwise

UNKNOWN: Removes the accelerator action identified by the name.

setAutoUpdate

public boolean setAutoUpdate(boolean bAuto)
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.

Parameters: bAuto true to enable, false to disable

Returns: the value of the flag before this call

UNKNOWN: Enable auto-update of connections.

setConfigGroup

public void setConfigGroup(String name)
Returns the configuration group of the settings.

Parameters: name the new configuration group

See Also: KConfig

UNKNOWN: Returns the configuration group of the settings.

setEnabled

public void setEnabled(boolean bEnabled)
Enables or disables the KAccel.

Parameters: bEnabled true to enable, false to disable

UNKNOWN: Enables or disables the KAccel.

setEnabled

public boolean setEnabled(String sAction, boolean bEnabled)
Enable or disable the action named by sAction.

Parameters: sAction the action to en-/disable bEnabled true to enable, false to disable

Returns: true if successful, false otherwise

UNKNOWN: Enable or disable the action named by sAction.

setShortcut

public boolean setShortcut(String sAction, KShortcut shortcut)
Set the shortcut to be associated with the action named by sAction.

Parameters: sAction the name of the action shortcut the shortcut to set

Returns: true if successful, false otherwise

UNKNOWN: Set the shortcut to be associated with the action named by sAction.

setSlot

public boolean setSlot(String sAction, QObject pObjSlot, String psMethodSlot)
Set the slot to be called when the shortcut of the action named by sAction is pressed.

Parameters: sAction the name of the action pObjSlot the owner of the slot psMethodSlot the name of the slot

Returns: true if successful, false otherwise

UNKNOWN: Set the slot to be called when the shortcut of the action named by sAction is pressed.

shortcut

public KShortcut shortcut(String sAction)
Return the shortcut associated with the action named by sAction.

Parameters: sAction the name of the action

Returns: the action's shortcut, or a null shortcut if not found

UNKNOWN: Return the shortcut associated with the action named by sAction.

updateConnections

public boolean updateConnections()
Updates the connections of the accelerations after changing them. This is only necessary if you have disabled auto updates which are on by default.

Returns: true if successful, false otherwise

See Also: KAccel KAccel

UNKNOWN: Updates the connections of the accelerations after changing them.

writeSettings

public boolean writeSettings(KConfigBase pConfig)
Write the current shortcuts to pConfig, or (if pConfig is zero) to the application's configuration file.

Parameters: pConfig the configuration file, or 0 for the application configuration file

Returns: true if successful, false otherwise

UNKNOWN: Write the current shortcuts to pConfig, or (if pConfig is zero) to the application's configuration file.

writeSettings

public boolean writeSettings()