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 #include "qmlwheelevent.h" 0019 #include <QQmlEngine> 0020 0021 QmlWheelEvent::QmlWheelEvent(QWheelEvent *wheelEvent, QObject *parent) 0022 : QObject(parent) 0023 , m_wheelEvent(wheelEvent) 0024 { 0025 } 0026 0027 QPoint QmlWheelEvent::angleDelta() const 0028 { 0029 if (!m_wheelEvent) { 0030 return QPoint(-1, -1); 0031 } 0032 return m_wheelEvent->angleDelta(); 0033 } 0034 0035 int QmlWheelEvent::buttons() const 0036 { 0037 if (!m_wheelEvent) { 0038 return -1; 0039 } 0040 return static_cast<int>(m_wheelEvent->buttons()); 0041 } 0042 0043 QPoint QmlWheelEvent::globalPos() const 0044 { 0045 if (!m_wheelEvent) { 0046 return QPoint(-1, -1); 0047 } 0048 return m_wheelEvent->globalPosition().toPoint(); 0049 } 0050 0051 QPointF QmlWheelEvent::globalPosF() const 0052 { 0053 if (!m_wheelEvent) { 0054 return QPointF(-1, -1); 0055 } 0056 return m_wheelEvent->globalPosition(); 0057 } 0058 0059 int QmlWheelEvent::globalX() const 0060 { 0061 if (!m_wheelEvent) { 0062 return -1; 0063 } 0064 return m_wheelEvent->globalPosition().toPoint().x(); 0065 } 0066 0067 int QmlWheelEvent::globalY() const 0068 { 0069 if (!m_wheelEvent) { 0070 return -1; 0071 } 0072 return m_wheelEvent->globalPosition().toPoint().y(); 0073 } 0074 0075 bool QmlWheelEvent::inverted() const 0076 { 0077 if (!m_wheelEvent) { 0078 return false; 0079 } 0080 return m_wheelEvent->inverted(); 0081 } 0082 0083 int QmlWheelEvent::phase() const 0084 { 0085 if (!m_wheelEvent) { 0086 return -1; 0087 } 0088 return static_cast<int>(m_wheelEvent->phase()); 0089 } 0090 0091 QPoint QmlWheelEvent::pixelDelta() const 0092 { 0093 if (!m_wheelEvent) { 0094 return QPoint(-1, -1); 0095 } 0096 return m_wheelEvent->pixelDelta(); 0097 } 0098 0099 QPoint QmlWheelEvent::pos() const 0100 { 0101 if (!m_wheelEvent) { 0102 return QPoint(-1, -1); 0103 } 0104 return m_wheelEvent->position().toPoint(); 0105 } 0106 0107 QPointF QmlWheelEvent::posF() const 0108 { 0109 if (!m_wheelEvent) { 0110 return QPointF(-1, -1); 0111 } 0112 return m_wheelEvent->position(); 0113 } 0114 0115 int QmlWheelEvent::source() const 0116 { 0117 if (!m_wheelEvent) { 0118 return -1; 0119 } 0120 return static_cast<int>(m_wheelEvent->source()); 0121 } 0122 0123 int QmlWheelEvent::x() const 0124 { 0125 if (!m_wheelEvent) { 0126 return -1; 0127 } 0128 return m_wheelEvent->position().toPoint().x(); 0129 } 0130 0131 int QmlWheelEvent::y() const 0132 { 0133 if (!m_wheelEvent) { 0134 return -1; 0135 } 0136 return m_wheelEvent->position().toPoint().y(); 0137 } 0138 0139 void QmlWheelEvent::clear() 0140 { 0141 m_wheelEvent = nullptr; 0142 }