I am trying to figure out how to track when a user was idle from a computer, which means not only my application. The reason is because I want my application to be able to set the user as "Away" after a certain time. Think of it as Skype, which takes you in X minutes.
Any ideas how to do this?
Edit
What I still have to track the mouse:
mouseTimer = new QTimer();
mouseLastPos = QCursor::pos();
mouseIdleSeconds = 0;
connect(mouseTimer, SIGNAL(timeout()), this, SLOT(mouseTimerTick()));
mouseTimer->start(1000);
void MainWindow::mouseTimerTick()
{
QPoint point = QCursor::pos();
if(point != mouseLastPos)
mouseIdleSeconds = 0;
else
mouseIdleSeconds++;
mouseLastPos = point;
qDebug() << mouseIdleSeconds;
}
Can I also add a keyboard to this?
source
share