[Pkg-kde-extras] Bug#341212: playground/utils/rsibreak/src

Bram Schoenmakers bramschoenmakers at kde.nl
Thu Dec 1 23:20:26 UTC 2005


SVN commit 484800 by bram:

Feature added: Suspend RSIBreak with the docker's popup menu. Handy if you're playing a game for example.

CCMAIL:341212 at bugs.debian.org



 AM            hi16-action-rsibreakx.png  
 AM            hi32-action-rsibreakx.png  
 M  +24 -1     rsidock.cpp  
 M  +16 -2     rsidock.h  
 M  +3 -1      rsitimer.cpp  
 M  +3 -0      rsitimer.h  
 M  +8 -0      rsiwidget.cpp  


** trunk/playground/utils/rsibreak/src/hi16-action-rsibreakx.png #property svn:mime-type
   + application/octet-stream
** trunk/playground/utils/rsibreak/src/hi32-action-rsibreakx.png #property svn:mime-type
   + application/octet-stream
--- trunk/playground/utils/rsibreak/src/rsidock.cpp #484799:484800
@@ -33,7 +33,7 @@
 #include <kkeydialog.h>
 
 RSIDock::RSIDock( QWidget *parent, const char *name )
-    : KSystemTray( parent, name )
+    : KSystemTray( parent, name ), m_suspended( false )
 {
   kdDebug() << "Entering RSIDock" << endl;
   QPixmap dockPixmap = KSystemTray::loadIcon( "rsibreak0" );
@@ -44,6 +44,9 @@
   contextMenu()->insertItem(SmallIcon("configure"),
                          i18n("Configure RSIBreak..."), this,
                          SLOT(slotConfigure()));
+  mSuspendItem = contextMenu()->insertItem(SmallIcon("player_pause"),
+                         i18n("Suspend RSIBreak"), this,
+                         SLOT(slotSuspend()));
   contextMenu()->insertSeparator();
   contextMenu()->insertItem(i18n("Report Bug..."), this,
                          SLOT(slotReportBug()));
@@ -125,4 +128,24 @@
     emit breakRequest();
 }
 
+void RSIDock::slotSuspend()
+{
+  if( m_suspended )
+  {
+    emit unsuspend();
+
+    setPixmap( KSystemTray::loadIcon( "rsibreak0" ) );
+    contextMenu()->changeItem( mSuspendItem, SmallIcon( "player_pause" ), i18n("Suspend RSIBreak") );
+  }
+  else
+  {
+    emit suspend();
+
+    setPixmap( KSystemTray::loadIcon( "rsibreakx" ) );
+    contextMenu()->changeItem( mSuspendItem, SmallIcon( "player_play" ), i18n( "Resume RSIBreak" ) );
+  }
+
+  m_suspended = !m_suspended;
+}
+
 #include "rsidock.moc"
--- trunk/playground/utils/rsibreak/src/rsidock.h #484799:484800
@@ -29,11 +29,11 @@
 class KGlobalAccel;
 #include <ksystemtray.h>
 
-/** 
+/**
  * @class RSIDock
  * This class is resonsible for putting rsibreak in the system tray
  * and provide a proper menu when right clicked on the icon.
- * 
+ *
  * Originaly this file was copied from KSynaptics
  * @author Nadeem Hasan <nhasan at kde.org>
  * @author Tom Albers <tomalbers at kde.nl>
@@ -87,16 +87,30 @@
          */
         void breakRequest();
 
+        /**
+         * Suspend RSIbreak on user's request.
+        */
+        void suspend();
+
+        /**
+         * Restart RSIbreak again after suspensing.
+        */
+        void unsuspend();
+
     private slots:
         void slotConfigure();
         void slotAboutKDE();
         void slotAboutRSIBreak();
         void slotReportBug();
         void slotBreakRequest();
+        void slotSuspend();
 
     private:
         KGlobalAccel* m_accel;
         QString       m_currentIcon;
+
+        int mSuspendItem;
+        bool m_suspended;
 };
 
 #endif // RSIDOCK_H
--- trunk/playground/utils/rsibreak/src/rsitimer.cpp #484799:484800
@@ -37,7 +37,7 @@
 
 RSITimer::RSITimer( QObject *parent, const char *name )
     : QObject( parent, name ), m_idleLong( false ), m_targetReached( false ),
-      m_needBreak( 0 ), m_idleIndex( 0 )
+      m_suspended( false ), m_needBreak( 0 ), m_idleIndex( 0 )
 {
     kdDebug() << "Entering RSITimer::RSITimer" << endl;
 
@@ -173,6 +173,7 @@
     emit minimize();
     m_timer_max->stop();
     m_needBreak=false;
+    m_suspended=true;
 }
 
 void RSITimer::slotRestart( )
@@ -185,6 +186,7 @@
 
     emit minimize();
     startMinimizeTimer();
+    m_suspended=false;
 }
 
 
--- trunk/playground/utils/rsibreak/src/rsitimer.h #484799:484800
@@ -42,6 +42,8 @@
         RSITimer( QObject *parent = 0, const char *name = 0 );
         ~RSITimer();
 
+        bool isSuspended() const { return m_suspended; }
+
     public slots:
         void slotMinimize();
         void slotMaximize();
@@ -72,6 +74,7 @@
         bool            m_idleLong;
         bool            m_targetReached;
         bool            m_idleDetection;
+        bool            m_suspended;
 
         int             m_needBreak;
         int             m_timeMaximized;
--- trunk/playground/utils/rsibreak/src/rsiwidget.cpp #484799:484800
@@ -82,6 +82,9 @@
     connect( m_tray, SIGNAL( dialogEntered() ), m_timer, SLOT( slotStop() ) );
     connect( m_tray, SIGNAL( dialogLeft() ), m_timer, SLOT( slotRestart() ) );
     connect( m_tray, SIGNAL( breakRequest() ), m_timer, SLOT( slotMaximize() ) );
+    connect( m_tray, SIGNAL( suspend() ), m_timer, SLOT( slotStop() ) );
+    connect( m_tray, SIGNAL( suspend() ), m_popup, SLOT( hide() ) );
+    connect( m_tray, SIGNAL( unsuspend() ), m_timer, SLOT( slotRestart() ) );
 
     srand ( time(NULL) );
 
@@ -268,6 +271,11 @@
         QToolTip::add(m_tray, i18n("One second remaining",
                       "%n seconds remaining",s));
     }
+    else if ( m_timer->isSuspended() )
+    {
+        m_countDown->setText( "Suspended" );
+        QToolTip::add( m_tray, i18n("RSIbreak is currently suspended"));
+    }
     else
     {
         m_countDown->setText (QString::null );




More information about the pkg-kde-extras mailing list