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 #pragma once 0019 0020 #include <QWheelEvent> 0021 #include <QObject> 0022 0023 /** 0024 * @brief The class exposing WheelEvent to QML 0025 */ 0026 class QmlWheelEvent : public QObject 0027 { 0028 Q_OBJECT 0029 /** 0030 * @brief the distance that the wheel is rotated, in eighths of a degree 0031 */ 0032 Q_PROPERTY(QPoint angleDelta READ angleDelta CONSTANT) 0033 /** 0034 * @brief mouse state at the time of event 0035 */ 0036 Q_PROPERTY(int buttons READ buttons CONSTANT) 0037 /** 0038 * @brief global position of mouse cursor at the time of event 0039 */ 0040 Q_PROPERTY(QPoint globalPos READ globalPos CONSTANT) 0041 /** 0042 * @brief global position of mouse cursor at the time of event 0043 */ 0044 Q_PROPERTY(QPointF globalPosF READ globalPosF CONSTANT) 0045 /** 0046 * @brief global x position of mouse cursor at the time of event 0047 */ 0048 Q_PROPERTY(int globalX READ globalX CONSTANT) 0049 /** 0050 * @brief global y position of mouse cursor at the time of event 0051 */ 0052 Q_PROPERTY(int globalY READ globalY CONSTANT) 0053 /** 0054 * @brief checks if the delta values delivered with the event are inverted 0055 */ 0056 Q_PROPERTY(bool inverted READ inverted CONSTANT) 0057 /** 0058 * @brief scrolling phase of this wheel event 0059 */ 0060 Q_PROPERTY(int phase READ phase CONSTANT) 0061 /** 0062 * @brief scrolling distance in pixels on screen 0063 */ 0064 Q_PROPERTY(QPoint pixelDelta READ pixelDelta CONSTANT) 0065 /** 0066 * @brief position of mouse cursor at the time of event 0067 */ 0068 Q_PROPERTY(QPoint pos READ pos CONSTANT) 0069 /** 0070 * @brief position of mouse cursor at the time of event 0071 */ 0072 Q_PROPERTY(QPointF posF READ posF CONSTANT) 0073 /** 0074 * @brief source of the event 0075 */ 0076 Q_PROPERTY(int source READ source CONSTANT) 0077 /** 0078 * @brief x position of mouse cursor at the time of event 0079 */ 0080 Q_PROPERTY(int x READ x CONSTANT) 0081 /** 0082 * @brief y position of mouse cursor at the time of event 0083 */ 0084 Q_PROPERTY(int y READ y CONSTANT) 0085 public: 0086 explicit QmlWheelEvent(QWheelEvent *wheelEvent = nullptr, QObject *parent = nullptr); 0087 QPoint angleDelta() const; 0088 int buttons() const; 0089 QPoint globalPos() const; 0090 QPointF globalPosF() const; 0091 int globalX() const; 0092 int globalY() const; 0093 bool inverted() const; 0094 int phase() const; 0095 QPoint pixelDelta() const; 0096 QPoint pos() const; 0097 QPointF posF() const; 0098 int source() const; 0099 int x() const; 0100 int y() const; 0101 0102 void clear(); 0103 private: 0104 QWheelEvent *m_wheelEvent = nullptr; 0105 };