kshortcutlist.h
/* This file is part of the KDE libraries
Copyright (C) 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 __KSHORTCUTLIST_H
#define __KSHORTCUTLIST_H
#include <qglobal.h> // For uint
#include <qstring.h>
#include "kdelibs_export.h"
class QVariant;
class KConfigBase;
class KInstance;
class KKeySequence;
class KShortcut;
/**********************************************************************
* This is a wrapper class which allows a function to use one interface
* to KActionCollection, KAccelActions, and KActionPtrList.
**********************************************************************/
class KDECORE_EXPORT KShortcutList
{
public:
KShortcutList();
virtual ~KShortcutList();
virtual uint count() const = 0;
virtual QString name( uint index ) const = 0;
virtual QString label( uint index ) const = 0;
virtual QString whatsThis( uint index ) const = 0;
// TODO KDE4: add virtual QString toolTip( uint index ) const = 0
// Will then be used by the listview in kkeydialog
virtual const KShortcut& shortcut( uint index ) const = 0;
virtual const KShortcut& shortcutDefault( uint index ) const = 0;
virtual bool isConfigurable( uint index ) const = 0;
virtual bool setShortcut( uint index, const KShortcut &shortcut ) = 0;
virtual bool isGlobal( uint index ) const;
virtual int index( const QString& sName ) const;
virtual int index( const KKeySequence& keySeq ) const;
virtual const KInstance* instance() const;
// These are here in order to handle expansion.
enum Other { };
virtual QVariant getOther( Other, uint index ) const = 0;
virtual bool setOther( Other, uint index, QVariant ) = 0;
virtual bool save() const = 0;
virtual bool readSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
virtual bool writeSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0,
bool bWriteAll = false, bool bGlobal = false ) const;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KShortcutListPrivate* d;
};
//---------------------------------------------------------------------
// KAccelShortcutList
//---------------------------------------------------------------------
class KAccel;
class KAccelActions;
class KGlobalAccel;
class KDECORE_EXPORT KAccelShortcutList : public KShortcutList
{
public:
KAccelShortcutList( KAccel* accel );
KAccelShortcutList( KGlobalAccel* accel );
KAccelShortcutList( KAccelActions &actions, bool bGlobal );
virtual ~KAccelShortcutList();
virtual uint count() const;
virtual QString name( uint index ) const;
virtual QString label( uint index ) const;
virtual QString whatsThis( uint index ) const;
virtual const KShortcut& shortcut( uint index ) const;
virtual const KShortcut& shortcutDefault( uint index ) const;
virtual bool isConfigurable( uint index ) const;
virtual bool setShortcut( uint index , const KShortcut& shortcut );
virtual bool isGlobal( uint index ) const;
virtual QVariant getOther( Other, uint index ) const;
virtual bool setOther( Other, uint index, QVariant );
virtual bool save() const;
protected:
KAccelActions& m_actions;
bool m_bGlobal;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KAccelShortcutListPrivate* d;
};
namespace KStdAccel {
//---------------------------------------------------------------------
// ShortcutList
//---------------------------------------------------------------------
class KDECORE_EXPORT ShortcutList : public KShortcutList
{
public:
ShortcutList();
virtual ~ShortcutList();
virtual uint count() const;
virtual QString name( uint index ) const;
virtual QString label( uint index ) const;
virtual QString whatsThis( uint index ) const;
virtual const KShortcut& shortcut( uint index ) const;
virtual const KShortcut& shortcutDefault( uint index ) const;
virtual bool isConfigurable( uint index ) const;
virtual bool setShortcut( uint index , const KShortcut& shortcut );
virtual QVariant getOther( Other, uint index ) const;
virtual bool setOther( Other, uint index, QVariant );
virtual bool save() const;
protected:
virtual void virtual_hook( int id, void* data );
private:
class ShortcutListPrivate* d;
};
}
#endif // __KSHORTCUTLIST_H
KShortcutList::name
virtual QString name(uint index) const =0
Returns the name of the shortcut with the given index.
KAccel
Handle shortcuts.
Definition: kaccel.h:93
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
KShortcutList::count
virtual uint count() const =0
Returns the number of entries.
KShortcutList::shortcutDefault
virtual const KShortcut & shortcutDefault(uint index) const =0
Returns default shortcut with the given index.
KShortcutList::save
virtual bool save() const =0
Save the shortcut list.
KShortcutList::virtual_hook
virtual void virtual_hook(int id, void *data)
used to extend the interface with virtuals without breaking binary compatibility
Definition: kshortcutlist.cpp:212
KShortcutList::shortcut
virtual const KShortcut & shortcut(uint index) const =0
Returns the shortcut with the given index.
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::save
const KShortcut & save()
Save current document.
Definition: kstdaccel.cpp:273
KShortcutList::label
virtual QString label(uint index) const =0
Returns the (i18n'd) label of the shortcut with the given index.
KAccelShortcutList
KShortcutList implementation to access KAccel and KGlobalAccel lists.
Definition: kshortcutlist.h:198
KShortcutList
KShortcutList is an abstract base class for KAccelShortcutList and KStdAccel::ShortcutList.
Definition: kshortcutlist.h:48
KAccelShortcutList::m_actions
KAccelActions & m_actions
Actions (collection) for this shortcut list.
Definition: kshortcutlist.h:244
KStdAccel::label
QString label(StdAccel id)
Returns a localized label for user-visible display.
Definition: kstdaccel.cpp:156
KInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:43
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KStdAccel::whatsThis
QString whatsThis(StdAccel)
Returns an extended WhatsThis description for the given accelerator.
Definition: kstdaccel.cpp:165
KStdAccel::ShortcutList
KShortcutList implementation that accesses KStdAccel actions.
Definition: kshortcutlist.h:263
KAccelShortcutList::m_bGlobal
bool m_bGlobal
Is this shortcut list global? Access through isGlobal()
Definition: kshortcutlist.h:246
KShortcutList::isConfigurable
virtual bool isConfigurable(uint index) const =0
Checks whether the shortcut with the given index is configurable.
KShortcutList::whatsThis
virtual QString whatsThis(uint index) const =0
Returns the (i18n'd) What's This text of the shortcut with the given index.
KShortcutList::setShortcut
virtual bool setShortcut(uint index, const KShortcut &shortcut)=0
Sets the shortcut of the given entry.
KGlobalAccel
KGlobalAccel allows you to have global accelerators that are independent of the focused window...
Definition: kglobalaccel.h:45
KStdAccel::name
QString name(StdAccel id)
Returns a unique name for the given accel.
Definition: kstdaccel.cpp:148
KShortcutList::isGlobal
virtual bool isGlobal(uint index) const
Checks whether the shortcut with the given index is saved in the global configuration.
Definition: kshortcutlist.cpp:26

KDE Home | KDE Accessibility Home | Description of Access Keys