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 <QMouseEvent> 0021 0022 /** 0023 * @brief The class exposing MouseEvent to QML 0024 */ 0025 class QmlMouseEvent : public QObject 0026 { 0027 Q_OBJECT 0028 /** 0029 * @brief button associated with the event 0030 */ 0031 Q_PROPERTY(int button READ button CONSTANT) 0032 /** 0033 * @brief button state associated with the event 0034 */ 0035 Q_PROPERTY(int buttons READ buttons CONSTANT) 0036 /** 0037 * @brief global position of mouse cursor at the time of event 0038 */ 0039 Q_PROPERTY(QPoint globalPos READ globalPos CONSTANT) 0040 /** 0041 * @brief global x position of mouse cursor at the time of event 0042 */ 0043 Q_PROPERTY(int globalX READ globalX CONSTANT) 0044 /** 0045 * @brief global y position of mouse cursor at the time of event 0046 */ 0047 Q_PROPERTY(int globalY READ globalY CONSTANT) 0048 /** 0049 * @brief local position of mouse cursor at the time of event 0050 */ 0051 Q_PROPERTY(QPointF localPos READ localPos CONSTANT) 0052 /** 0053 * @brief position of mouse cursor at the time of event 0054 */ 0055 Q_PROPERTY(QPoint pos READ pos CONSTANT) 0056 /** 0057 * @brief screen position of mouse cursor at the time of event 0058 */ 0059 Q_PROPERTY(QPointF screenPos READ screenPos CONSTANT) 0060 /** 0061 * @brief source of the event 0062 */ 0063 Q_PROPERTY(int source READ source CONSTANT) 0064 /** 0065 * @brief window position of mouse cursor at the time of event 0066 */ 0067 Q_PROPERTY(QPointF windowPos READ windowPos CONSTANT) 0068 /** 0069 * @brief x position of mouse cursor at the time of event 0070 */ 0071 Q_PROPERTY(int x READ x CONSTANT) 0072 /** 0073 * @brief y position of mouse cursor at the time of event 0074 */ 0075 Q_PROPERTY(int y READ y CONSTANT) 0076 public: 0077 explicit QmlMouseEvent(QMouseEvent *mouseEvent = nullptr, QObject *parent = nullptr); 0078 int button() const; 0079 int buttons() const; 0080 QPoint globalPos() const; 0081 int globalX() const; 0082 int globalY() const; 0083 QPointF localPos() const; 0084 QPoint pos() const; 0085 QPointF screenPos() const; 0086 int source() const; 0087 QPointF windowPos() const; 0088 int x() const; 0089 int y() const; 0090 0091 void clear(); 0092 0093 private: 0094 QMouseEvent *m_mouseEvent = nullptr; 0095 };