inputoverwatcher.cpp
994 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
46
#include "inputoverwatcher.h"
#include <QtDebug>
#include "soundplayer.h"
#include "backlight.h"
#include "config.h"
InputOverwatcher::InputOverwatcher(QObject *parent) : QObject(parent)
{
Define::config_item item = Config::getInstance()->getConfigValue(Define::config_set_auto_darkness);
timer.setSingleShot(true);
timer.setInterval(item.d32 * 60000);
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();
}