Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > ce2e75decdd057e5c961fad858af3221 > files > 31

kdebase4-workspace-4.4.5-0.2mdv2010.2.src.rpm

#
# Description: Add tooltip support in the simpleapplet plasma menu
# Forwarded:  No
# Bug: N/A
# Author:  rodrigo@mandriva.com.br
#

diff -p -up plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp.orig plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp
--- plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp.orig   2010-05-10 15:30:03.000000000 -0300
+++ plasma/desktop/applets/kickoff/simpleapplet/menuview.cpp    2010-05-14 10:26:16.000000000 -0300
@@ -30,6 +30,7 @@
 #include <QtGui/QStandardItem>
 #include <QtGui/QStyleOptionMenuItem>
 #include <QtGui/QPainter>
+#include <QtGui/QToolTip>
 
 // KDE
 #include <KDebug>
@@ -170,9 +171,11 @@ void MenuView::updateAction(QAbstractIte
         switch (d->formattype) {
         case Name: {
             action->setText(name.isEmpty() ? text : name);
+       action->setToolTip(text.isEmpty() ? QString() : text);
         } break;
         case Description: {
             action->setText(name.contains(text, Qt::CaseInsensitive) ? name : text);
+       action->setToolTip(name.isEmpty() ? QString() : name);
         } break;
         case NameDescription: // fall through
         case NameDashDescription: // fall through
@@ -270,6 +273,29 @@ bool MenuView::eventFilter(QObject *watc
     case QEvent::Hide: {
         emit afterBeingHidden();
     } break;
+    case QEvent::ToolTip: {
+        bool hide = false;
+
+           if ((d->formattype == Name) || (d->formattype == Description)){
+          QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
+          QMenu *watchedMenu = qobject_cast<QMenu*>(watched);
+
+          if (watchedMenu && watchedMenu->activeAction()){
+       QString toolTip = watchedMenu->activeAction()->toolTip();
+
+       if ((toolTip != watchedMenu->activeAction()->text()) && (watchedMenu->activeAction()->menu() == 0))
+         QToolTip::showText(helpEvent->globalPos(), toolTip);
+       else
+         hide = true;
+     }
+   } else
+     hide = true;
+
+   if (hide){
+     QToolTip::hideText();
+     event->ignore();
+   }
+    } break;
     default: break;
     }