• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
TDEShortcut Class Reference

#include <tdeshortcut.h>

Public Types

enum  { MAX_SEQUENCES = 2 }
 

Public Member Functions

 TDEShortcut ()
 
 TDEShortcut (int keyQt)
 
 TDEShortcut (const TQKeySequence &keySeq)
 
 TDEShortcut (const KKey &key)
 
 TDEShortcut (const KKeySequence &keySeq)
 
 TDEShortcut (const TDEShortcut &shortcut)
 
 TDEShortcut (const char *shortcut)
 
 TDEShortcut (const TQString &shortcut)
 
void clear ()
 
bool init (int keyQt)
 
bool init (const TQKeySequence &keySeq)
 
bool init (const KKey &key)
 
bool init (const KKeySequence &keySeq)
 
bool init (const TDEShortcut &shortcut)
 
bool init (const TQString &shortcut)
 
TDEShortcut & operator= (const TDEShortcut &cut)
 
uint count () const
 
const KKeySequence & seq (uint i) const
 
int keyCodeQt () const
 
bool isNull () const
 
int compare (const TDEShortcut &shortcut) const
 
bool operator== (const TDEShortcut &cut) const
 
bool operator!= (const TDEShortcut &cut) const
 
bool operator< (const TDEShortcut &cut) const
 
bool contains (const KKey &key) const
 
bool contains (const KKeyNative &key) const
 
bool contains (const KKeySequence &keySeq) const
 
bool setSeq (uint i, const KKeySequence &keySeq)
 
bool append (const KKeySequence &keySeq)
 
void remove (const KKeySequence &keySeq)
 
bool append (const KKey &spec)
 
bool append (const TDEShortcut &cut)
 
 operator TQKeySequence () const
 
TQString toString () const
 
TQString toStringInternal (const TDEShortcut *pcutDefault=0) const
 
 operator int () const
 

Static Public Member Functions

static TDEShortcut & null ()
 

Protected Attributes

uint m_nSeqs
 
KKeySequence m_rgseq [MAX_SEQUENCES]
 

Friends

class KKeyNative
 

Detailed Description

The TDEShortcut class is used to represent a keyboard shortcut to an action.

A shortcut is normally a single key with modifiers, such as Ctrl+V. A TDEShortcut object may also contain an alternate key which will also activate the action it's associated to, as long as no other actions have defined that key as their primary key. Ex: Ctrl+V;Shift+Insert.

This can be used to add additional accelerators to a TDEAction. For example, the below code binds the escape key to the close action.

TDEAction *closeAction = KStdAction::close( this, TQ_SLOT( close() ), actionCollection() );
TDEShortcut closeShortcut = closeAction->shortcut();
closeShortcut.append( KKey(Key_Escape));
closeAction->setShortcut(closeShortcut);
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: tdeshortcut.h:41
TDEAction
TDEAction::setShortcut
virtual bool setShortcut(const TDEShortcut &)
TDEAction::shortcut
virtual const TDEShortcut & shortcut() const
TDEShortcut
The TDEShortcut class is used to represent a keyboard shortcut to an action.
Definition: tdeshortcut.h:544
TDEShortcut::append
bool append(const KKeySequence &keySeq)
Appends the given key sequence.
Definition: tdeshortcut.cpp:587
KStdAction::close
TDEAction * close(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)

Note that a shortcut cannot have more than 2 key combinations associated with it, so the above code would not do anything (and append() would return false) if the closeAction already had an key and alternate key.

Definition at line 543 of file tdeshortcut.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The maximum number of key sequences that can be contained in a TDEShortcut.

Definition at line 550 of file tdeshortcut.h.

Constructor & Destructor Documentation

◆ TDEShortcut() [1/8]

TDEShortcut::TDEShortcut ( )

Creates a new null shortcut.

See also
null()
isNull()
clear()

Definition at line 403 of file tdeshortcut.cpp.

◆ TDEShortcut() [2/8]

TDEShortcut::TDEShortcut ( int  keyQt)

Creates a new shortcut with the given Qt key code as the only key sequence.

Parameters
keyQtthe qt keycode
See also
TQt::Key

Definition at line 404 of file tdeshortcut.cpp.

◆ TDEShortcut() [3/8]

TDEShortcut::TDEShortcut ( const TQKeySequence &  keySeq)

Creates a new shortcut that contains only the given qt key sequence.

Parameters
keySeqthe qt key sequence to add

Definition at line 405 of file tdeshortcut.cpp.

◆ TDEShortcut() [4/8]

TDEShortcut::TDEShortcut ( const KKey &  key)

Creates a new shortcut that contains only the given key in its only sequence.

Parameters
keythe key to add

Definition at line 406 of file tdeshortcut.cpp.

◆ TDEShortcut() [5/8]

TDEShortcut::TDEShortcut ( const KKeySequence &  keySeq)

Creates a new shortcut that contains only the given key sequence.

Parameters
keySeqthe key sequence to add

Definition at line 407 of file tdeshortcut.cpp.

