Falkon Develop
Cross-platform Qt-based web browser
qmlkeyevent.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#pragma once
19
20#include <QKeyEvent>
21#include <QObject>
22
26class QmlKeyEvent : public QObject
27{
28 Q_OBJECT
32 Q_PROPERTY(int count READ count CONSTANT)
36 Q_PROPERTY(bool autoRepeat READ isAutoRepeat CONSTANT)
40 Q_PROPERTY(int key READ key CONSTANT)
44 Q_PROPERTY(int modifiers READ modifiers CONSTANT)
48 Q_PROPERTY(quint32 nativeModifiers READ nativeModifiers CONSTANT)
52 Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
56 Q_PROPERTY(quint32 nativeVirtualKey READ nativeVirtualKey CONSTANT)
60 Q_PROPERTY(QString text READ text CONSTANT)
61public:
62 explicit QmlKeyEvent(QKeyEvent *keyEvent = nullptr, QObject *parent = nullptr);
63 int count() const;
64 bool isAutoRepeat() const;
65 int key() const;
66 int modifiers() const;
67 quint32 nativeModifiers() const;
68 quint32 nativeScanCode() const;
69 quint32 nativeVirtualKey() const;
70 QString text() const;
71
72 void clear();
73
74private:
75 QKeyEvent *m_keyEvent = nullptr;
76};
The class exposing KeyEvent to QML.
Definition: qmlkeyevent.h:27
int count
number of keys involved in this event
Definition: qmlkeyevent.h:32
bool autoRepeat
checks if the event comes from an auto-repeating key
Definition: qmlkeyevent.h:36
QmlKeyEvent(QKeyEvent *keyEvent=nullptr, QObject *parent=nullptr)
Definition: qmlkeyevent.cpp:21
quint32 nativeScanCode
native scan code of the event
Definition: qmlkeyevent.h:52
quint32 nativeVirtualKey
native virtual key, or key sum of the event
Definition: qmlkeyevent.h:56
void clear()
Definition: qmlkeyevent.cpp:91
quint32 nativeModifiers
native modifiers of the event
Definition: qmlkeyevent.h:48
QString text
Returns the Unicode text that this key generated.
Definition: qmlkeyevent.h:60
int key
key code which is pressed/released
Definition: qmlkeyevent.h:40
bool isAutoRepeat() const
Definition: qmlkeyevent.cpp:35
int modifiers
modifiers associated with the event
Definition: qmlkeyevent.h:44