| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 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 QT3DINPUT_QKEYEVENT_H |
| 5 | #define QT3DINPUT_QKEYEVENT_H |
| 6 | |
| 7 | #include <Qt3DInput/qt3dinput_global.h> |
| 8 | #include <QtCore/QObject> |
| 9 | #include <QtGui/QKeyEvent> |
| 10 | #include <memory> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | namespace Qt3DInput { |
| 15 | |
| 16 | class QKeyEventPrivate; |
| 17 | class QKeyEvent; |
| 18 | |
| 19 | typedef QSharedPointer<QKeyEvent> QKeyEventPtr; |
| 20 | |
| 21 | class Q_3DINPUTSHARED_EXPORT QKeyEvent : public QObject |
| 22 | { |
| 23 | Q_OBJECT |
| 24 | Q_PROPERTY(int key READ key CONSTANT) |
| 25 | Q_PROPERTY(QString text READ text CONSTANT) |
| 26 | Q_PROPERTY(int modifiers READ modifiers CONSTANT) |
| 27 | Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat CONSTANT) |
| 28 | Q_PROPERTY(int count READ count CONSTANT) |
| 29 | Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT) |
| 30 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) |
| 31 | |
| 32 | public: |
| 33 | explicit QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1); |
| 34 | explicit QKeyEvent(const QT_PREPEND_NAMESPACE(QKeyEvent) &ke); |
| 35 | ~QKeyEvent(); |
| 36 | |
| 37 | inline int key() const { return m_event->key(); } |
| 38 | inline QString text() const { return m_event->text(); } |
| 39 | inline int modifiers() const { return int(m_event->modifiers().toInt()); } |
| 40 | inline bool isAutoRepeat() const { return m_event->isAutoRepeat(); } |
| 41 | inline int count() const { return m_event->count(); } |
| 42 | inline quint32 nativeScanCode() const { return m_event->nativeScanCode(); } |
| 43 | inline bool isAccepted() const { return m_event->isAccepted(); } |
| 44 | inline void setAccepted(bool accepted) { m_event->setAccepted(accepted); } |
| 45 | inline QEvent::Type type() const { return m_event->type(); } |
| 46 | #if QT_CONFIG(shortcut) |
| 47 | Q_INVOKABLE bool matches(QKeySequence::StandardKey key_) const { return m_event->matches(key: key_); } |
| 48 | #endif |
| 49 | |
| 50 | private: |
| 51 | std::unique_ptr<QT_PREPEND_NAMESPACE(QKeyEvent)> m_event; |
| 52 | }; |
| 53 | |
| 54 | } // namespace Qt3DInput |
| 55 | |
| 56 | QT_END_NAMESPACE |
| 57 | |
| 58 | #endif // QT3DINPUT_QKEYEVENT_H |
| 59 |