◆ TDEShortcut() [6/8]

TDEShortcut::TDEShortcut ( const TDEShortcut &  shortcut)

Copies the given shortcut.

Parameters
shortcutthe shortcut to add

Definition at line 408 of file tdeshortcut.cpp.

◆ TDEShortcut() [7/8]

TDEShortcut::TDEShortcut ( const char *  shortcut)

Creates a new key sequence that contains the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const TQString&).

Parameters
shortcutthe description of the key
See also
KKeySequence::KKeySequence(const TQString&)

Definition at line 409 of file tdeshortcut.cpp.

◆ TDEShortcut() [8/8]

TDEShortcut::TDEShortcut ( const TQString &  shortcut)

Creates a new key sequence that contains the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const TQString&).

Parameters
shortcutthe description of the key
See also
KKeySequence::KKeySequence(const TQString&)

Definition at line 410 of file tdeshortcut.cpp.

◆ ~TDEShortcut()

TDEShortcut::~TDEShortcut ( )

Definition at line 412 of file tdeshortcut.cpp.

Member Function Documentation

◆ append() [1/3]

bool TDEShortcut::append ( const KKey &  spec)

Appends the given key.

Parameters
specthe key to add
Returns
true if successful, false otherwise
See also
setSeq()
MAX_SEQUENCES
Since
3.2

Definition at line 599 of file tdeshortcut.cpp.

◆ append() [2/3]

bool TDEShortcut::append ( const KKeySequence &  keySeq)

Appends the given key sequence.

This sets it as either the keysequence or the alternate keysequence. If the shortcut already has MAX_SEQUENCES sequences then this call does nothing, and returns false.

Parameters
keySeqthe key sequence to add
Returns
true if successful, false otherwise
See also
setSeq()

Definition at line 587 of file tdeshortcut.cpp.

◆ append() [3/3]

bool TDEShortcut::append ( const TDEShortcut &  cut)

Appends the sequences from the given shortcut.

Parameters
cutthe shortcut to append
Returns
true if successful, false otherwise
See also
MAX_SEQUENCES
Since
3.2

Definition at line 609 of file tdeshortcut.cpp.

◆ clear()

void TDEShortcut::clear ( )

Clears the shortcut.

The shortcut is null after calling this function.

See also
isNull()

Definition at line 416 of file tdeshortcut.cpp.

◆ compare()

int TDEShortcut::compare ( const TDEShortcut &  shortcut) const

Compares this object with the given shortcut.

Returns a negative number if the given shortcut is larger, 0 if they are equal and a positive number this shortcut is larger. Shortcuts are compared by comparing the individual key sequences, starting from the beginning until an unequal key sequences has been found. If a shortcut contains more key sequences, it is considered larger.

Parameters
shortcutthe shortcut to compare to
Returns
a negative number if the given TDEShortcut is larger, 0 if they are equal and a positive number this TDEShortcut is larger
See also
KKey::compare()
KKeyShortcut::compare()

Definition at line 522 of file tdeshortcut.cpp.

◆ contains() [1/3]

bool TDEShortcut::contains ( const KKey &  key) const

Checks whether this shortcut contains a sequence that starts with the given key.

Parameters
keythe key to check
Returns
true if a key sequence starts with the key

Definition at line 532 of file tdeshortcut.cpp.

◆ contains() [2/3]

bool TDEShortcut::contains ( const KKeyNative &  key) const

Checks whether this shortcut contains a sequence that starts with the given key.

Parameters
keythe key to check
Returns
true if a key sequence starts with the key

Definition at line 537 of file tdeshortcut.cpp.

◆ contains() [3/3]

bool TDEShortcut::contains ( const KKeySequence &  keySeq) const

Checks whether this shortcut contains the given sequence.

Parameters
keySeqthe key sequence to check
Returns
true if the shortcut has the given key sequence

Definition at line 551 of file tdeshortcut.cpp.

◆ count()

uint TDEShortcut::count ( ) const

Returns the number of sequences that are in this shortcut.

Returns
the number of sequences MAX_SEQUENCES

Definition at line 500 of file tdeshortcut.cpp.

◆ init() [1/6]

bool TDEShortcut::init ( const KKey &  key)

Initializes the shortcut with the given key as its only sequence.

Parameters
keythe key to add

Definition at line 440 of file tdeshortcut.cpp.

◆ init() [2/6]

bool TDEShortcut::init ( const KKeySequence &  keySeq)

Initializes the shortcut with the given qt key sequence.

Parameters
keySeqthe qt key sequence to add

Definition at line 447 of file tdeshortcut.cpp.

◆ init() [3/6]

bool TDEShortcut::init ( const TDEShortcut &  shortcut)

Copies the given shortcut.

Parameters
shortcutthe shortcut to add

Definition at line 454 of file tdeshortcut.cpp.

◆ init() [4/6]

bool TDEShortcut::init ( const TQKeySequence &  keySeq)

Initializes the shortcut with the given qt key sequence.

