| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> |
| 3 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 4 | */ |
| 5 | |
| 6 | #ifndef KATEVI_KEYEVENT_H |
| 7 | #define KATEVI_KEYEVENT_H |
| 8 | |
| 9 | #include <QKeyEvent> |
| 10 | |
| 11 | namespace KateVi |
| 12 | { |
| 13 | |
| 14 | /** QEvent wrapper for copying/storing key events. |
| 15 | * With Qt6 QEvent itself is no longer copyable/movable and therefore |
| 16 | * cannot be held inside containers. |
| 17 | */ |
| 18 | class KeyEvent |
| 19 | { |
| 20 | public: |
| 21 | QEvent::Type type() const; |
| 22 | Qt::KeyboardModifiers modifiers() const; |
| 23 | int key() const; |
| 24 | QString text() const; |
| 25 | |
| 26 | static KeyEvent fromQKeyEvent(const QKeyEvent &e); |
| 27 | |
| 28 | private: |
| 29 | QEvent::Type m_type = QEvent::None; |
| 30 | Qt::KeyboardModifiers m_modifiers = Qt::NoModifier; |
| 31 | int m_key = 0; |
| 32 | QString m_text; |
| 33 | }; |
| 34 | |
| 35 | } |
| 36 | |
| 37 | #endif // KATEVI_KEYEVENT_H |
| 38 | |