Bug 133668 - Show sensor values on ksysguard applet tooltip/popup
Summary: Show sensor values on ksysguard applet tooltip/popup
Status: RESOLVED FIXED
Alias: None
Product: ksysguard
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-06 19:55 UTC by Manuel López-Ibáñez
Modified: 2006-12-04 00:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel López-Ibáñez 2006-09-06 19:55:57 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages
OS:                Linux

A Tooltip could display sensor information (like numerical values and sensor names) when the mouse hovers over each kicker applet display.
Comment 1 John Tapsell 2006-12-04 00:04:27 UTC
SVN commit 610259 by johnflux:

* Show the value of each sensor in the tooltip for the signal plotter
* Fix a few clipping/painting bugs in the signal plotter

BUG:133668


 M  +16 -14    FancyPlotter.cc  
 M  +1 -0      FancyPlotter.h  
 M  +1 -5      SensorDisplay.cc  
 M  +1 -1      SensorDisplay.h  
 M  +13 -6     SignalPlotter.cc  
 M  +4 -0      SignalPlotter.h  


--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/FancyPlotter.cc #610258:610259
@@ -70,6 +70,14 @@
   KSGRD::SensorDisplay::setTitle( title );
 }
 
+bool FancyPlotter::eventFilter( QObject* object, QEvent* event ) {	//virtual
+  if(event->type() == QEvent::ToolTip)
+  {
+    setTooltip();
+  }
+  return SensorDisplay::eventFilter(object, event);
+}
+
 void FancyPlotter::configureSettings()
 {
   mSettingsDialog = new FancyPlotterSettings( this, mSharedSettings->locked );
@@ -176,9 +184,6 @@
     }
 
     mPlotter->update();
-
-    setTooltip();
-  
 }
 
 void FancyPlotter::applyStyle()
@@ -231,8 +236,6 @@
 
   ++mBeams;
 
-  setTooltip();
-
   return true;
 }
 
@@ -248,8 +251,6 @@
   mBeams--;
   KSGRD::SensorDisplay::removeSensor( pos );
 
-  setTooltip();
-
   return true;
 }
 
@@ -258,19 +259,21 @@
   QString tooltip;
   for ( uint i = 0; i < mBeams; ++i ) {
     if(sensors().at( mBeams -i - 1)->isLocalhost()) {
-      tooltip += QString( "%1%2%3" ).arg( i != 0 ? "<br>" : "<qt>")
+      tooltip += QString( "%1%2%3 (%4)" ).arg( i != 0 ? "<br>" : "<qt>")
             .arg("<font color=\"" + mPlotter->beamColors()[ i ].name() + "\">#</font>")
-                                    .arg( sensors().at( mBeams - i - 1  )->description() );
+            .arg( sensors().at( mBeams - i - 1  )->description() )
+	    .arg( mPlotter->lastValue(i) );
+
     } else {
-      tooltip += QString( "%1%2%3:%4" ).arg( i != 0 ? "<br>" : "<qt>" )
+      tooltip += QString( "%1%2%3:%4 (%5)" ).arg( i != 0 ? "<br>" : "<qt>" )
                  .arg("<font color=\"" + mPlotter->beamColors()[ i ].name() + "\">#</font>")
-                                   .arg( sensors().at( mBeams - i - 1 )->hostName() )
-                                   .arg( sensors().at( mBeams - i - 1  )->description() );
+                 .arg( sensors().at( mBeams - i - 1 )->hostName() )
+                 .arg( sensors().at( mBeams - i - 1  )->description() )
+	         .arg( mPlotter->lastValue(i) );
     }
   }
 
   mPlotter->setToolTip( tooltip );
-
 }
 
 void FancyPlotter::resizeEvent( QResizeEvent* )
@@ -330,7 +333,6 @@
 
     mPlotter->setTranslatedUnit( KSGRD::SensorMgr->translateUnit( unit ) );
     sensors().at( id - 100 )->setDescription( info.name() );
-    setTooltip();
   }
 }
 
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/FancyPlotter.h #610258:610259
@@ -80,6 +80,7 @@
     void applySettings();
 
   protected:
+    virtual bool eventFilter( QObject*, QEvent* );
     virtual void resizeEvent( QResizeEvent* );
     void setTooltip();
 
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SensorDisplay.cc #610258:610259
@@ -193,14 +193,10 @@
     }
 
     return true;
-  } else if ( event->type() == QEvent::MouseButtonRelease &&
-            ( ( QMouseEvent*)event)->button() == Qt::LeftButton ) {
-    setFocus();
-  }
+  } 
 
   return QWidget::eventFilter( object, event );
 }
-
 void SensorDisplay::sendRequest( const QString &hostName,
                                  const QString &command, int id )
 {
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SensorDisplay.h #610258:610259
@@ -208,7 +208,7 @@
     virtual void sensorLost( int reqId );
 
     /**
-     * Sets the object where the delete events will be send to.
+     * Sets the object where the delete events will be sent to.
      */
     void setDeleteNotifier( QObject *object );
 
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SignalPlotter.cc #610258:610259
@@ -444,16 +444,16 @@
     pCache.setPen( palette().color( QPalette::Light ) );
     pCache.drawLine( 0, h - 1, w - 1, h - 1 );
     pCache.drawLine( w - 1, 0, w - 1, h - 1 );
-    pCache.setClipRect( 1, 1, w - 2, h - 2 );
-
   }
   p.drawImage(0,0, mBackgroundImage);
   p.setRenderHint(QPainter::Antialiasing, true);
 
+  //We have a 'frame' in the bottom and right - so subtract them from the view
+  h-=1;
+  w-=1;
+  p.setClipRect( 0, 0, w , h );
 
-  p.setClipRect( 1, 1, w - 2, h - 2 );
   double range = mMaxValue - mMinValue;
-
   /* If the range is too small we will force it to 1.0 since it
    * looks a lot nicer. */
   if ( range < 0.000001 )
@@ -722,8 +722,8 @@
     //Draw the bottom most (minimum) number as well
     if ( mShowLabels && h > ( fontheight + 1 ) * ( mHorizontalLinesCount + 1 )
          && w > 60 ) {
-      int value = (int)(minValue / mScaleDownBy);
-      QString number = KGlobal::locale()->formatNumber( value, (value >= 100)?0:1);
+      double value = minValue / mScaleDownBy;
+      QString number = KGlobal::locale()->formatNumber( value, (value >= 100)?0:2);
       val = QString( "%1 %2" ).arg( number, mUnit);
       p.setPen( mFontColor );
       p.drawText( 6, top + h - 2, val );
@@ -731,4 +731,11 @@
   }
 }
 
+QString KSignalPlotter::lastValue( int i) const
+{
+  if(mBeamData.isEmpty()) return QString::null;
+  double value = mBeamData.first()[i] / mScaleDownBy; //retrieve the newest value for this beam then scale it correct
+  QString number = KGlobal::locale()->formatNumber( value, (value >= 100)?0:2);
+  return QString( "%1 %2").arg(number, mUnit);
+}
 #include "SignalPlotter.moc"
--- trunk/KDE/kdebase/workspace/ksysguard/gui/SensorDisplayLib/SignalPlotter.h #610258:610259
@@ -110,6 +110,10 @@
     void setSvgBackground( const QString &filename );
     QString svgBackground() const;
 
+    /** Return a translated string like:   "34 %" or "100 KB" for beam i
+     */
+    QString lastValue( int i) const;
+
   protected:
     void updateDataBuffers();