kaccelbase.h
/* This file is part of the KDE libraries
Copyright (C) 2001 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 _KACCELBASE_H
#define _KACCELBASE_H
#include <qmap.h>
#include <qptrvector.h>
#include <qstring.h>
#include <qvaluevector.h>
#include <qvaluelist.h>
#include "kaccelaction.h"
#include "kkeyserver.h"
class QPopupMenu;
class QWidget;
//----------------------------------------------------
class KDECORE_EXPORT KAccelBase
{
public:
enum Init { QT_KEYS = 0x00, NATIVE_KEYS = 0x01 };
enum Signal { KEYCODE_CHANGED };
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 { return m_sConfigGroup; }
void setConfigGroup( const QString& group );
void setConfigGlobal( bool global );
virtual void setEnabled( bool bEnabled ) = 0;
bool getAutoUpdate() { return m_bAutoUpdate; }
bool setAutoUpdate( bool bAuto );
// Procedures for manipulating Actions.
//void clearActions();
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 );
// Modify individual Action sub-items
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 methods
protected:
void slotRemoveAction( KAccelAction* );
struct X;
void createKeyList( QValueVector<struct X>& rgKeys );
bool insertConnection( KAccelAction* );
bool removeConnection( KAccelAction* );
virtual bool emitSignal( Signal signal ) = 0;
virtual bool connectKey( KAccelAction& action, const KKeyServer::Key& key ) = 0;
virtual bool connectKey( const KKeyServer::Key& key) = 0;
virtual bool disconnectKey( KAccelAction&, const KKeyServer::Key& ) = 0;
virtual bool disconnectKey( const KKeyServer::Key& ) = 0;
protected:
virtual bool isEnabledInternal() const;
struct ActionInfo
{
KAccelAction* pAction;
uint iSeq, iVariation;
//ActionInfo* pInfoNext; // nil if only one action uses this key.
ActionInfo() { pAction = 0; iSeq = 0xffff; iVariation = 0xffff; }
ActionInfo( KAccelAction* _pAction, uint _iSeq, uint _iVariation )
{ pAction = _pAction; iSeq = _iSeq; iVariation = _iVariation; }
};
typedef QMap<KKeyServer::Key, ActionInfo> KKeyToActionMap;
KAccelActions m_rgActions;
KKeyToActionMap m_mapKeyToAction;
QValueList<KAccelAction*> m_rgActionsNonUnique;
bool m_bNativeKeys; // Use native key codes instead of Qt codes
bool m_bEnabled;
bool m_bConfigIsGlobal;
QString m_sConfigGroup;
bool m_bAutoUpdate;
KAccelAction* mtemp_pActionRemoving;
private:
KAccelBase& operator =( const KAccelBase& );
friend class KAccelActions;
};
#endif // _KACCELBASE_H
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
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: kshortcut.h:40
KKeyServer::Key
Represents a key press.
Definition: kkeyserver_x11.h:137

KDE Home | KDE Accessibility Home | Description of Access Keys