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// Qt-Security score:significant reason:default
4
5#ifndef QSHORTCUTMAP_P_H
6#define QSHORTCUTMAP_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include "QtGui/qkeysequence.h"
21#include "QtCore/qlist.h"
22#include "QtCore/qscopedpointer.h"
23
25
26QT_BEGIN_NAMESPACE
27
28// To enable dump output uncomment below
29//#define Dump_QShortcutMap
30
31class QKeyEvent;
32struct QShortcutEntry;
34class QObject;
35
36class Q_GUI_EXPORT QShortcutMap
37{
38 Q_DECLARE_PRIVATE(QShortcutMap)
39public:
40 QShortcutMap();
41 ~QShortcutMap();
42
43 typedef bool (*ContextMatcher)(QObject *object, Qt::ShortcutContext context);
44
45 int addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher);
46 int removeShortcut(int id, QObject *owner, const QKeySequence &key = QKeySequence());
47 int setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key = QKeySequence());
48 int setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key = QKeySequence());
49
51
52 bool tryShortcut(QKeyEvent *e);
53 bool hasShortcutForKeySequence(const QKeySequence &seq) const;
54 QList<QKeySequence> keySequences(bool getAll = false) const;
55
56#ifdef Dump_QShortcutMap
57 void dumpMap() const;
58#endif
59
60private:
61 void resetState();
62 QKeySequence::SequenceMatch nextState(QKeyEvent *e);
63 void dispatchEvent(QKeyEvent *e);
64
65 QKeySequence::SequenceMatch find(QKeyEvent *e, int ignoredModifiers = 0);
66 QList<const QShortcutEntry *> matches() const;
67 void createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, int ignoredModifiers);
68 void clearSequence(QList<QKeySequence> &ksl);
69 int translateModifiers(Qt::KeyboardModifiers modifiers);
70
71 QScopedPointer<QShortcutMapPrivate> d_ptr;
72};
73
74QT_END_NAMESPACE
75
76#endif // QSHORTCUTMAP_P_H
Definition qlist.h:81
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)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
QT_REQUIRE_CONFIG(shortcut)
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