kaccelaction.h
/* This file is part of the KDE libraries
Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KACCELACTION_H
#define _KACCELACTION_H
#include <qmap.h>
#include <qptrvector.h>
#include <qstring.h>
#include <qvaluevector.h>
#include <kshortcut.h>
class KAccelBase;
class QObject;
class KConfig;
class KConfigBase;
class KDECORE_EXPORT KAccelAction
{
public:
KAccelAction();
KAccelAction( const KAccelAction& );
KAccelAction( const QString& sName, const QString& sLabel, const QString& sWhatsThis,
const KShortcut& cutDef3, const KShortcut& cutDef4,
const QObject* pObjSlot, const char* psMethodSlot,
bool bConfigurable, bool bEnabled );
~KAccelAction();
void clear();
bool init( const QString& sName, const QString& sLabel, const QString& sWhatsThis,
const KShortcut& cutDef3, const KShortcut& cutDef4,
const QObject* pObjSlot, const char* psMethodSlot,
bool bConfigurable, bool bEnabled );
KAccelAction& operator=( const KAccelAction& );
const QString& name() const { return m_sName; }
const QString& label() const { return m_sLabel; }
const QString& whatsThis() const { return m_sWhatsThis; }
const KShortcut& shortcut() const { return m_cut; }
const KShortcut& shortcutDefault() const;
const KShortcut& shortcutDefault3() const { return m_cutDefault3; }
const KShortcut& shortcutDefault4() const { return m_cutDefault4; }
const QObject* objSlotPtr() const { return m_pObjSlot; }
const char* methodSlotPtr() const { return m_psMethodSlot; }
bool isConfigurable() const { return m_bConfigurable; }
bool isEnabled() const { return m_bEnabled; }
void setName( const QString& name );
void setLabel( const QString& label );
void setWhatsThis( const QString& whatsThis );
bool setShortcut( const KShortcut& rgCuts );
void setSlot( const QObject* pObjSlot, const char* psMethodSlot );
void setConfigurable( bool configurable );
void setEnabled( bool enable );
int getID() const { return m_nIDAccel; }
void setID( int n ) { m_nIDAccel = n; }
bool isConnected() const;
bool setKeySequence( uint i, const KKeySequence &keySeq );
void clearShortcut();
bool contains( const KKeySequence &keySeq );
QString toString() const;
QString toStringInternal() const;
static bool useFourModifierKeys();
static void useFourModifierKeys( bool use );
protected:
QString m_sName ,
m_sLabel ,
m_sWhatsThis ;
KShortcut m_cut ;
KShortcut m_cutDefault3 ,
m_cutDefault4 ;
const QObject* m_pObjSlot ;
const char* m_psMethodSlot ;
bool m_bConfigurable ,
m_bEnabled ;
int m_nIDAccel ;
uint m_nConnections ;
void incConnections();
void decConnections();
private:
static int g_bUseFourModifierKeys;
class KAccelActionPrivate* d;
friend class KAccelActions;
friend class KAccelBase;
};
//---------------------------------------------------------------------
// KAccelActions
//---------------------------------------------------------------------
class KDECORE_EXPORT KAccelActions
{
public:
KAccelActions();
KAccelActions( const KAccelActions& );
virtual ~KAccelActions();
void clear();
bool init( const KAccelActions &actions );
bool init( KConfigBase& config, const QString& sGroup );
void updateShortcuts( KAccelActions &shortcuts );
int actionIndex( const QString& sAction ) const;
KAccelAction* actionPtr( uint index );
const KAccelAction* actionPtr( uint index ) const;
KAccelAction* actionPtr( const QString& sAction );
const KAccelAction* actionPtr( const QString& sAction ) const;
KAccelAction* actionPtr( KKeySequence cut );
KAccelAction& operator []( uint index );
const KAccelAction& operator []( uint index ) const;
KAccelAction* insert( const QString& sAction, const QString& sLabel, const QString& sWhatsThis,
const KShortcut& rgCutDefaults3, const KShortcut& rgCutDefaults4,
const QObject* pObjSlot = 0, const char* psMethodSlot = 0,
bool bConfigurable = true, bool bEnabled = true );
KAccelAction* insert( const QString& sName, const QString& sLabel );
bool remove( const QString& sAction );
bool readActions( const QString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0 );
bool writeActions( const QString& sConfigGroup = "Shortcuts", KConfigBase* pConfig = 0,
bool bWriteAll = false, bool bGlobal = false ) const;
void emitKeycodeChanged();
uint count() const;
protected:
KAccelBase* m_pKAccelBase;
KAccelAction** m_prgActions;
uint m_nSizeAllocated ,
m_nSize ;
void resize( uint new_size );
void insertPtr( KAccelAction* );
private:
class KAccelActionsPrivate* d;
KAccelActions( KAccelBase* );
void initPrivate( KAccelBase* );
KAccelActions& operator =( KAccelActions& );
friend class KAccelBase;
};
#endif // _KACCELACTION_H
KStdAccel::shortcut
const KShortcut & shortcut(StdAccel id)
Returns the keybinding for accel.
Definition: kstdaccel.cpp:174
KStdAccel::shortcutDefault
KShortcut shortcutDefault(StdAccel id)
Returns the hardcoded default shortcut for id.
Definition: kstdaccel.cpp:202
KStdAction::whatsThis
KAction * whatsThis(const QObject *recvr, const char *slot, KActionCollection *parent, const char *name=0)
KStdAccel::shortcutDefault4
KShortcut shortcutDefault4(StdAccel id)
Returns the hardcoded default 4 modifier shortcut for id.
Definition: kstdaccel.cpp:225
KStdAccel::insert
const KShortcut & insert()
Toggle insert/overwrite (with visual feedback, e.g.
KShortcut
The KShortcut class is used to represent a keyboard shortcut to an action.
Definition: kshortcut.h:543
KKeySequence
A KKeySequence object holds a sequence of up to 4 keys.
Definition: kshortcut.h:288
KStdAccel::label
QString label(StdAccel id)
Returns a localized label for user-visible display.
Definition: kstdaccel.cpp:156
KStdAction::clear
KAction * clear(const QObject *recvr, const char *slot, KActionCollection *parent, const char *name=0)
KStdAccel::shortcutDefault3
KShortcut shortcutDefault3(StdAccel id)
Returns the hardcoded default 3 modifier shortcut for id.
Definition: kstdaccel.cpp:208
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KStdAction::name
const char * name(StdAction id)
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:43

KDE Home | KDE Accessibility Home | Description of Access Keys