added EnergySaver intended to handle shutdown.

Moved timer from MouseEventSpy to EnergySaver.
Connected MouseEventSpy and MusicController to EnergySaver.
This commit is contained in:
Anika Raemer 2019-04-04 12:21:41 +02:00
parent ce8ea8f582
commit 8a8abd6c76
7 changed files with 132 additions and 53 deletions

View file

@ -2,36 +2,34 @@
#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.
*/
* @brief Catches all mouse event 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
public:
protected:
explicit MouseEventSpy(QObject *parent = 0);
signals:
void mouseEventDetected();
public:
static void init();
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