File indexing completed on 2024-04-14 03:55:48

0001 /*
0002     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #ifndef KATEVI_KEYEVENT_H
0007 #define KATEVI_KEYEVENT_H
0008 
0009 #include <QKeyEvent>
0010 
0011 namespace KateVi
0012 {
0013 
0014 /** QEvent wrapper for copying/storing key events.
0015  *  With Qt6 QEvent itself is no longer copyable/movable and therefore
0016  *  cannot be held inside containers.
0017  */
0018 class KeyEvent
0019 {
0020 public:
0021     QEvent::Type type() const;
0022     Qt::KeyboardModifiers modifiers() const;
0023     int key() const;
0024     QString text() const;
0025 
0026     static KeyEvent fromQKeyEvent(const QKeyEvent &e);
0027 
0028 private:
0029     QEvent::Type m_type = QEvent::None;
0030     Qt::KeyboardModifiers m_modifiers = Qt::NoModifier;
0031     int m_key = 0;
0032     QString m_text;
0033 };
0034 
0035 }
0036 
0037 #endif // KATEVI_KEYEVENT_H