KDECore
KKey Class Reference
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win). More...
#include <kshortcut.h>
Public Types | |
enum | { MOD_FLAG_COUNT = 4 } |
enum | { QtWIN = (Qt::META) } |
enum | ModFlag { SHIFT = 0x01, CTRL = 0x02, ALT = 0x04, WIN = 0x08 } |
Public Member Functions | |
void | clear () |
int | compare (const KKey &key) const |
bool | init (uint key, uint mod) |
bool | init (const QString &key) |
bool | init (const KKey &key) |
bool | init (const QKeyEvent *keyEvent) |
bool | init (const QKeySequence &keySeq) |
bool | init (int keyQt) |
bool | isNull () const |
int | keyCodeQt () const |
KKey (uint key, uint mod) | |
KKey (const QString &key) | |
KKey (const KKey &key) | |
KKey (const QKeyEvent *keyEvent) | |
KKey (const QKeySequence &keySeq) | |
KKey (int keyQt) | |
KKey () | |
uint | modFlags () const |
bool | operator!= (const KKey &key) const |
bool | operator< (const KKey &key) const |
KKey & | operator= (const KKey &key) |
bool | operator== (const KKey &key) const |
void | simplify () |
uint | sym () const |
QString | toString () const |
QString | toStringInternal () const |
~KKey () | |
Static Public Member Functions | |
static QString | modFlagLabel (ModFlag f) |
static KKey & | null () |
Detailed Description
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).It can represent both keys which are understood by Qt as well as those which are additionally supported by the underlying system (e.g. X11).
- See also:
- KKeyNative
Definition at line 40 of file kshortcut.h.
Member Enumeration Documentation
anonymous enum |
anonymous enum |
enum KKey::ModFlag |
Flags to represent the modifiers.
You can combine modifiers by ORing them.
Definition at line 53 of file kshortcut.h.
Constructor & Destructor Documentation
KKey::KKey | ( | ) |
KKey::KKey | ( | int | keyQt | ) |
Creates a new key for the given Qt key code.
- Parameters:
-
keyQt the qt keycode
- See also:
- Qt::Key
Definition at line 44 of file kshortcut.cpp.
KKey::KKey | ( | const QKeySequence & | keySeq | ) |
Creates a new key from the first key code of the given key sequence.
- Parameters:
-
keySeq the key sequence that contains the key
Definition at line 45 of file kshortcut.cpp.
KKey::KKey | ( | const QKeyEvent * | keyEvent | ) |
Extracts the key from the given key event.
- Parameters:
-
keyEvent the key event to get the key from
Definition at line 46 of file kshortcut.cpp.
KKey::KKey | ( | const KKey & | key | ) |
KKey::KKey | ( | const QString & | key | ) |
Creates a new key from the given description.
The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.
- Parameters:
-
key the description of the key
- See also:
- KKeyServer::Sym::init()
Definition at line 48 of file kshortcut.cpp.
KKey::KKey | ( | uint | key, | |
uint | mod | |||
) |
KKey::~KKey | ( | ) |
Definition at line 50 of file kshortcut.cpp.
Member Function Documentation
void KKey::clear | ( | ) |
Clears the key.
The key is null after calling this function.
- See also:
- isNull()
Definition at line 54 of file kshortcut.cpp.
int KKey::compare | ( | const KKey & | key | ) | const |
Compares this key with the given KKey object.
Returns a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger. The returned value is the difference between the symbol or, if the symbols are equal, the difference between the encoded modifiers.
- Parameters:
-
key the key to compare with this key
- Returns:
- a negative number if the given KKey is larger, 0 if they are equal and a positive number this KKey is larger
Definition at line 152 of file kshortcut.cpp.
bool KKey::init | ( | uint | key, | |
uint | mod | |||
) |
Initializes the key with the given description.
The form of the description is "[modifier+[modifier+]]+key", for example "e", "CTRL+q" or "CTRL+ALT+DEL". Allowed modifiers are "SHIFT", "CTRL", "ALT", "WIN" and "META". "WIN" and "META" are equivalent. Modifiers are not case-sensitive.
- Parameters:
-
key the description of the key
- Returns:
- true if successful, false otherwise
- See also:
- KKeyServer::Sym::init()
Definition at line 105 of file kshortcut.cpp.
Copies the given key.
- Parameters:
-
key the key to copy
- Returns:
- true if successful, false otherwise
Definition at line 98 of file kshortcut.cpp.
Initializes the key by extracting the code from the given key event.
- Parameters:
-
keyEvent the key event to get the key from
- Returns:
- true if successful, false otherwise
Definition at line 88 of file kshortcut.cpp.
bool KKey::init | ( | const QKeySequence & | keySeq | ) |
Initializes the key with the first key code of the given key sequence.
- Parameters:
-
keySeq the key sequence that contains the key
- Returns:
- true if successful, false otherwise
Definition at line 82 of file kshortcut.cpp.
bool KKey::init | ( | int | keyQt | ) |
Initializes the key with the given Qt key code.
- Parameters:
-
keyQt the qt keycode
- Returns:
- true if successful, false otherwise
- See also:
- Qt::Key
Definition at line 67 of file kshortcut.cpp.
bool KKey::isNull | ( | ) | const |
Returns true if the key is null (after clear() or empty constructor).
- Returns:
- true if the key is null
Definition at line 148 of file kshortcut.cpp.
int KKey::keyCodeQt | ( | ) | const |
Returns the qt key code.
- Returns:
- the qt key code or 0 if there is no key set.
- See also:
- Qt::Key
Definition at line 161 of file kshortcut.cpp.
Returns a user-readable representation of the given modifiers.
- Parameters:
-
f the modifiers to convert
- Returns:
- the string representation of the modifiers
Definition at line 201 of file kshortcut.cpp.
uint KKey::modFlags | ( | ) | const |
KKey & KKey::null | ( | ) | [static] |
Compares the symbol and modifiers of both keys.
- See also:
- compare()
Definition at line 207 of file kshortcut.h.
Compares the symbol and modifiers of both keys.
- See also:
- compare()
Definition at line 213 of file kshortcut.h.
Compares the symbol and modifiers of both keys.
- See also:
- compare()
Definition at line 201 of file kshortcut.h.
void KKey::simplify | ( | ) |
For internal use only.
uint KKey::sym | ( | ) | const |
QString KKey::toString | ( | ) | const |
Returns a human-readable representation of the key in the form "modifier+key".
Note that the representation is localised, use toStringInternal() for cases like saving to configuration files.
- Returns:
- the string representation of the key
- See also:
- toStringInternal()
Definition at line 166 of file kshortcut.cpp.
QString KKey::toStringInternal | ( | ) | const |
Returns an untranslated text representation of the key in the form "modifier+key", suitable e.g.
for saving in configuration files.
Definition at line 178 of file kshortcut.cpp.
The documentation for this class was generated from the following files: