Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qshortcutmap_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSHORTCUTMAP_P_H
5#define QSHORTCUTMAP_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include "QtGui/qkeysequence.h"
20#include "QtCore/qlist.h"
21#include "QtCore/qscopedpointer.h"
22
24
25QT_BEGIN_NAMESPACE
26
27// To enable dump output uncomment below
28//#define Dump_QShortcutMap
29
30class QKeyEvent;
31struct QShortcutEntry;
33class QObject;
34
35class Q_GUI_EXPORT QShortcutMap
36{
37 Q_DECLARE_PRIVATE(QShortcutMap)
38public:
39 QShortcutMap();
40 ~QShortcutMap();
41
42 typedef bool (*ContextMatcher)(QObject *object, Qt::ShortcutContext context);
43
44 int addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher);
45 int removeShortcut(int id, QObject *owner, const QKeySequence &key = QKeySequence());
46 int setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key = QKeySequence());
47 int setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key = QKeySequence());
48
50
51 bool tryShortcut(QKeyEvent *e);
52 bool hasShortcutForKeySequence(const QKeySequence &seq) const;
53 QList<QKeySequence> keySequences(bool getAll = false) const;
54
55#ifdef Dump_QShortcutMap
56 void dumpMap() const;
57#endif
58
59private:
60 void resetState();
61 QKeySequence::SequenceMatch nextState(QKeyEvent *e);
62 void dispatchEvent(QKeyEvent *e);
63
64 QKeySequence::SequenceMatch find(QKeyEvent *e, int ignoredModifiers = 0);
65 QList<const QShortcutEntry *> matches() const;
66 void createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, int ignoredModifiers);
67 void clearSequence(QList<QKeySequence> &ksl);
68 int translateModifiers(Qt::KeyboardModifiers modifiers);
69
71};
72
73QT_END_NAMESPACE
74
75#endif // QSHORTCUTMAP_P_H
QScopedPointer< QImageIOHandlerPrivate > d_ptr
Definition qlist.h:80
QList< const QShortcutEntry * > identicals
QKeySequence prevSequence
QList< QKeySequence > newEntries
QList< QShortcutEntry > shortcuts
QList< QKeySequence > currentSequences
QKeySequence::SequenceMatch currentState
bool hasShortcutForKeySequence(const QKeySequence &seq) const
int setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key=QKeySequence())
int removeShortcut(int id, QObject *owner, const QKeySequence &key=QKeySequence())
int setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key=QKeySequence())
int addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher)
bool tryShortcut(QKeyEvent *e)
QList< QKeySequence > keySequences(bool getAll=false) const
QKeySequence::SequenceMatch state()
bool(* ContextMatcher)(QObject *object, Qt::ShortcutContext context)
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
Q_DECLARE_TYPEINFO(QShortcutEntry, Q_RELOCATABLE_TYPE)
QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a, QShortcutMap::ContextMatcher m)
bool correctContext() const
QShortcutEntry(const QKeySequence &k)
Qt::ShortcutContext context
QKeySequence keySequence
bool operator<(const QShortcutEntry &f) const