File indexing completed on 2024-11-24 04:50:40
0001 // SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #pragma once 0005 0006 #include <QObject> 0007 #include <QPointF> 0008 0009 class MouseTracker : public QObject 0010 { 0011 Q_OBJECT 0012 Q_PROPERTY(QPointF mousePosition READ mousePosition NOTIFY mousePositionChanged) 0013 0014 public: 0015 static MouseTracker *instance(); 0016 QPointF mousePosition() const; 0017 0018 Q_SIGNALS: 0019 void mousePositionChanged(QPointF position); 0020 void mouseButtonReleased(Qt::MouseButton button); 0021 0022 protected: 0023 bool eventFilter(QObject *watched, QEvent *event) override; 0024 0025 private: 0026 explicit MouseTracker(QObject *parent = nullptr); 0027 0028 QPointF m_lastMousePos; 0029 };