Falkon Develop
Cross-platform Qt-based web browser
qmlwheelevent.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 "qmlwheelevent.h"
19#include <QQmlEngine>
20
21QmlWheelEvent::QmlWheelEvent(QWheelEvent *wheelEvent, QObject *parent)
22 : QObject(parent)
23 , m_wheelEvent(wheelEvent)
24{
25}
26
28{
29 if (!m_wheelEvent) {
30 return QPoint(-1, -1);
31 }
32 return m_wheelEvent->angleDelta();
33}
34
36{
37 if (!m_wheelEvent) {
38 return -1;
39 }
40 return static_cast<int>(m_wheelEvent->buttons());
41}
42
44{
45 if (!m_wheelEvent) {
46 return QPoint(-1, -1);
47 }
48 return m_wheelEvent->globalPosition().toPoint();
49}
50
52{
53 if (!m_wheelEvent) {
54 return QPointF(-1, -1);
55 }
56 return m_wheelEvent->globalPosition();
57}
58
60{
61 if (!m_wheelEvent) {
62 return -1;
63 }
64 return m_wheelEvent->globalPosition().toPoint().x();
65}
66
68{
69 if (!m_wheelEvent) {
70 return -1;
71 }
72 return m_wheelEvent->globalPosition().toPoint().y();
73}
74
76{
77 if (!m_wheelEvent) {
78 return false;
79 }
80 return m_wheelEvent->inverted();
81}
82
84{
85 if (!m_wheelEvent) {
86 return -1;
87 }
88 return static_cast<int>(m_wheelEvent->phase());
89}
90
92{
93 if (!m_wheelEvent) {
94 return QPoint(-1, -1);
95 }
96 return m_wheelEvent->pixelDelta();
97}
98
99QPoint QmlWheelEvent::pos() const
100{
101 if (!m_wheelEvent) {
102 return QPoint(-1, -1);
103 }
104 return m_wheelEvent->position().toPoint();
105}
106
107QPointF QmlWheelEvent::posF() const
108{
109 if (!m_wheelEvent) {
110 return QPointF(-1, -1);
111 }
112 return m_wheelEvent->position();
113}
114
116{
117 if (!m_wheelEvent) {
118 return -1;
119 }
120 return static_cast<int>(m_wheelEvent->source());
121}
122
124{
125 if (!m_wheelEvent) {
126 return -1;
127 }
128 return m_wheelEvent->position().toPoint().x();
129}
130
132{
133 if (!m_wheelEvent) {
134 return -1;
135 }
136 return m_wheelEvent->position().toPoint().y();
137}
138
140{
141 m_wheelEvent = nullptr;
142}
int source
source of the event
Definition: qmlwheelevent.h:76
int x
x position of mouse cursor at the time of event
Definition: qmlwheelevent.h:80
int globalX
global x position of mouse cursor at the time of event
Definition: qmlwheelevent.h:48
QmlWheelEvent(QWheelEvent *wheelEvent=nullptr, QObject *parent=nullptr)
QPointF posF
position of mouse cursor at the time of event
Definition: qmlwheelevent.h:72
int globalY
global y position of mouse cursor at the time of event
Definition: qmlwheelevent.h:52
QPoint pixelDelta
scrolling distance in pixels on screen
Definition: qmlwheelevent.h:64
QPointF globalPosF
global position of mouse cursor at the time of event
Definition: qmlwheelevent.h:44
int y
y position of mouse cursor at the time of event
Definition: qmlwheelevent.h:84
QPoint globalPos
global position of mouse cursor at the time of event
Definition: qmlwheelevent.h:40
QPoint pos
position of mouse cursor at the time of event
Definition: qmlwheelevent.h:68
bool inverted
checks if the delta values delivered with the event are inverted
Definition: qmlwheelevent.h:56
int phase
scrolling phase of this wheel event
Definition: qmlwheelevent.h:60
QPoint angleDelta
the distance that the wheel is rotated, in eighths of a degree
Definition: qmlwheelevent.h:32
int buttons
mouse state at the time of event
Definition: qmlwheelevent.h:36