Falkon Develop
Cross-platform Qt-based web browser
qmlmouseevent.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 "qmlmouseevent.h"
19#include <QQmlEngine>
20
21QmlMouseEvent::QmlMouseEvent(QMouseEvent *mouseEvent, QObject *parent)
22 : QObject(parent)
23 , m_mouseEvent(mouseEvent)
24{
25}
26
28{
29 if (!m_mouseEvent) {
30 return -1;
31 }
32 return static_cast<int>(m_mouseEvent->button());
33}
34
36{
37 if (!m_mouseEvent) {
38 return -1;
39 }
40 return static_cast<int>(m_mouseEvent->buttons());
41}
42
44{
45 if (!m_mouseEvent) {
46 return QPoint(-1, -1);
47 }
48 return m_mouseEvent->globalPosition().toPoint();
49}
50
52{
53 if (!m_mouseEvent) {
54 return -1;
55 }
56 return m_mouseEvent->globalPosition().toPoint().x();
57}
58
60{
61 if (!m_mouseEvent) {
62 return -1;
63 }
64 return m_mouseEvent->globalPosition().toPoint().y();
65}
66
68{
69 if (!m_mouseEvent) {
70 return QPointF(-1, -1);
71 }
72 return m_mouseEvent->position();
73}
74
75QPoint QmlMouseEvent::pos() const
76{
77 if (!m_mouseEvent) {
78 return QPoint(-1, -1);
79 }
80 return m_mouseEvent->position().toPoint();
81}
82
84{
85 if (!m_mouseEvent) {
86 return QPointF(-1, -1);
87 }
88 return m_mouseEvent->globalPosition();
89}
90
92{
93 if (!m_mouseEvent) {
94 return -1;
95 }
96 return static_cast<int>(m_mouseEvent->source());
97}
98
100{
101 if (!m_mouseEvent) {
102 return QPointF(-1, -1);
103 }
104 return m_mouseEvent->scenePosition();
105}
106
108{
109 if (!m_mouseEvent) {
110 return -1;
111 }
112 return m_mouseEvent->position().toPoint().x();
113}
114
116{
117 if (!m_mouseEvent) {
118 return -1;
119 }
120 return m_mouseEvent->position().toPoint().y();
121}
122
124{
125 m_mouseEvent = nullptr;
126}
QPoint globalPos
global position of mouse cursor at the time of event
Definition: qmlmouseevent.h:39
QmlMouseEvent(QMouseEvent *mouseEvent=nullptr, QObject *parent=nullptr)
QPointF localPos
local position of mouse cursor at the time of event
Definition: qmlmouseevent.h:51
int buttons
button state associated with the event
Definition: qmlmouseevent.h:35
int button
button associated with the event
Definition: qmlmouseevent.h:31
int x
x position of mouse cursor at the time of event
Definition: qmlmouseevent.h:71
QPointF windowPos
window position of mouse cursor at the time of event
Definition: qmlmouseevent.h:67
int globalY
global y position of mouse cursor at the time of event
Definition: qmlmouseevent.h:47
QPoint pos
position of mouse cursor at the time of event
Definition: qmlmouseevent.h:55
int source
source of the event
Definition: qmlmouseevent.h:63
QPointF screenPos
screen position of mouse cursor at the time of event
Definition: qmlmouseevent.h:59
int globalX
global x position of mouse cursor at the time of event
Definition: qmlmouseevent.h:43
int y
y position of mouse cursor at the time of event
Definition: qmlmouseevent.h:75