![]() |
Qt 6.x
The Qt SDK
|
#include <qshortcutmap_p.h>
Public Types | |
typedef bool(* | ContextMatcher) (QObject *object, Qt::ShortcutContext context) |
Public Member Functions | |
QShortcutMap () | |
~QShortcutMap () | |
int | addShortcut (QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher) |
int | removeShortcut (int id, QObject *owner, const QKeySequence &key=QKeySequence()) |
int | setShortcutEnabled (bool enable, int id, QObject *owner, const QKeySequence &key=QKeySequence()) |
int | setShortcutAutoRepeat (bool on, int id, QObject *owner, const QKeySequence &key=QKeySequence()) |
QKeySequence::SequenceMatch | state () |
bool | tryShortcut (QKeyEvent *e) |
bool | hasShortcutForKeySequence (const QKeySequence &seq) const |
QList< QKeySequence > | keySequences (bool getAll=false) const |
Definition at line 35 of file qshortcutmap_p.h.
typedef bool(* QShortcutMap::ContextMatcher) (QObject *object, Qt::ShortcutContext context) |
Definition at line 42 of file qshortcutmap_p.h.
QShortcutMap::QShortcutMap | ( | ) |
QShortcutMap constructor.
Definition at line 106 of file qshortcutmap.cpp.
QShortcutMap::~QShortcutMap | ( | ) |
QShortcutMap destructor.
Definition at line 115 of file qshortcutmap.cpp.
int QShortcutMap::addShortcut | ( | QObject * | owner, |
const QKeySequence & | key, | ||
Qt::ShortcutContext | context, | ||
ContextMatcher | matcher | ||
) |
Adds a shortcut to the global map. Returns the id of the newly added shortcut.
Definition at line 123 of file qshortcutmap.cpp.
References context, d, it, matcher, Q_ASSERT_X, and qCDebug.
bool QShortcutMap::hasShortcutForKeySequence | ( | const QKeySequence & | seq | ) | const |
Determines if an enabled shortcut has a matching key sequence.
Definition at line 364 of file qshortcutmap.cpp.
References d, QKeySequence::ExactMatch, and it.
QList< QKeySequence > QShortcutMap::keySequences | ( | bool | getAll = false | ) | const |
Definition at line 639 of file qshortcutmap.cpp.
References Qt::ApplicationShortcut, d, QGuiApplication::focusObject(), QGuiApplication::focusWindow(), keys, QObject::parent(), qobject_cast< QWindow * >(), Qt::WidgetWithChildrenShortcut, and Qt::WindowShortcut.
int QShortcutMap::removeShortcut | ( | int | id, |
QObject * | owner, | ||
const QKeySequence & | key = QKeySequence() |
||
) |
Removes a shortcut from the global map. If owner is \nullptr, all entries in the map with the key sequence specified is removed. If key is null, all sequences for owner is removed from the map. If id is 0, any identical key sequences owned by owner are removed. Returns the number of sequences removed from the map.
Definition at line 147 of file qshortcutmap.cpp.
References allKeys(), d, debug, i, qCDebug, and qScopeGuard().
int QShortcutMap::setShortcutAutoRepeat | ( | bool | on, |
int | id, | ||
QObject * | owner, | ||
const QKeySequence & | key = QKeySequence() |
||
) |
Changes the auto repeat state of a shortcut to enable. If owner is \nullptr, all entries in the map with the key sequence specified is removed. If key is null, all sequences for owner is removed from the map. If id is 0, any identical key sequences owned by owner are changed. Returns the number of sequences which are matched in the map.
Definition at line 230 of file qshortcutmap.cpp.
References allKeys(), d, i, and qCDebug.
int QShortcutMap::setShortcutEnabled | ( | bool | enable, |
int | id, | ||
QObject * | owner, | ||
const QKeySequence & | key = QKeySequence() |
||
) |
Changes the enable state of a shortcut to enable. If owner is \nullptr, all entries in the map with the key sequence specified is removed. If key is null, all sequences for owner is removed from the map. If id is 0, any identical key sequences owned by owner are changed. Returns the number of sequences which are matched in the map.
Definition at line 194 of file qshortcutmap.cpp.
References allKeys(), d, i, and qCDebug.
QKeySequence::SequenceMatch QShortcutMap::state | ( | ) |
Returns the current state of the statemachine
Definition at line 271 of file qshortcutmap.cpp.
References d.
Referenced by QWindowSystemInterface::handleShortcutEvent(), qt_sendShortcutOverrideEvent(), and tryShortcut().
bool QShortcutMap::tryShortcut | ( | QKeyEvent * | e | ) |
Uses nextState(QKeyEvent) to check for a grabbed shortcut.
If so, it is dispatched using dispatchEvent().
Returns true if a shortcut handled the event.
Definition at line 286 of file qshortcutmap.cpp.
References d, e, QKeySequence::ExactMatch, Qt::Key_unknown, QKeySequence::NoMatch, QKeySequence::PartialMatch, and state().
Referenced by QWindowSystemInterface::handleShortcutEvent(), and qt_sendShortcutOverrideEvent().