Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QShortcutMap Class Reference

#include <qshortcutmap_p.h>

+ Collaboration diagram for QShortcutMap:

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< QKeySequencekeySequences (bool getAll=false) const
 

Detailed Description

Definition at line 35 of file qshortcutmap_p.h.

Member Typedef Documentation

◆ ContextMatcher

typedef bool(* QShortcutMap::ContextMatcher) (QObject *object, Qt::ShortcutContext context)

Definition at line 42 of file qshortcutmap_p.h.

Constructor & Destructor Documentation

◆ QShortcutMap()

QShortcutMap::QShortcutMap ( )

QShortcutMap constructor.

Definition at line 106 of file qshortcutmap.cpp.

◆ ~QShortcutMap()

QShortcutMap::~QShortcutMap ( )

QShortcutMap destructor.

Definition at line 115 of file qshortcutmap.cpp.

Member Function Documentation

◆ addShortcut()

int QShortcutMap::addShortcut ( QObject * owner,
const QKeySequence & keySequence,
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, QKeySequence::isEmpty(), it, matcher, Q_ASSERT_X, and qCDebug.

+ Here is the call graph for this function:

◆ hasShortcutForKeySequence()

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.

◆ keySequences()

QList< QKeySequence > QShortcutMap::keySequences ( bool getAll = false) const

Definition at line 609 of file qshortcutmap.cpp.

References Qt::ApplicationShortcut, d, QGuiApplication::focusObject(), QGuiApplication::focusWindow(), keys, QObject::parent(), Qt::WidgetWithChildrenShortcut, and Qt::WindowShortcut.

+ Here is the call graph for this function:

◆ removeShortcut()

int QShortcutMap::removeShortcut ( int id,
QObject * owner,
const QKeySequence & keySequence = 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, QShortcutEntry::id, QKeySequence::isEmpty(), qCDebug, and qScopeGuard().

+ Here is the call graph for this function:

◆ setShortcutAutoRepeat()

int QShortcutMap::setShortcutAutoRepeat ( bool on,
int id,
QObject * owner,
const QKeySequence & keySequence = 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(), QShortcutEntry::autorepeat, d, i, QKeySequence::isEmpty(), and qCDebug.

+ Here is the call graph for this function:

◆ setShortcutEnabled()

int QShortcutMap::setShortcutEnabled ( bool enable,
int id,
QObject * owner,
const QKeySequence & keySequence = 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, QShortcutEntry::enabled, i, QKeySequence::isEmpty(), and qCDebug.

+ Here is the call graph for this function:

◆ state()

QKeySequence::SequenceMatch QShortcutMap::state ( )

Returns the current state of the statemachine

Definition at line 271 of file qshortcutmap.cpp.

References d.

Referenced by tryShortcut().

+ Here is the caller graph for this function:

◆ 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.

See also
nextState, dispatchEvent

Definition at line 286 of file qshortcutmap.cpp.

References d, QKeySequence::ExactMatch, QKeyEvent::key(), Qt::Key_unknown, QKeySequence::NoMatch, QKeySequence::PartialMatch, and state().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: