org.kde.koala

Class KShortcut

public class KShortcut extends Object implements QtSupport

The KShortcut 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 KShortcut 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 KAction. For example, the below code binds the escape key to the close action.
  KAction closeAction = KStdAction.close( this, SLOT("close()"), actionCollection() );
  KShortcut closeShortcut = closeAction.shortcut();
  closeShortcut.append( KKey(Key_Escape));
  closeAction.setShortcut(closeShortcut);
 
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.

UNKNOWN: The KShortcut class is used to represent a keyboard shortcut to an action.

Field Summary
static intMAX_SEQUENCES
The maximum number of key sequences that can be contained in a KShortcut.
Constructor Summary
protected KShortcut(Class dummy)
KShortcut()
Creates a new null shortcut.
KShortcut(int keyQt)
Creates a new shortcut with the given Qt key code as the only key sequence.
KShortcut(QKeySequence keySeq)
Creates a new shortcut that contains only the given qt key sequence.
KShortcut(KKey key)
Creates a new shortcut that contains only the given key in its only sequence.
KShortcut(KKeySequence keySeq)
Creates a new shortcut that contains only the given key sequence.
KShortcut(KShortcut shortcut)
Copies the given shortcut.
KShortcut(String shortcut)
Creates a new key sequence that contains the given key sequence.
Method Summary
booleanappend(KKeySequence keySeq)
Appends the given key sequence.
booleanappend(KKey spec)
Appends the given key
booleanappend(KShortcut cut)
Appends the sequences from the given shortcut.
voidclear()
Clears the shortcut.
intcompare(KShortcut shortcut)
Compares this object with the given shortcut.
booleancontains(KKey key)
Checks whether this shortcut contains a sequence that starts with the given key.
booleancontains(KKeySequence keySeq)
Checks whether this shortcut contains the given sequence.
intcount()
Returns the number of sequences that are in this shortcut.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
protected voidfinalize()
Deletes the wrapped C++ instance
booleaninit(int keyQt)
Initializes the shortcut with the given Qt key code as the only key sequence.
booleaninit(QKeySequence keySeq)
Initializes the shortcut with the given qt key sequence.
booleaninit(KKey key)
Initializes the shortcut with the given key as its only sequence.
booleaninit(KKeySequence keySeq)
Initializes the shortcut with the given qt key sequence.
booleaninit(KShortcut shortcut)
Copies the given shortcut.
booleaninit(String shortcut)
Initializes the key sequence with the given key sequence.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisNull()
Returns true if the shortcut is null (after clear() or empty constructor).
intkeyCodeQt()
Returns the key code of the first key sequence, or null if there is no first key sequence.
static KShortcutnil()
Returns a null shortcut.
booleanop_equals(KShortcut cut)
Compares the sequences of both shortcuts.
booleanop_lt(KShortcut cut)
Compares the sequences of both shortcuts.
booleanop_not_equals(KShortcut cut)
Compares the sequences of both shortcuts.
voidremove(KKeySequence keySeq)
Removes the given key sequence from this shortcut
KKeySequenceseq(int i)
Returns the i'th key sequence of this shortcut.
booleansetSeq(int i, KKeySequence keySeq)
Sets the i 'th key sequence of the shortcut.
StringtoString()
Returns a description of the shortcut as semicolon-separated ket sequences, as returned by KKeySequence.toString().
StringtoStringInternal(KShortcut pcutDefault)
StringtoStringInternal()

Field Detail

MAX_SEQUENCES

public static final int MAX_SEQUENCES
The maximum number of key sequences that can be contained in a KShortcut.

UNKNOWN: The maximum number of key sequences that can be contained in a KShortcut.

Constructor Detail

KShortcut

protected KShortcut(Class dummy)

KShortcut

public KShortcut()
Creates a new null shortcut.

See Also: KShortcut KShortcut KShortcut

UNKNOWN: Creates a new null shortcut.

KShortcut

public KShortcut(int keyQt)
Creates a new shortcut with the given Qt key code as the only key sequence.

Parameters: keyQt the qt keycode

See Also: org.kde.qt.Qt#Key

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

KShortcut

public KShortcut(QKeySequence keySeq)
Creates a new shortcut that contains only the given qt key sequence.

Parameters: keySeq the qt key sequence to add

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

KShortcut

public KShortcut(KKey key)
Creates a new shortcut that contains only the given key in its only sequence.

Parameters: key the key to add

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

KShortcut

public KShortcut(KKeySequence keySeq)
Creates a new shortcut that contains only the given key sequence.

Parameters: keySeq the key sequence to add

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

KShortcut

public KShortcut(KShortcut shortcut)
Copies the given shortcut.

Parameters: shortcut the shortcut to add

UNKNOWN: Copies the given shortcut.

KShortcut

public KShortcut(String shortcut)
Creates a new key sequence that contains the given key sequence. The description consists of semicolon-separated keys as used in KKeySequence.KKeySequence(String).

