35 lines
669 B
C++
35 lines
669 B
C++
#ifndef MOUSEEVENTSPY_H
|
|
#define MOUSEEVENTSPY_H
|
|
|
|
#include <QObject>
|
|
#include <QEvent>
|
|
|
|
/**
|
|
* @brief Catches all mouse events and reports them via signal.
|
|
*
|
|
* Based on
|
|
* https://stackoverflow.com/questions/46173105/how-can-i-reset-a-timer-every-time-i-receive-a-touch-event-from-a-qml-page
|
|
*/
|
|
class MouseEventSpy : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
protected:
|
|
explicit MouseEventSpy(QObject *parent = 0);
|
|
|
|
signals:
|
|
void mouseEventDetected();
|
|
|
|
public:
|
|
static void init();
|
|
static MouseEventSpy* instance();
|
|
|
|
protected:
|
|
bool eventFilter(QObject* watched, QEvent* event);
|
|
|
|
private:
|
|
bool isMouseEvent(QEvent::Type t);
|
|
|
|
};
|
|
|
|
#endif // MOUSEEVENTSPY_H
|