karm

idletimedetector.h
1 #ifndef KARM_IDLE_TIME_DETECTOR_H
2 #define KARM_IDLE_TIME_DETECTOR_H
3 
4 #include <tqobject.h>
5 #include "config.h" // HAVE_LIBXSS
6 #include <tqdatetime.h>
7 #include <kdebug.h>
8 
9 class TQTimer;
10 
11 #ifdef HAVE_LIBXSS
12  #include <X11/Xlib.h>
13  #include <X11/Xutil.h>
14  #include <X11/extensions/scrnsaver.h>
15  #include <fixx11h.h>
16 #endif // HAVE_LIBXSS
17 
18 // Seconds per minutes - useful for speeding debugging up!
19 const int secsPerMinute = 60;
20 
21 // Minutes between each idle overrun test.
22 const int testInterval= secsPerMinute * 1000;
23 
28 class IdleTimeDetector :public TQObject
29 {
30 TQ_OBJECT
31 
32 
33 public:
38  IdleTimeDetector(int maxIdle);
39 
46 
47 signals:
54  void extractTime(int minutes);
55 
57  void stopAllTimers();
58 
60  void stopAllTimersAt(TQDateTime qdt);
61 
62 public slots:
67  void setMaxIdle(int maxIdle);
68 
72  void startIdleDetection();
73 
77  void stopIdleDetection();
78 
84  void toggleOverAllIdleDetection(bool on);
85 
86 
87 protected:
88 #ifdef HAVE_LIBXSS
89  void informOverrun(int idle);
90 #endif // HAVE_LIBXSS
91 
92 protected slots:
93  void check();
94 
95 private:
96 #ifdef HAVE_LIBXSS
97  XScreenSaverInfo *_mit_info;
98 #endif
99  bool _idleDetectionPossible;
100  bool _overAllIdleDetect; // Based on preferences.
101  int _maxIdle;
102  TQTimer *_timer;
103 };
104 
105 #endif // KARM_IDLE_TIME_DETECTOR_H
Keep track of how long the computer has been idle.
void extractTime(int minutes)
Tells the listener to extract time from current timing.
void startIdleDetection()
Starts detecting idle time.
void stopAllTimers()
Tells the listener to stop timing.
IdleTimeDetector(int maxIdle)
Initializes and idle test timer.
void toggleOverAllIdleDetection(bool on)
Sets whether idle detection should be done at all.
void stopIdleDetection()
Stops detecting idle time.
void setMaxIdle(int maxIdle)
Sets the maximum allowed idle.
bool isIdleDetectionPossible()
Returns true if it is possible to do idle detection.
void stopAllTimersAt(TQDateTime qdt)
Tells the listener to stop timing for TQDateTime.