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

List:       kde-commits
Subject:    extragear/utils/rsibreak/src
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2011-04-03 22:06:06
Message-ID: 20110403220606.1684AAC8D5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1227001 by gateau:

Merged RSIToolTip into RSIDock

 M  +0 -1      CMakeLists.txt  
 M  +45 -0     rsidock.cpp  
 M  +3 -0      rsidock.h  
 D             rsitooltip.cpp  
 D             rsitooltip.h  
 M  +1 -6      rsiwidget.cpp  
 M  +0 -2      rsiwidget.h  


--- trunk/extragear/utils/rsibreak/src/CMakeLists.txt #1227000:1227001
@@ -20,7 +20,6 @@
 rsiwidget.cpp
 rsirelaxpopup.cpp
 setupmaximized.cpp
-rsitooltip.cpp
 rsistatwidget.cpp
 rsistats.cpp
 rsitimer.cpp
--- trunk/extragear/utils/rsibreak/src/rsidock.cpp #1227000:1227001
@@ -25,6 +25,7 @@
 #include "rsistats.h"
 
 #include <QPointer>
+#include <QTextDocument>
 
 #include <KAboutData>
 #include <KComponentData>
@@ -175,4 +176,48 @@
         RSIGlobals::instance()->stats()->reset();
 }
 
+static QString colorizedText( const QString& text, const QColor& color )
+{
+    return QString("<font color='%1'>&#9679;</font> %2")
+        .arg(color.name())
+        .arg(Qt::escape(text))
+        ;
+}
+
+void RSIDock::setCounters( int tiny_left, int big_left )
+{
+    if ( m_suspended )
+        setToolTipSubTitle( i18n( "Suspended" ) );
+    else {
+        QColor tinyColor = RSIGlobals::instance()->getTinyBreakColor( tiny_left );
+        RSIGlobals::instance()->stats()->setColor( LAST_TINY_BREAK, tinyColor );
+
+        QColor bigColor = RSIGlobals::instance()-> getBigBreakColor( big_left );
+        RSIGlobals::instance()->stats()->setColor( LAST_BIG_BREAK, bigColor );
+
+        // Only add the line for the tiny break when there is not
+        // a big break planned at the same time.
+
+        QStringList lines;
+        if ( tiny_left != big_left ) {
+            QString formattedText = RSIGlobals::instance()->formatSeconds( tiny_left \
); +            if ( !formattedText.isNull() ) {
+                lines << colorizedText(
+                    i18n( "%1 remaining until next short break", formattedText ),
+                    tinyColor
+                    );
+            }
+        }
+
+        // do the same for the big break
+        if ( big_left > 0 )
+            lines << colorizedText(
+                i18n( "%1 remaining until next long break",
+                    RSIGlobals::instance()->formatSeconds( big_left ) ),
+                bigColor
+                );
+        setToolTipSubTitle(lines.join("<br>"));
+    }
+}
+
 #include "rsidock.moc"
--- trunk/extragear/utils/rsibreak/src/rsidock.h #1227000:1227001
@@ -52,6 +52,9 @@
      */
     ~RSIDock();
 
+public slots:
+    void setCounters( int tiny_left, int big_left );
+
 signals:
     /**
      * This signal is emitted when the user has left
--- trunk/extragear/utils/rsibreak/src/rsiwidget.cpp #1227000:1227001
@@ -28,7 +28,6 @@
 #include "rsitimer.h"
 #include "rsidock.h"
 #include "rsirelaxpopup.h"
-#include "rsitooltip.h"
 #include "rsiglobals.h"
 
 #include <config-rsibreak.h>
@@ -62,8 +61,6 @@
     QDBusConnection dbus = QDBusConnection::sessionBus();
     dbus.registerObject( "/rsibreak", this );
 
-    m_tooltip = new RSIToolTip( 0, m_tray );
-
     m_relaxpopup = new RSIRelaxPopup( 0 );
     connect( m_relaxpopup, SIGNAL( lock() ), SLOT( slotLock() ) );
 
@@ -72,8 +69,6 @@
              SLOT( slotReadConfig() ) );
     connect( m_tray, SIGNAL( configChanged( bool ) ), m_relaxpopup,
              SLOT( slotReadConfig() ) );
-    connect( m_tray, SIGNAL( suspend( bool ) ), m_tooltip,
-             SLOT( setSuspended( bool ) ) );
     connect( m_tray, SIGNAL( suspend( bool ) ), m_relaxpopup, SLOT( hide() ) );
 
     srand( time( NULL ) );
@@ -217,7 +212,7 @@
     connect( m_timer, SIGNAL( updateWidget( int ) ),
              SLOT( setCounters( int ) ), Qt::QueuedConnection );
     connect( m_timer, SIGNAL( updateToolTip( int, int ) ),
-             m_tooltip, SLOT( setCounters( int, int ) ), Qt::QueuedConnection );
+             m_tray, SLOT( setCounters( int, int ) ), Qt::QueuedConnection );
     connect( m_timer, SIGNAL( updateIdleAvg( double ) ), SLOT( updateIdleAvg( double \
                ) ), Qt::QueuedConnection );
     connect( m_timer, SIGNAL( minimize() ), SLOT( minimize() ),  \
                Qt::QueuedConnection );
     connect( m_timer, SIGNAL( relax( int, bool ) ), m_relaxpopup, SLOT( relax( int, \
                bool ) ), Qt::QueuedConnection );
--- trunk/extragear/utils/rsibreak/src/rsiwidget.h #1227000:1227001
@@ -26,7 +26,6 @@
 
 class RSIDock;
 class RSIRelaxPopup;
-class RSIToolTip;
 class BreakBase;
 
 /**
@@ -96,7 +95,6 @@
     bool            m_usePlasmaRO;
 
     RSIRelaxPopup*  m_relaxpopup;
-    RSIToolTip*     m_tooltip;
 
     bool            m_useIdleDetection;
     QString         m_currentIcon;


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

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