[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/utils/rsibreak/src
From:       Chani Armitage <chanika () gmail ! com>
Date:       2010-09-06 19:38:26
Message-ID: 20100906193826.227AEAC884 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1172242 by chani:

Make the timers thread-friendly
needed for qt>=4.4


 M  +7 -4      rsitimer.cpp  
 M  +5 -7      rsitimer.h  
 M  +7 -4      rsitimer_kidle.cpp  
 M  +5 -7      rsitimer_kidle.h  


--- trunk/extragear/utils/rsibreak/src/rsitimer.cpp #1172241:1172242
@@ -40,7 +40,7 @@
 #include "rsiglobals.h"
 #include "rsistats.h"
 #include "rsitimer_dpms.h"
-#include <QTimerEvent>
+#include <QTimer>
 #include <QThread>
 #include <kglobal.h>
 #include <QX11Info>
@@ -66,13 +66,16 @@
 
 void RSITimer::run()
 {
-    startTimer( 1000 );
+    QTimer timer;
+    connect( &timer, SIGNAL(timeout()), this, SLOT(timeout()) );
+    timer.start( 1000 );
     slotReadConfig( /* restart */ true );
 
     m_tiny_left = m_intervals["tiny_minimized"];
     m_big_left = m_intervals["big_minimized"];
 
     restoreSession();
+    exec(); //make timers work
 }
 
 void RSITimer::hibernationDetector()
@@ -290,7 +293,7 @@
 
 // ----------------------------- EVENTS -----------------------//
 
-void RSITimer::timerEvent( QTimerEvent * )
+void RSITimer::timeout()
 {
     // although we might be suspended, we still want to return a valid value
     // when restarted, so m_lastActivity shouls still be updated. This way
@@ -528,7 +531,7 @@
 
 RSITimerNoIdle::~RSITimerNoIdle() {}
 
-void RSITimerNoIdle::timerEvent( QTimerEvent * )
+void RSITimerNoIdle::timeout()
 {
     // Just spot some long time inactivity...
     int idle = idleTime();
--- trunk/extragear/utils/rsibreak/src/rsitimer.h #1172241:1172242
@@ -22,12 +22,9 @@
 #define RSITimer_H
 
 #include <QDateTime>
-#include <QTimerEvent>
 #include <QThread>
 #include <QMap>
 
-class QTimerEvent;
-
 /**
  * @class RSITimer
  * This class controls the timings and arranges the maximizing
@@ -133,15 +130,16 @@
         return m_big_left;
     };
 
-protected:
+protected slots:
     /**
       The pumping heart of the timer. This will evaluate user's activity
       and decide what to do (wait, popup a relax notification or a
       fullscreen break.
       You shouldn't call this function directly.
     */
-    virtual void timerEvent( QTimerEvent* );
+    virtual void timeout();
 
+protected:
     /** This function is called when a break has passed. */
     void resetAfterBreak();
 
@@ -272,8 +270,8 @@
 public:
     explicit RSITimerNoIdle( QObject *parent = 0 );
     ~RSITimerNoIdle();
-protected:
-    virtual void timerEvent( QTimerEvent * );
+protected slots:
+    virtual void timeout();
 };
 
 #endif
--- trunk/extragear/utils/rsibreak/src/rsitimer_kidle.cpp #1172241:1172242
@@ -37,7 +37,7 @@
 
 #include "rsiglobals.h"
 #include "rsistats.h"
-#include <QTimerEvent>
+#include <QTimer>
 #include <QThread>
 #include <kglobal.h>
 #include <QX11Info>
@@ -61,13 +61,16 @@
 
 void RSITimer::run()
 {
-    startTimer( 1000 );
+    QTimer timer;
+    connect( &timer, SIGNAL(timeout()), this, SLOT(timeout()) );
+    timer.start( 1000 );
     slotReadConfig( /* restart */ true );
 
     m_tiny_left = m_intervals["tiny_minimized"];
     m_big_left = m_intervals["big_minimized"];
 
     restoreSession();
+    exec(); //make timers work
 }
 
 void RSITimer::hibernationDetector()
@@ -257,7 +260,7 @@
 
 // ----------------------------- EVENTS -----------------------//
 
-void RSITimer::timerEvent( QTimerEvent * )
+void RSITimer::timeout()
 {
     int t = idleTime();
 
@@ -492,7 +495,7 @@
 
 RSITimerNoIdle::~RSITimerNoIdle() {}
 
-void RSITimerNoIdle::timerEvent( QTimerEvent * )
+void RSITimerNoIdle::timeout()
 {
     // Just spot some long time inactivity...
     int idle = idleTime();
--- trunk/extragear/utils/rsibreak/src/rsitimer_kidle.h #1172241:1172242
@@ -22,12 +22,9 @@
 #define RSITimer_H
 
 #include <QDateTime>
-#include <QTimerEvent>
 #include <QThread>
 #include <QMap>
 
-class QTimerEvent;
-
 /**
  * @class RSITimer
  * This class controls the timings and arranges the maximizing
@@ -133,15 +130,16 @@
         return m_big_left;
     };
 
-protected:
+protected slots:
     /**
       The pumping heart of the timer. This will evaluate user's activity
       and decide what to do (wait, popup a relax notification or a
       fullscreen break.
       You shouldn't call this function directly.
     */
-    virtual void timerEvent( QTimerEvent* );
+    virtual void timeout();
 
+protected:
     /** This function is called when a break has passed. */
     void resetAfterBreak();
 
@@ -268,8 +266,8 @@
 public:
     explicit RSITimerNoIdle( QObject *parent = 0 );
     ~RSITimerNoIdle();
-protected:
-    virtual void timerEvent( QTimerEvent * );
+protected slots:
+    virtual void timeout();
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic