File indexing completed on 2024-12-22 04:41:13
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #pragma once 0019 0020 #include <QKeyEvent> 0021 #include <QObject> 0022 0023 /** 0024 * @brief The class exposing KeyEvent to QML 0025 */ 0026 class QmlKeyEvent : public QObject 0027 { 0028 Q_OBJECT 0029 /** 0030 * @brief number of keys involved in this event 0031 */ 0032 Q_PROPERTY(int count READ count CONSTANT) 0033 /** 0034 * @brief checks if the event comes from an auto-repeating key 0035 */ 0036 Q_PROPERTY(bool autoRepeat READ isAutoRepeat CONSTANT) 0037 /** 0038 * @brief key code which is pressed/released 0039 */ 0040 Q_PROPERTY(int key READ key CONSTANT) 0041 /** 0042 * @brief modifiers associated with the event 0043 */ 0044 Q_PROPERTY(int modifiers READ modifiers CONSTANT) 0045 /** 0046 * @brief native modifiers of the event 0047 */ 0048 Q_PROPERTY(quint32 nativeModifiers READ nativeModifiers CONSTANT) 0049 /** 0050 * @brief native scan code of the event 0051 */ 0052 Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT) 0053 /** 0054 * @brief native virtual key, or key sum of the event 0055 */ 0056 Q_PROPERTY(quint32 nativeVirtualKey READ nativeVirtualKey CONSTANT) 0057 /** 0058 * @brief Returns the Unicode text that this key generated 0059 */ 0060 Q_PROPERTY(QString text READ text CONSTANT) 0061 public: 0062 explicit QmlKeyEvent(QKeyEvent *keyEvent = nullptr, QObject *parent = nullptr); 0063 int count() const; 0064 bool isAutoRepeat() const; 0065 int key() const; 0066 int modifiers() const; 0067 quint32 nativeModifiers() const; 0068 quint32 nativeScanCode() const; 0069 quint32 nativeVirtualKey() const; 0070 QString text() const; 0071 0072 void clear(); 0073 0074 private: 0075 QKeyEvent *m_keyEvent = nullptr; 0076 };