class KAccelBase
|
Configurable key binding support.
More... |
|
|
Public Types
- enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 }
- enum Signal { KEYCODE_CHANGED }
Public Methods
- KAccelBase ( int fInitCode )
- virtual ~KAccelBase ()
- uint actionCount () const
- KAccelActions& actions ()
- bool isEnabled () const
- KAccelAction* actionPtr ( const QString& sAction )
- const KAccelAction* actionPtr ( const QString& sAction ) const
- KAccelAction* actionPtr ( const KKey& key )
- KAccelAction* actionPtr ( const KKeyServer::Key& key )
- const QString& configGroup () const
- void setConfigGroup ( const QString& group )
- void setConfigGlobal ( bool global )
- virtual void setEnabled ( bool bEnabled )
- bool getAutoUpdate ()
- bool setAutoUpdate ( bool bAuto )
- KAccelAction* insert ( const QString& sName, const QString& sDesc )
- KAccelAction* insert (
const QString& sAction, const QString& sDesc, const QString& sHelp,
const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
const QObject* pObjSlot, const char* psMethodSlot,
bool bConfigurable = true, bool bEnabled = true )
- bool remove ( const QString& sAction )
- bool setActionSlot ( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot )
- bool updateConnections ()
- bool setShortcut ( const QString& sAction, const KShortcut& cut )
- bool setActionEnabled ( const QString& sAction, bool bEnable )
- void readSettings ( KConfigBase* pConfig = 0 )
- void writeSettings ( KConfigBase* pConfig = 0 ) const
- QPopupMenu* createPopupMenu ( QWidget* pParent, const KKeySequence& )
Protected Types
Protected Methods
Protected Members
Handle keyboard accelerators.
Allow an user to configure
key bindings through application configuration files or through the
KKeyChooser GUI.
A KAccel 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+P" could be a shortcut for printing a document. The key
codes are listed in ckey.h. "Print" could be the action name for printing.
The action name identifies 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.
A KAccel object handles key events sent to its parent widget and to all
children of this parent widget.
Key binding reconfiguration during run time 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. Convenience methods are
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 *a = new KAccel( myWindow );
// Insert an action "Scroll Up" which is associated with the "Up" key:
a->insertItem( i18n("Scroll up"), "Scroll Up", "Up" );
// Insert an action "Scroll Down" which is not associated with any key:
a->insertItem( i18n("Scroll down"), "Scroll Down", 0);
a->connectItem( "Scroll up", myWindow, SLOT( scrollUp() ) );
// a->insertStdItem( KStdAccel::Print ); //not necessary, since it
// is done automatially with the
// connect below!
a->connectItem(KStdAccel::Print, myWindow, SLOT( printDoc() ) );
a->readSettings();
|
If a shortcut has a menu entry as well, you could insert them like
this. The example is again the KStdAccel::Print from above.
int id;
id = popup->insertItem("&Print",this, SLOT(printDoc()));
a->changeMenuAccel(popup, id, KStdAccel::Print );
|
If you want a somewhat "exotic" name for your standard print action, like
id = popup->insertItem(i18n("Print &Document"),this, SLOT(printDoc()));
it might be a good idea to insert the standard action before as
a->insertStdItem( KStdAccel::Print, i18n("Print Document") )
as well, so that the user can easily find the corresponding function.
This technique works for other actions as well. Your "scroll up" function
in a menu could be done with
id = popup->insertItem(i18n"Scroll &up",this, SLOT(scrollUp()));
a->changeMenuAccel(popup, id, "Scroll Up" );
|
Please keep the order right: First insert all functions in the
acceleratior, then call a -> readSettings() and then build your
menu structure.
enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 }
| Init |
enum Signal { KEYCODE_CHANGED }
| Signal |
KAccelBase ( int fInitCode )
| KAccelBase |
~KAccelBase ()
| ~KAccelBase |
[virtual]
uint actionCount ()
| actionCount |
[const]
bool isEnabled ()
| isEnabled |
[const]
[const]
const QString& configGroup ()
| configGroup |
[const]
void setConfigGroup ( const QString& group )
| setConfigGroup |
void setConfigGlobal ( bool global )
| setConfigGlobal |
void setEnabled ( bool bEnabled )
| setEnabled |
[pure virtual]
bool getAutoUpdate ()
| getAutoUpdate |
bool setAutoUpdate ( bool bAuto )
| setAutoUpdate |
bool remove ( const QString& sAction )
| remove |
bool setActionSlot ( const QString& sAction, const QObject* pObjSlot, const char* psMethodSlot )
| setActionSlot |
bool updateConnections ()
| updateConnections |
bool setActionEnabled ( const QString& sAction, bool bEnable )
| setActionEnabled |
void readSettings ( KConfigBase* pConfig = 0 )
| readSettings |
Read all key associations from config
, or (if config
is zero) from the application's configuration file
KGlobal::config().
The group in which the configuration is stored can be
set with setConfigGroup().
void writeSettings ( KConfigBase* pConfig = 0 )
| writeSettings |
[const]
Write the current configurable associations to config
,
or (if config
is zero) to the application's
configuration file.
[protected]
[protected]
[protected]
[protected]
bool emitSignal ( Signal )
| emitSignal |
[protected pure virtual]
[protected pure virtual]
[protected pure virtual]
[protected pure virtual]
[protected pure virtual]
ActionInfo (struct) | ActionInfo |
[protected]
[protected]
[protected]
KKeyToActionMap m_mapKeyToAction
| m_mapKeyToAction |
[protected]
[protected]
bool m_bNativeKeys
| m_bNativeKeys |
[protected]
bool m_bEnabled
| m_bEnabled |
[protected]
bool m_bConfigIsGlobal
| m_bConfigIsGlobal |
[protected]
QString m_sConfigGroup
| m_sConfigGroup |
[protected]
bool m_bAutoUpdate
| m_bAutoUpdate |
[protected]
[protected]
void virtual_hook ( int id, void* data )
| virtual_hook |
[protected virtual]
- Version: $Id: KAccelBase.html 149726 2002-04-16 07:39:43Z dfaure $
- Generated: dfaure on faure on Tue Apr 16 08:49:00 2002, using kdoc 2.0a53.