You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
296 lines
9.1 KiB
296 lines
9.1 KiB
15 years ago
|
/* 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
|
||
|
|
||
15 years ago
|
#include <tqglobal.h> // For uint
|
||
|
#include <tqstring.h>
|
||
13 years ago
|
#include "tdelibs_export.h"
|
||
15 years ago
|
|
||
14 years ago
|
class TQVariant;
|
||
12 years ago
|
class TDEConfigBase;
|
||
12 years ago
|
class TDEInstance;
|
||
15 years ago
|
class KKeySequence;
|
||
12 years ago
|
class TDEShortcut;
|
||
15 years ago
|
|
||
|
/**********************************************************************
|
||
|
* This is a wrapper class which allows a function to use one interface
|
||
12 years ago
|
* to TDEActionCollection, TDEAccelActions, and TDEActionPtrList.
|
||
15 years ago
|
**********************************************************************/
|
||
|
|
||
|
/**
|
||
12 years ago
|
* TDEShortcutList is an abstract base class for
|
||
|
* TDEAccelShortcutList and TDEStdAccel::ShortcutList. It gives
|
||
15 years ago
|
* you an unified interface for accessing the accelerator lists
|
||
12 years ago
|
* of TDEAccel (using TDEAccelShortcutList),
|
||
|
* TDEGlobalAccel (using TDEAccelShortcutList), and
|
||
|
* TDEStdAccel (using TDEStdAccel::ShortcutList).
|
||
15 years ago
|
*
|
||
|
* @short Base class for accessing accelerator lists
|
||
|
*/
|
||
12 years ago
|
class TDECORE_EXPORT TDEShortcutList
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
/**
|
||
|
* Default constructor.
|
||
|
*/
|
||
12 years ago
|
TDEShortcutList();
|
||
|
virtual ~TDEShortcutList();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the number of entries.
|
||
|
* @return the number of entries
|
||
|
*/
|
||
|
virtual uint count() const = 0;
|
||
|
|
||
|
/**
|
||
|
* Returns the name of the shortcut with the given @p index.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return the name of the shortcut
|
||
|
*/
|
||
15 years ago
|
virtual TQString name( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the (i18n'd) label of the shortcut with the given @p index.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return the label (i18n'd) of the shortcut
|
||
|
*/
|
||
15 years ago
|
virtual TQString label( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the (i18n'd) What's This text of the shortcut with the given @p index.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return the What's This text (i18n'd) of the shortcut
|
||
|
*/
|
||
15 years ago
|
virtual TQString whatsThis( uint index ) const = 0;
|
||
15 years ago
|
|
||
15 years ago
|
// TODO KDE4: add virtual TQString toolTip( uint index ) const = 0
|
||
15 years ago
|
// Will then be used by the listview in kkeydialog
|
||
|
|
||
|
/**
|
||
|
* Returns the shortcut with the given @p index.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return the shortcut
|
||
|
* @see shortcutDefault()
|
||
|
*/
|
||
12 years ago
|
virtual const TDEShortcut& shortcut( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns default shortcut with the given @p index.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return the default shortcut
|
||
|
* @see shortcut()
|
||
|
*/
|
||
12 years ago
|
virtual const TDEShortcut& shortcutDefault( uint index ) const = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Checks whether the shortcut with the given @p index is configurable.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return true if configurable, false otherwise
|
||
|
*/
|
||
|
virtual bool isConfigurable( uint index ) const = 0;
|
||
|
|
||
|
/**
|
||
|
* Sets the shortcut of the given entry
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @param shortcut the shortcut
|
||
|
*/
|
||
12 years ago
|
virtual bool setShortcut( uint index, const TDEShortcut &shortcut ) = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Checks whether the shortcut with the given @p index is saved in the
|
||
|
* global configuration.
|
||
|
* @param index the index of the shortcut (must be < count())
|
||
|
* @return true if global, false otherwise
|
||
|
*/
|
||
|
virtual bool isGlobal( uint index ) const;
|
||
|
|
||
|
/**
|
||
|
* Returns the index of the shortcut with he given name.
|
||
|
* @param sName the name of the shortcut to search
|
||
|
* @return the index of the shortcut, of -1 if not found
|
||
|
*/
|
||
15 years ago
|
virtual int index( const TQString& sName ) const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the index of the shortcut with he given key sequence.
|
||
|
* @param keySeq the key sequence to search for
|
||
|
* @return the index of the shortcut, of -1 if not found
|
||
|
*/
|
||
|
virtual int index( const KKeySequence& keySeq ) const;
|
||
|
|
||
|
/**
|
||
12 years ago
|
* The TDEInstance.
|
||
|
* @return the TDEInstance of the list, can be 0 if not available
|
||
15 years ago
|
*/
|
||
12 years ago
|
virtual const TDEInstance* instance() const;
|
||
15 years ago
|
|
||
|
// These are here in order to handle expansion.
|
||
|
enum Other { };
|
||
|
/** \internal */
|
||
15 years ago
|
virtual TQVariant getOther( Other, uint index ) const = 0;
|
||
15 years ago
|
/** \internal */
|
||
15 years ago
|
virtual bool setOther( Other, uint index, TQVariant ) = 0;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Save the shortcut list.
|
||
|
* @return true if successful, false otherwise
|
||
|
*/
|
||
|
virtual bool save() const = 0;
|
||
|
|
||
|
/**
|
||
|
* Loads the shortcuts from the given configuration file.
|
||
|
*
|
||
|
* @param sConfigGroup the group in the configuration file
|
||
|
* @param pConfig the configuration file to load from
|
||
|
* @return true if successful, false otherwise
|
||
|
*/
|
||
12 years ago
|
virtual bool readSettings( const TQString& sConfigGroup = TQString::null, TDEConfigBase* pConfig = 0 );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Writes the shortcuts to the given configuration file.
|
||
|
*
|
||
|
* @param sConfigGroup the group in the configuration file
|
||
|
* @param pConfig the configuration file to save to
|
||
|
* @param bWriteAll true to write all actions
|
||
|
* @param bGlobal true to write to the global configuration file
|
||
|
* @return true if successful, false otherwise
|
||
|
*/
|
||
12 years ago
|
virtual bool writeSettings( const TQString& sConfigGroup = TQString::null, TDEConfigBase* pConfig = 0,
|
||
15 years ago
|
bool bWriteAll = false, bool bGlobal = false ) const;
|
||
|
|
||
|
protected:
|
||
|
/// used to extend the interface with virtuals without breaking binary compatibility
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
12 years ago
|
class TDEShortcutListPrivate* d;
|
||
15 years ago
|
};
|
||
|
|
||
|
//---------------------------------------------------------------------
|
||
12 years ago
|
// TDEAccelShortcutList
|
||
15 years ago
|
//---------------------------------------------------------------------
|
||
|
|
||
12 years ago
|
class TDEAccel;
|
||
|
class TDEAccelActions;
|
||
12 years ago
|
class TDEGlobalAccel;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* TDEShortcutList implementation to access TDEAccel and
|
||
12 years ago
|
* TDEGlobalAccel lists.
|
||
15 years ago
|
*/
|
||
12 years ago
|
class TDECORE_EXPORT TDEAccelShortcutList : public TDEShortcutList
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
/**
|
||
12 years ago
|
* Creates a new TDEShortcutList that accesses the given TDEAccel.
|
||
15 years ago
|
* @param accel the accelerators to access
|
||
|
*/
|
||
12 years ago
|
TDEAccelShortcutList( TDEAccel* accel );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Creates a new TDEShortcutList that accesses the given
|
||
12 years ago
|
* TDEGlobalAccel.
|
||
15 years ago
|
* @param accel the accelerators to access
|
||
|
*/
|
||
12 years ago
|
TDEAccelShortcutList( TDEGlobalAccel* accel );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @internal
|
||
12 years ago
|
* Creates a new TDEShortcutList that accesses the given
|
||
|
* TDEAccelActions collection.
|
||
15 years ago
|
* @param actions the actions to access
|
||
|
* @param bGlobal true to save the actions in the global
|
||
|
* configuration file
|
||
|
*/
|
||
12 years ago
|
TDEAccelShortcutList( TDEAccelActions &actions, bool bGlobal );
|
||
|
virtual ~TDEAccelShortcutList();
|
||
15 years ago
|
|
||
|
virtual uint count() const;
|
||
15 years ago
|
virtual TQString name( uint index ) const;
|
||
|
virtual TQString label( uint index ) const;
|
||
|
virtual TQString whatsThis( uint index ) const;
|
||
12 years ago
|
virtual const TDEShortcut& shortcut( uint index ) const;
|
||
|
virtual const TDEShortcut& shortcutDefault( uint index ) const;
|
||
15 years ago
|
virtual bool isConfigurable( uint index ) const;
|
||
12 years ago
|
virtual bool setShortcut( uint index , const TDEShortcut& shortcut );
|
||
15 years ago
|
virtual bool isGlobal( uint index ) const;
|
||
|
|
||
|
/** \internal */
|
||
15 years ago
|
virtual TQVariant getOther( Other, uint index ) const;
|
||
15 years ago
|
/** \internal */
|
||
15 years ago
|
virtual bool setOther( Other, uint index, TQVariant );
|
||
15 years ago
|
|
||
|
virtual bool save() const;
|
||
|
|
||
|
protected:
|
||
|
/** Actions (collection) for this shortcut list. Set by constructor. */
|
||
12 years ago
|
TDEAccelActions& m_actions;
|
||
15 years ago
|
/** Is this shortcut list global? Access through isGlobal() */
|
||
|
bool m_bGlobal;
|
||
|
|
||
|
protected:
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
12 years ago
|
class TDEAccelShortcutListPrivate* d;
|
||
15 years ago
|
};
|
||
|
|
||
12 years ago
|
namespace TDEStdAccel {
|
||
15 years ago
|
//---------------------------------------------------------------------
|
||
|
// ShortcutList
|
||
|
//---------------------------------------------------------------------
|
||
|
|
||
|
/**
|
||
12 years ago
|
* TDEShortcutList implementation that accesses TDEStdAccel
|
||
15 years ago
|
* actions.
|
||
|
*/
|
||
12 years ago
|
class TDECORE_EXPORT ShortcutList : public TDEShortcutList
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
/**
|
||
|
* Creates a new ShortcutList.
|
||
|
*/
|
||
|
ShortcutList();
|
||
|
virtual ~ShortcutList();
|
||
|
|
||
|
virtual uint count() const;
|
||
15 years ago
|
virtual TQString name( uint index ) const;
|
||
|
virtual TQString label( uint index ) const;
|
||
|
virtual TQString whatsThis( uint index ) const;
|
||
12 years ago
|
virtual const TDEShortcut& shortcut( uint index ) const;
|
||
|
virtual const TDEShortcut& shortcutDefault( uint index ) const;
|
||
15 years ago
|
virtual bool isConfigurable( uint index ) const;
|
||
12 years ago
|
virtual bool setShortcut( uint index , const TDEShortcut& shortcut );
|
||
15 years ago
|
|
||
|
/** \internal */
|
||
15 years ago
|
virtual TQVariant getOther( Other, uint index ) const;
|
||
15 years ago
|
/** \internal */
|
||
15 years ago
|
virtual bool setOther( Other, uint index, TQVariant );
|
||
15 years ago
|
|
||
|
virtual bool save() const;
|
||
|
|
||
|
protected:
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
|
class ShortcutListPrivate* d;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif // __KSHORTCUTLIST_H
|