Falkon Develop
Cross-platform Qt-based web browser
qmlkeyevent.cpp
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#include "qmlkeyevent.h"
19#include <QQmlEngine>
20
21QmlKeyEvent::QmlKeyEvent(QKeyEvent *keyEvent, QObject *parent)
22 : QObject(parent)
23 , m_keyEvent(keyEvent)
24{
25}
26
28{
29 if (!m_keyEvent) {
30 return -1;
31 }
32 return m_keyEvent->count();
33}
34
36{
37 if (!m_keyEvent) {
38 return false;
39 }
40 return m_keyEvent->isAutoRepeat();
41}
42
44{
45 if (!m_keyEvent) {
46 return -1;
47 }
48 return m_keyEvent->key();
49}
50
52{
53 if (!m_keyEvent) {
54 return -1;
55 }
56 return static_cast<int>(m_keyEvent->modifiers());
57}
58
60{
61 if (!m_keyEvent) {
62 return 0;
63 }
64 return static_cast<quint32>(m_keyEvent->nativeModifiers());
65}
66
68{
69 if (!m_keyEvent) {
70 return 0;
71 }
72 return static_cast<quint32>(m_keyEvent->nativeScanCode());
73}
74
76{
77 if (!m_keyEvent) {
78 return 0;
79 }
80 return static_cast<quint32>(m_keyEvent->nativeVirtualKey());
81}
82
83QString QmlKeyEvent::text() const
84{
85 if (!m_keyEvent) {
86 return {};
87 }
88 return m_keyEvent->text();
89}
90
92{
93 m_keyEvent = nullptr;
94}
int count
number of keys involved in this event
Definition: qmlkeyevent.h:32
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