KDEUI
#include <kshortcut.h>
Public Types | |
enum | EmptyHandling { KeepEmpty = 0, RemoveEmpty } |
Public Member Functions | |
KShortcut () | |
KShortcut (const QKeySequence &primary) | |
KShortcut (const QKeySequence &primary, const QKeySequence &alternate) | |
KShortcut (int keyQtPri, int keyQtAlt=0) | |
KShortcut (const KShortcut &other) | |
KShortcut (const QString &description) | |
KShortcut (const QList< QKeySequence > &seqs) | |
~KShortcut () | |
Query methods | |
QKeySequence | primary () const |
QKeySequence | alternate () const |
bool | isEmpty () const |
bool | contains (const QKeySequence &needle) const |
bool | conflictsWith (const QKeySequence &needle) const |
QString | toString () const |
QString | toString (QKeySequence::SequenceFormat format) const |
bool | operator== (const KShortcut &other) const |
bool | operator!= (const KShortcut &other) const |
operator QList< QKeySequence > () const | |
QList< QKeySequence > | toList (enum EmptyHandling handleEmpty=RemoveEmpty) const |
operator QVariant () const | |
Mutator methods | |
void | setPrimary (const QKeySequence &keySeq) |
void | setAlternate (const QKeySequence &keySeq) |
void | remove (const QKeySequence &keySeq, enum EmptyHandling handleEmpty=RemoveEmpty) |
KShortcut & | operator= (const KShortcut &other) |
Detailed Description
Represents a keyboard shortcut.
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 sequence which will also activate the action it's associated with, 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.
Definition at line 57 of file kshortcut.h.
Member Enumeration Documentation
An enum about the behavior of operations that treat a KShortcut like a list of QKeySequences.
Definition at line 63 of file kshortcut.h.
Constructor & Destructor Documentation
KShortcut::KShortcut | ( | ) |
Creates a new empty shortcut.
Definition at line 44 of file kshortcut.cpp.
|
explicit |
Creates a new shortcut that contains the given Qt key sequence as primary shortcut.
- Parameters
-
primary Qt key sequence to add
Definition at line 50 of file kshortcut.cpp.
KShortcut::KShortcut | ( | const QKeySequence & | primary, |
const QKeySequence & | alternate | ||
) |
Creates a new shortcut with the given Qt key sequences as primary and secondary shortcuts.
- See also
- Qt::Key
Definition at line 57 of file kshortcut.cpp.
|
explicit |
Creates a new shortcut with the given Qt key codes as primary and secondary shortcuts.
You can only assign single-key shortcuts this way.
- See also
- Qt::Key
Definition at line 65 of file kshortcut.cpp.
KShortcut::KShortcut | ( | const KShortcut & | other | ) |
Copy constructor.
Definition at line 73 of file kshortcut.cpp.
|
explicit |
Creates a new shortcut that contains the key sequences described in description
.
The format of description is the same as used in QKeySequence::fromString(const QString&). Up to two key sequences separated by a semicolon followed by a space "; " may be given.
- Parameters
-
description the description of key sequence(s)
Definition at line 90 of file kshortcut.cpp.
|
explicit |
Creates a new shortcut with the given Qt key sequences.
The first sequence in the list is considered to be the primary sequence, the second one the alternate.
- Parameters
-
seqs List of key sequeces.
Definition at line 80 of file kshortcut.cpp.
KShortcut::~KShortcut | ( | ) |
Destructor.
Definition at line 129 of file kshortcut.cpp.
Member Function Documentation
QKeySequence KShortcut::alternate | ( | ) | const |
Returns the alternate key sequence of this shortcut.
- Returns
- alternate key sequence
Definition at line 139 of file kshortcut.cpp.
bool KShortcut::conflictsWith | ( | const QKeySequence & | needle | ) | const |
Returns whether at least one of the key sequences conflicts witho needle
.
- Returns
- whether this shortcut conflicts with
needle
Definition at line 156 of file kshortcut.cpp.
bool KShortcut::contains | ( | const QKeySequence & | needle | ) | const |
Returns whether at least one of the key sequences is equal to needle
.
- Returns
- whether this shortcut contains
needle
Definition at line 149 of file kshortcut.cpp.
bool KShortcut::isEmpty | ( | ) | const |
Returns whether this shortcut contains any nonempty key sequences.
- Returns
- whether this shortcut is empty
Definition at line 144 of file kshortcut.cpp.
KShortcut::operator QList< QKeySequence > | ( | ) | const |
Returns shortcut as QList<QKeySequence>, and is equivalent to toList(RemoveEmpty).
Be aware that empty shortcuts will not be included in the list; due to this, conversion operations like KShortcut b = (QList<QKeySequence>)KShortcut a will not always result in b == a.
- Returns
- the shortcut converted to a QList<QKeySequence>
Definition at line 228 of file kshortcut.cpp.
KShortcut::operator QVariant | ( | ) | const |
Returns shortcut as QVariant.
Definition at line 265 of file kshortcut.cpp.
Definition at line 223 of file kshortcut.cpp.
Assignment operator.
Definition at line 211 of file kshortcut.cpp.
Definition at line 218 of file kshortcut.cpp.
QKeySequence KShortcut::primary | ( | ) | const |
Returns the primary key sequence of this shortcut.
- Returns
- primary key sequence
Definition at line 134 of file kshortcut.cpp.
void KShortcut::remove | ( | const QKeySequence & | keySeq, |
enum EmptyHandling | handleEmpty = RemoveEmpty |
||
) |
Remove keySeq
from this shortcut.
If handleEmpty
equals RemoveEmpty, following key sequences will move up to take the place of keySeq
. Otherwise, key sequences equal to keySeq
will be set to empty.
- Parameters
-
keySeq remove this key sequence from the shortcut
Definition at line 194 of file kshortcut.cpp.
void KShortcut::setAlternate | ( | const QKeySequence & | keySeq | ) |
Set the alternate key sequence of this shortcut to the given key sequence.
- Parameters
-
keySeq set alternate key sequence to this
Definition at line 189 of file kshortcut.cpp.
void KShortcut::setPrimary | ( | const QKeySequence & | keySeq | ) |
Set the primary key sequence of this shortcut to the given key sequence.
- Parameters
-
keySeq set primary key sequence to this
Definition at line 184 of file kshortcut.cpp.
QList< QKeySequence > KShortcut::toList | ( | enum EmptyHandling | handleEmpty = RemoveEmpty | ) | const |
The same as operator QList<QKeySequence>() If handleEmpty
equals RemoveEmpty, empty key sequences will be left out of the result.
Otherwise, empy key sequences will be included; you can be sure that shortcut.alternate() == shortcut.toList(KeepEmpty).at(1).
- Returns
- the shortcut converted to a QList<QKeySequence>
Definition at line 233 of file kshortcut.cpp.
QString KShortcut::toString | ( | ) | const |
Returns a description of the shortcut as a semicolon-separated list of key sequences, as returned by QKeySequence::toString().
- Returns
- the string represenation of this shortcut
Definition at line 249 of file kshortcut.cpp.
QString KShortcut::toString | ( | QKeySequence::SequenceFormat | format | ) | const |
Returns a description of the shortcut as a semicolon-separated list of key sequences, as returned by QKeySequence::toString().
- Returns
- the string represenation of this shortcut
- Since
- KDE 4.2
Definition at line 254 of file kshortcut.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.