KShortcut Class Reference
from PyKDE4.kdeui import *
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.
KAction *closeAction = KStandardAction.close(this, SLOT( close() ), actionCollection());
KShortcut closeShortcut = closeAction->shortcut();
closeShortcut.setAlternate(Qt.Key_Escape);
closeAction->setShortcut(closeShortcut);
Enumerations |
EmptyHandling | { KeepEmpty, RemoveEmpty } |
Methods |
| __init__ (self) |
| __init__ (self, QKeySequence primary) |
| __init__ (self, QKeySequence primary, QKeySequence alternate) |
| __init__ (self, int keyQtPri, int keyQtAlt=0) |
| __init__ (self, KShortcut other) |
| __init__ (self, QString description) |
| __init__ (self, [QKeySequence] seqs) |
QKeySequence | alternate (self) |
bool | conflictsWith (self, QKeySequence needle) |
bool | contains (self, QKeySequence needle) |
bool | isEmpty (self) |
bool | operator != (self, KShortcut other) |
bool | operator == (self, KShortcut other) |
QKeySequence | primary (self) |
| remove (self, QKeySequence keySeq, KShortcut.EmptyHandling handleEmpty=KShortcut.RemoveEmpty) |
| setAlternate (self, QKeySequence keySeq) |
| setPrimary (self, QKeySequence keySeq) |
[QKeySequence] | toList (self, KShortcut.EmptyHandling handleEmpty=KShortcut.RemoveEmpty) |
QString | toString (self) |
QString | toString (self, QKeySequence.SequenceFormat format) |
Method Documentation
__init__ |
( |
self, |
|
|
|
int |
keyQtPri, |
|
|
int |
keyQtAlt=0 |
|
) |
|
|
|
__init__ |
( |
self, |
|
|
|
QString |
description |
|
) |
|
|
|
Returns the alternate key sequence of this shortcut.
- Returns:
- alternate key sequence
Returns whether at least one of the key sequences conflicts witho needle.
- Returns:
- whether this shortcut conflicts with needle
Returns whether at least one of the key sequences is equal to needle.
- Returns:
- whether this shortcut contains needle
Returns whether this shortcut contains any nonempty key sequences.
- Returns:
- whether this shortcut is empty
Returns the primary key sequence of this shortcut.
- Returns:
- primary key sequence
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
|
Set the alternate key sequence of this shortcut to the given key sequence.
- Parameters:
-
| keySeq | set alternate key sequence to this
|
Set the primary key sequence of this shortcut to the given key sequence.
- Parameters:
-
| keySeq | set primary key sequence to this
|
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>
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
- See also:
- QKeySequence.toString()
- See also:
- KShortcut(const QString &description)
- Since:
- KDE 4.2
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
- See also:
- QKeySequence.toString()
- See also:
- KShortcut(const QString &description)
- Since:
- KDE 4.2
Enumeration Documentation