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

List:       kde-commits
Subject:    kdepim/kontact/src
From:       Till Adam <adam () kde ! org>
Date:       2005-03-27 20:37:58
Message-ID: 20050327203758.EDE4A3E9 () office ! kde ! org
[Download RAW message or body]

CVS commit by tilladam: 

If texts are not shown but only icons, show the plugin name as a tooltip.
Per-item tooltip technique courtesy of "Practical Qt", by Kalle Dalheimer,
Jesper Pedersenet al., section 3.5.


  M +6 -0      iconsidepane.cpp   1.42
  M +34 -1     iconsidepane.h   1.18


--- kdepim/kontact/src/iconsidepane.cpp  #1.41:1.42
@@ -35,4 +35,5 @@
 #include <qcursor.h>
 #include <qtimer.h>
+#include <qtooltip.h>
 
 #include <kpopupmenu.h>
@@ -271,4 +272,9 @@ Navigator::Navigator( SidePaneBase *pare
   mMapper = new QSignalMapper( this );
   connect( mMapper, SIGNAL( mapped( int ) ), SLOT( shortCutSelected( int ) ) );
+
+  QToolTip::remove( this );
+  if ( !mShowText )
+    new EntryItemToolTip( this );
+
 }
 

--- kdepim/kontact/src/iconsidepane.h  #1.17:1.18
@@ -22,8 +22,12 @@
 #define KONTACT_ICONSIDEPANEBASE_H
 
-#include "sidepanebase.h"
+#include <qtooltip.h>
 
 #include <klistbox.h>
 
+#include "sidepanebase.h"
+#include "prefs.h"
+
+
 class QSignalMapper;
 
@@ -80,4 +85,32 @@ class EntryItem : public QListBoxItem
 
 /**
+ * Tooltip that changes text depending on the item it is above.
+ * Compliments of "Practical Qt" by Dalheimer, Petersen et al.
+ */
+class EntryItemToolTip : public QToolTip
+{
+  public:
+    EntryItemToolTip( QListBox* parent )
+      : QToolTip( parent->viewport() ), mListBox( parent ) 
+      {}
+  protected:
+    void maybeTip( const QPoint& p ) {
+      // We only show tooltips when there are no texts shown
+      if ( Prefs::self()->sidePaneShowText() ) return;
+      if ( !mListBox ) return;
+      QListBoxItem* item = mListBox->itemAt( p );
+      if ( !item ) return;
+      const QRect itemRect = mListBox->itemRect( item );
+      if ( !itemRect.isValid() ) return;
+
+      const EntryItem *entryItem = static_cast<EntryItem*>( item );
+      QString tipStr = entryItem->text();
+      tip( itemRect, tipStr );
+    }
+  private:
+    QListBox* mListBox;
+};
+
+/**
   Navigation pane showing all parts relevant to the user
 */


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

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