inputoverwatcher.cpp
907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "inputoverwatcher.h"
#include <QtDebug>
#include "soundplayer.h"
#include "backlight.h"
#include "config.h"
InputOverwatcher::InputOverwatcher(QObject *parent) : QObject(parent)
{
timer.setSingleShot(true);
timer.setInterval(5 * 60000); //Default Value is 5min
connect(&timer, SIGNAL(timeout()), SLOT(lowerBacklight()));
}
bool InputOverwatcher::eventFilter(QObject */*watched*/, QEvent *event)
{
switch (event->type())
{
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
Backlight::restore();
timer.start();
break;
default:
break;
}
return false;
}
void InputOverwatcher::setDelay(int mins)
{
timer.setInterval(mins * 60000);
timer.start();
}
void InputOverwatcher::lowerBacklight()
{
Backlight::lower();
}