Parameters
keySeqthe qt key sequence to add

Definition at line 433 of file tdeshortcut.cpp.

◆ init() [5/6]

bool TDEShortcut::init ( const TQString &  shortcut)

Initializes the key sequence with the given key sequence.

The description consists of semicolon-separated keys as used in KKeySequence::KKeySequence(const TQString&).

Parameters
shortcutthe description of the key
See also
KKeySequence::KKeySequence(const TQString&)

Definition at line 462 of file tdeshortcut.cpp.

◆ init() [6/6]

bool TDEShortcut::init ( int  keyQt)

Initializes the shortcut with the given Qt key code as the only key sequence.

Parameters
keyQtthe qt keycode
See also
TQt::Key

Definition at line 421 of file tdeshortcut.cpp.

◆ isNull()

bool TDEShortcut::isNull ( ) const

Returns true if the shortcut is null (after clear() or empty constructor).

Returns
true if the shortcut is null
See also
clear()
null()

Definition at line 517 of file tdeshortcut.cpp.

◆ keyCodeQt()

int TDEShortcut::keyCodeQt ( ) const

Returns the key code of the first key sequence, or null if there is no first key sequence.

Returns
the key code of the first sequence's first key
See also
TQt::Key
KKeySequence::keyCodeQt()

Definition at line 510 of file tdeshortcut.cpp.

◆ null()

TDEShortcut & TDEShortcut::null ( )
static

Returns a null shortcut.

Returns
the null shortcut
See also
isNull()
clear()

Definition at line 667 of file tdeshortcut.cpp.

◆ operator int()

TDEShortcut::operator int ( ) const
inline

Definition at line 847 of file tdeshortcut.h.

◆ operator TQKeySequence()

TDEShortcut::operator TQKeySequence ( ) const

Converts this shortcut to a key sequence.

The first key sequence will be taken.

Definition at line 627 of file tdeshortcut.cpp.

◆ operator!=()

bool TDEShortcut::operator!= ( const TDEShortcut &  cut) const
inline

Compares the sequences of both shortcuts.

See also
compare()

Definition at line 729 of file tdeshortcut.h.

◆ operator<()

bool TDEShortcut::operator< ( const TDEShortcut &  cut) const
inline

Compares the sequences of both shortcuts.

See also
compare()

Definition at line 736 of file tdeshortcut.h.

◆ operator=()

TDEShortcut & TDEShortcut::operator= ( const TDEShortcut &  cut)
inline

Copies the given shortcut over this shortcut.

Definition at line 665 of file tdeshortcut.h.

◆ operator==()

bool TDEShortcut::operator== ( const TDEShortcut &  cut) const
inline

Compares the sequences of both shortcuts.

See also
compare()

Definition at line 722 of file tdeshortcut.h.

◆ remove()

void TDEShortcut::remove ( const KKeySequence &  keySeq)

Removes the given key sequence from this shortcut.

Parameters
keySeqthe key sequence to remove
Since
3.3

Definition at line 572 of file tdeshortcut.cpp.

◆ seq()

const KKeySequence & TDEShortcut::seq ( uint  i) const

Returns the i'th key sequence of this shortcut.

Parameters
ithe number of the key sequence to retrieve
Returns
the i'th sequence or KKeySequence::null() if there are less than i key sequences MAX_SEQUENCES

Definition at line 505 of file tdeshortcut.cpp.

◆ setSeq()

bool TDEShortcut::setSeq ( uint  i,
const KKeySequence &  keySeq 
)

Sets the i 'th key sequence of the shortcut.

You can not introduce gaps in the list of sequences, so you must use an i <= count(). Also note that the maximum number of key sequences is MAX_SEQUENCES.

Parameters
ithe position of the new key sequence(0 <= i <= count(), 0 <= i < MAX_SEQUENCES)
keySeqthe key sequence to set
Returns
true if successful, false otherwise

Definition at line 560 of file tdeshortcut.cpp.

◆ toString()

TQString TDEShortcut::toString ( ) const

Returns a description of the shortcut as semicolon-separated ket sequences, as returned by KKeySequence::toString().

Returns
the string represenation of this shortcut
See also
KKey::toString()
KKeySequence::toString()

Definition at line 635 of file tdeshortcut.cpp.

◆ toStringInternal()

TQString TDEShortcut::toStringInternal ( const TDEShortcut *  pcutDefault = 0) const

Definition at line 648 of file tdeshortcut.cpp.

Friends And Related Function Documentation

◆ KKeyNative

friend class KKeyNative
friend

Definition at line 843 of file tdeshortcut.h.

Member Data Documentation

◆ m_nSeqs

uint TDEShortcut::m_nSeqs
protected

Definition at line 838 of file tdeshortcut.h.

◆ m_rgseq

KKeySequence TDEShortcut::m_rgseq[MAX_SEQUENCES]
protected

Definition at line 839 of file tdeshortcut.h.


The documentation for this class was generated from the following files:
  • tdeshortcut.h
  • tdeshortcut.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.