lena_pi/LenaPi/MouseEventSpy.h
Anika Raemer ce8ea8f582 Restart timer on mouse event.
Todo: call shut down script on timeout
2019-04-03 20:05:48 +02:00

37 lines
806 B
C++

#ifndef MOUSEEVENTSPY_H
#define MOUSEEVENTSPY_H
#include <QObject>
#include <QTimer>
#include <QEvent>
/**
* Catches all mouse event and starts timer -- basically behaves like a screensaver.
* Based on
* https://stackoverflow.com/questions/46173105/how-can-i-reset-a-timer-every-time-i-receive-a-touch-event-from-a-qml-page
*
* @todo implement timer and behavior on timeout.
*/
class MouseEventSpy : public QObject
{
Q_OBJECT
public:
explicit MouseEventSpy(QObject *parent = 0);
static MouseEventSpy* instance();
protected:
bool eventFilter(QObject* watched, QEvent* event);
private:
void initTimer(int interval);
bool isMouseEvent(QEvent::Type t);
QTimer mTimer;
private slots:
void onTimeout();
signals:
void mouseEventDetected();
};
#endif // MOUSEEVENTSPY_H