Parameters: shortcut the description of the key

See Also: (const

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

Method Detail

append

public boolean append(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: keySeq the key sequence to add

Returns: true if successful, false otherwise

See Also: KShortcut

UNKNOWN: Appends the given key sequence.

append

public boolean append(KKey spec)
Appends the given key

Parameters: spec the key to add

Returns: true if successful, false otherwise

See Also: KShortcut MAX_SEQUENCES

UNKNOWN: Appends the given key

append

public boolean append(KShortcut cut)
Appends the sequences from the given shortcut.

Parameters: cut the shortcut to append

Returns: true if successful, false otherwise

See Also: MAX_SEQUENCES

UNKNOWN: Appends the sequences from the given shortcut.

clear

public void clear()
Clears the shortcut. The shortcut is null after calling this function.

See Also: KShortcut

UNKNOWN: Clears the shortcut.

compare

public int compare(KShortcut shortcut)
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: shortcut the shortcut to compare to

Returns: a negative number if the given KShortcut is larger, 0 if they are equal and a positive number this KShortcut is larger

See Also: KKey KKeyShortcut#compare

UNKNOWN: Compares this object with the given shortcut.

contains

public boolean contains(KKey key)
Checks whether this shortcut contains a sequence that starts with the given key.

Parameters: key the key to check

Returns: true if a key sequence starts with the key

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

contains

public boolean contains(KKeySequence keySeq)
Checks whether this shortcut contains the given sequence.

Parameters: keySeq the key sequence to check

Returns: true if the shortcut has the given key sequence

UNKNOWN: Checks whether this shortcut contains the given sequence.

count

public int count()
Returns the number of sequences that are in this shortcut.

Returns: the number of sequences MAX_SEQUENCES

UNKNOWN: Returns the number of sequences that are in this shortcut.

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()

finalize

protected void finalize()
Deletes the wrapped C++ instance

init

public boolean init(int keyQt)
Initializes the shortcut with the given Qt key code as the only key sequence.

Parameters: keyQt the qt keycode

See Also: org.kde.qt.Qt#Key

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

init

public boolean init(QKeySequence keySeq)
Initializes the shortcut with the given qt key sequence.

Parameters: keySeq the qt key sequence to add

UNKNOWN: Initializes the shortcut with the given qt key sequence.

init

public boolean init(KKey key)
Initializes the shortcut with the given key as its only sequence.

Parameters: key the key to add

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

init

public boolean init(KKeySequence keySeq)
Initializes the shortcut with the given qt key sequence.

Parameters: keySeq the qt key sequence to add

UNKNOWN: Initializes the shortcut with the given qt key sequence.

init

public boolean init(KShortcut shortcut)
Copies the given shortcut.

Parameters: shortcut the shortcut to add

UNKNOWN: Copies the given shortcut.

init

public boolean init(String shortcut)
Initializes the key sequence with the given key sequence. The description consists of semicolon-separated keys as used in KKeySequence.KKeySequence(String).

Parameters: shortcut the description of the key

See Also: (const

UNKNOWN: Initializes the key sequence with the given key sequence.

isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?

isNull

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

Returns: true if the shortcut is null

See Also: KShortcut KShortcut

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

keyCodeQt

public int keyCodeQt()
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: org.kde.qt.Qt#Key KKeySequence

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

nil

public static KShortcut nil()
Returns a null shortcut.

Returns: the null shortcut

See Also: KShortcut KShortcut

UNKNOWN: Returns a null shortcut.

op_equals

public boolean op_equals(KShortcut cut)
Compares the sequences of both shortcuts.

See Also: KShortcut

UNKNOWN: Compares the sequences of both shortcuts.

op_lt

public boolean op_lt(KShortcut cut)
Compares the sequences of both shortcuts.

See Also: KShortcut

UNKNOWN: Compares the sequences of both shortcuts.

op_not_equals

public boolean op_not_equals(KShortcut cut)
Compares the sequences of both shortcuts.

See Also: KShortcut

UNKNOWN: Compares the sequences of both shortcuts.

remove

public void remove(KKeySequence keySeq)
Removes the given key sequence from this shortcut

Parameters: keySeq the key sequence to remove

UNKNOWN: Removes the given key sequence from this shortcut

seq

public KKeySequence seq(int i)
Returns the i'th key sequence of this shortcut.

Parameters: i the 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

UNKNOWN: Returns the i'th key sequence of this shortcut.

setSeq

public boolean setSeq(int i, 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: i the position of the new key sequence(0 <= i <= count(), 0 <= i < MAX_SEQUENCES) keySeq the key sequence to set

Returns: true if successful, false otherwise

UNKNOWN: Sets the i 'th key sequence of the shortcut.

toString

public String toString()
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 KKeySequence

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

toStringInternal

public String toStringInternal(KShortcut pcutDefault)

UNKNOWN:

toStringInternal

public String toStringInternal()