1/***************************************************************************
2 * Copyright (C) 2009 by Dario Freddi <drf@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
19
20#include "KIdleTest.h"
21#include <QDebug>
22
23#include "../kidletime.h"
24
25KIdleTest::KIdleTest()
26{
27 connect(KIdleTime::instance(), SIGNAL(resumingFromIdle()), this, SLOT(resumeEvent()));
28 connect(KIdleTime::instance(), SIGNAL(timeoutReached(int,int)), this, SLOT(timeoutReached(int,int)));
29
30 KIdleTime::instance()->catchNextResumeEvent();
31
32 printf("Your idle time is %d\n", KIdleTime::instance()->idleTime());
33 printf("Welcome!! Move your mouse or do something to start...\n");
34}
35
36KIdleTest::~KIdleTest()
37{
38}
39
40void KIdleTest::resumeEvent()
41{
42 KIdleTime::instance()->removeAllIdleTimeouts();
43
44 printf("Great! Now stay idle for 5 seconds to get a nice message. From 10 seconds on, you can move your mouse to get back here.\n");
45 printf("If you will stay idle for too long, I will simulate your activity after 25 seconds, and make everything start back\n");
46
47 KIdleTime::instance()->addIdleTimeout(5000);
48 KIdleTime::instance()->addIdleTimeout(10000);
49 KIdleTime::instance()->addIdleTimeout(25000);
50}
51
52void KIdleTest::timeoutReached(int id, int timeout)
53{
54 Q_UNUSED(id)
55
56 if (timeout == 5000) {
57 printf("5 seconds passed, stay still some more...\n");
58 } else if (timeout == 10000) {
59 KIdleTime::instance()->catchNextResumeEvent();
60 printf("Cool. You can move your mouse to start over\n");
61 } else if (timeout == 25000) {
62 printf("Uff, you're annoying me. Let's start again. I'm simulating your activity now\n");
63 KIdleTime::instance()->simulateUserActivity();
64 } else {
65 qDebug() << "OUCH";
66 }
67}
68