rpms/kdebase-workspace/devel kdebase-workspace-4.0.99-plasma-tooltips.patch, NONE, 1.1 kdebase-workspace.spec, 1.107, 1.108

Kevin Kofler (kkofler) fedora-extras-commits at redhat.com
Sat Jul 19 15:58:29 UTC 2008


Author: kkofler

Update of /cvs/pkgs/rpms/kdebase-workspace/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11789/devel

Modified Files:
	kdebase-workspace.spec 
Added Files:
	kdebase-workspace-4.0.99-plasma-tooltips.patch 
Log Message:
* Sat Jul 19 2008 Kevin Kofler <Kevin at tigcc.ticalc.org> 4.0.99-2
- backport Plasma tooltip manager from KDE 4.2 (fixes regression from 4.0)
  WARNING: Adds some new APIs from 4.2 (Plasma::popupPosition, Plasma::viewFor,
           Plasma::ToolTip*), use at your own risk, we have no control to
           guarantee that they will not change!

kdebase-workspace-4.0.99-plasma-tooltips.patch:

--- NEW FILE kdebase-workspace-4.0.99-plasma-tooltips.patch ---
diff -Nur kdebase-workspace-4.0.99/libs/plasma/applet.cpp kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/applet.cpp
--- kdebase-workspace-4.0.99/libs/plasma/applet.cpp	2008-07-17 23:32:49.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/applet.cpp	2008-07-19 17:34:22.000000000 +0200
@@ -27,7 +27,6 @@
 
 #include <QAction>
 #include <QApplication>
-#include <QDesktopWidget>
 #include <QEvent>
 #include <QFile>
 #include <QGraphicsGridLayout>
@@ -76,6 +75,7 @@
 #include "plasma/view.h"
 #include "plasma/widgets/label.h"
 #include "plasma/widgets/pushbutton.h"
+#include "plasma/tooltipmanager.h"
 
 //#define DYNAMIC_SHADOWS
 namespace Plasma
@@ -411,13 +411,16 @@
         return 0;
     }
 
+    QGraphicsView *found = 0;
     foreach (QGraphicsView *view, scene()->views()) {
         if (view->sceneRect().intersects(sceneBoundingRect()) ||
             view->sceneRect().contains(scenePos())) {
-            return view;
+            if (!found || view->isActiveWindow()) {
+                found = view;
+            }
         }
     }
-    return 0;
+    return found;
 }
 
 QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
@@ -434,55 +437,7 @@
 
 QPoint Applet::popupPosition(const QSize &s) const
 {
-    QGraphicsView *v = view();
-    Q_ASSERT(v);
-
-    QPoint pos = v->mapFromScene(scenePos());
-    pos = v->mapToGlobal(pos);
-    //kDebug() << "==> position is" << scenePos() << v->mapFromScene(scenePos()) << pos;
-    Plasma::View *pv = dynamic_cast<Plasma::View *>(v);
-
-    Plasma::Location loc = Floating;
-    if (pv) {
-        loc = pv->containment()->location();
-    }
-
-    switch (loc) {
-    case BottomEdge:
-        pos = QPoint(pos.x(), pos.y() - s.height());
-        break;
-    case TopEdge:
-        pos = QPoint(pos.x(), pos.y() + (int)size().height());
-        break;
-    case LeftEdge:
-        pos = QPoint(pos.x() + (int)size().width(), pos.y());
-        break;
-    case RightEdge:
-        pos = QPoint(pos.x() - s.width(), pos.y());
-        break;
-    default:
-        if (pos.y() - s.height() > 0) {
-             pos = QPoint(pos.x(), pos.y() - s.height());
-        } else {
-             pos = QPoint(pos.x(), pos.y() + (int)size().height());
-        }
-    }
-
-    //are we out of screen?
-
-    QRect screenRect = QApplication::desktop()->screenGeometry(pv ? pv->containment()->screen() : -1);
-    //kDebug() << "==> rect for" << (pv ? pv->containment()->screen() : -1) << "is" << screenRect;
-
-    if (pos.rx() + s.width() > screenRect.right()) {
-        pos.rx() -= ((pos.rx() + s.width()) - screenRect.right());
-    }
-
-    if (pos.ry() + s.height() > screenRect.bottom()) {
-        pos.ry() -= ((pos.ry() + s.height()) - screenRect.bottom());
-    }
-    pos.rx() = qMax(0, pos.rx());
-
-    return pos;
+    return Plasma::popupPosition(this, s);
 }
 
 void Applet::updateConstraints(Plasma::Constraints constraints)
diff -Nur kdebase-workspace-4.0.99/libs/plasma/CMakeLists.txt kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/CMakeLists.txt
--- kdebase-workspace-4.0.99/libs/plasma/CMakeLists.txt	2008-07-17 23:32:49.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/CMakeLists.txt	2008-07-19 17:33:19.000000000 +0200
@@ -58,6 +58,8 @@
     svg.cpp
     theme.cpp
     toolbox.cpp
+    tooltipmanager.cpp
+    tooltip.cpp
     uiloader.cpp
     version.cpp
     view.cpp
@@ -140,7 +142,9 @@
     servicejob.h
     svg.h
     theme.h
+    tooltipmanager.h
     uiloader.h
+    tooltipmanager.h
     version.h
     view.h)
 
@@ -225,6 +229,7 @@
 includes/SignalPlotter
 includes/Svg
 includes/TextEdit
+includes/ToolTipManager
 includes/Theme
 includes/UiLoader
 includes/View
diff -Nur kdebase-workspace-4.0.99/libs/plasma/containment.cpp kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/containment.cpp
--- kdebase-workspace-4.0.99/libs/plasma/containment.cpp	2008-07-17 23:32:49.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/containment.cpp	2008-07-19 17:34:22.000000000 +0200
@@ -1280,6 +1280,9 @@
     // point anymore since we are in the qobject dtor. we don't actually
     // try and do anything with it, we just need the value of the pointer
     // so this unsafe looking code is actually just fine.
+    //
+    // NOTE: DO NOT USE THE applet VARIABLE FOR ANYTHING OTHER THAN COMPARING
+    //       THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!!
     Applet* applet = static_cast<Plasma::Applet*>(object);
     applets.removeAll(applet);
     if (focusedApplet == applet) {
diff -Nur kdebase-workspace-4.0.99/libs/plasma/includes/ToolTipManager kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/includes/ToolTipManager
--- kdebase-workspace-4.0.99/libs/plasma/includes/ToolTipManager	1970-01-01 01:00:00.000000000 +0100
+++ kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/includes/ToolTipManager	2008-07-19 17:33:19.000000000 +0200
@@ -0,0 +1 @@
+#include "../../plasma/tooltipmanager.h"
diff -Nur kdebase-workspace-4.0.99/libs/plasma/plasma.cpp kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/plasma.cpp
--- kdebase-workspace-4.0.99/libs/plasma/plasma.cpp	2008-07-08 11:26:23.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/libs/plasma/plasma.cpp	2008-07-19 17:34:22.000000000 +0200
@@ -17,7 +17,14 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-#include <plasma.h>
+#include <plasma/plasma.h>
+
+#include <QDesktopWidget>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+
+#include <plasma/containment.h>
+#include <plasma/view.h>
 
 namespace Plasma
 {
@@ -62,4 +69,78 @@
     return Down;
 }
 
+QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
+{
+    QGraphicsView *v = viewFor(item);
+
+    if (!v) {
+        return QPoint(0,0);
+    }
+
+    QPoint pos = v->mapFromScene(item->scenePos());
+    pos = v->mapToGlobal(pos);
+    //kDebug() << "==> position is" << scenePos() << v->mapFromScene(scenePos()) << pos;
+    Plasma::View *pv = dynamic_cast<Plasma::View *>(v);
+
+    Plasma::Location loc = Floating;
+    if (pv) {
+        loc = pv->containment()->location();
+    }
+
+    switch (loc) {
+    case BottomEdge:
+        pos = QPoint(pos.x(), pos.y() - s.height());
+        break;
+    case TopEdge:
+        pos = QPoint(pos.x(), pos.y() + (int)item->boundingRect().size().height());
+        break;
+    case LeftEdge:
+        pos = QPoint(pos.x() + (int)item->boundingRect().size().width(), pos.y());
+        break;
+    case RightEdge:
+        pos = QPoint(pos.x() - s.width(), pos.y());
+        break;
+    default:
+        if (pos.y() - s.height() > 0) {
[...1822 lines suppressed...]
             m_icon->setDrawBackground(false);
         }
     }
diff -Nur kdebase-workspace-4.0.99/plasma/applets/tasks/windowtaskitem.cpp kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/tasks/windowtaskitem.cpp
--- kdebase-workspace-4.0.99/plasma/applets/tasks/windowtaskitem.cpp	2008-07-15 21:48:49.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/tasks/windowtaskitem.cpp	2008-07-19 17:34:22.000000000 +0200
@@ -41,6 +41,7 @@
 #include "plasma/theme.h"
 #include "plasma/paintutils.h"
 #include "plasma/panelsvg.h"
+#include "plasma/tooltipmanager.h"
 
 #include "tasks.h"
 
@@ -61,12 +62,18 @@
     setAcceptsHoverEvents(true);
     setAcceptDrops(true);
 
+    Plasma::ToolTipManager::self()->registerWidget(this);
+
     QFontMetrics fm(KGlobalSettings::taskbarFont());
     QSize mSize = fm.size(0, "M");
     setPreferredSize(QSize(mSize.width()*15 + m_applet->itemLeftMargin() + m_applet->itemRightMargin() + IconSize(KIconLoader::Panel),
                            mSize.height()*3 + m_applet->itemTopMargin() + m_applet->itemBottomMargin()));
 }
 
+WindowTaskItem::~WindowTaskItem()
+{
+}
+
 void WindowTaskItem::activate()
 {
     // the Task class has a method called activateRaiseOrIconify() which
@@ -552,19 +559,18 @@
     taskIcon.addPixmap(m_task->icon(KIconLoader::SizeMedium, KIconLoader::SizeMedium, false));
     taskIcon.addPixmap(m_task->icon(KIconLoader::SizeLarge, KIconLoader::SizeLarge, false));
 
-#ifdef TOOLTIP_MANAGER
     if (m_showTooltip) {
-      Plasma::ToolTipData data;
+      Plasma::ToolTipManager::ToolTipContent data;
       data.mainText = m_task->visibleName();
       data.subText = i18nc("Which virtual desktop a window is currently on", "On %1", KWindowSystem::desktopName(m_task->desktop()));
-      data.image = iconPixmap;
+      data.image = m_task->icon(KIconLoader::SizeSmall, KIconLoader::SizeSmall, false);
       data.windowToPreview = m_task->window();
-      setToolTip(data);
-    } else {
-        Plasma::ToolTipData data;
-        setToolTip(data); // Clear
+
+      Plasma::ToolTipManager::self()->setToolTipContent(this,data);
+    }
+    else {
+      Plasma::ToolTipManager::self()->unregisterWidget(this);
     }
-#endif
     setIcon(taskIcon);
     setText(m_task->visibleName());
     //redraw
@@ -722,4 +728,5 @@
                                      size, bounds.toRect());
 }
 
+
 #include "windowtaskitem.moc"
diff -Nur kdebase-workspace-4.0.99/plasma/applets/tasks/windowtaskitem.h kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/tasks/windowtaskitem.h
--- kdebase-workspace-4.0.99/plasma/applets/tasks/windowtaskitem.h	2008-06-18 14:41:39.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/tasks/windowtaskitem.h	2008-07-19 17:34:22.000000000 +0200
@@ -57,6 +57,9 @@
     /** Constructs a new representation for a window task. */
     WindowTaskItem(Tasks *parent, const bool showTooltip);
 
+    /**Destruct the representation of the window task */
+    ~WindowTaskItem();
+
     /** Sets the starting task represented by this item. */
     void setStartupTask(TaskManager::StartupPtr task);
 
diff -Nur kdebase-workspace-4.0.99/plasma/applets/trash/trash.cpp kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/trash/trash.cpp
--- kdebase-workspace-4.0.99/plasma/applets/trash/trash.cpp	2008-07-15 21:48:49.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/trash/trash.cpp	2008-07-19 17:35:30.000000000 +0200
@@ -45,6 +45,7 @@
 //Plasma
 #include <plasma/widgets/icon.h>
 #include <plasma/containment.h>
+#include <plasma/tooltipmanager.h>
 
 //Solid
 #include <solid/devicenotifier.h>
@@ -100,10 +101,6 @@
 
     registerAsDragHandle(m_icon);
 
-    //setMinimumSize(m_icon->sizeFromIconSize(IconSize(KIconLoader::Small)));
-    //FIXME PORT TO TOOLTIP MANAGER
-    //m_data.mainText = i18n("Trash");
-
     connect(m_icon, SIGNAL(activated()), this, SLOT(slotOpen()));
     connect(&m_menu, SIGNAL(aboutToHide()),
             m_icon, SLOT(setUnpressed()));
@@ -201,17 +198,20 @@
 
 void Trash::setIcon()
 {
+    Plasma::ToolTipManager::ToolTipContent data;
+    data.mainText = i18n("Trash");
+
     if (m_count > 0) {
         m_icon->setIcon(KIcon("user-trash-full"));
-	//FIXME PORT TO TOOLTIP MANAGER
-        //m_data.subText = i18np("One item", "%1 items", m_count);
+
+        data.subText = i18np("One item", "%1 items", m_count);
         if (m_showText) {
             m_icon->setInfoText(i18np("One item", "%1 items", m_count));
         }
     } else {
         m_icon->setIcon(KIcon("user-trash"));
-        //FIXME PORT TO TOOLTIP MANAGER
-	//m_data.subText = i18nc("The trash is empty. This is not an action, but a state", "Empty");
+
+        data.subText = i18nc("The trash is empty. This is not an action, but a state", "Empty");
         if (m_showText){
             m_icon->setInfoText(i18nc("The trash is empty. This is not an action, but a state", "Empty"));
         }
@@ -219,14 +219,13 @@
 
     m_icon->update();
     
-    //FIXME TOOLTIP MANAGER
-    /*m_data.image = m_icon->icon().pixmap(IconSize(KIconLoader::Desktop));
+    data.image = m_icon->icon().pixmap(IconSize(KIconLoader::Desktop));
 
     if (!m_showText) {
-        m_icon->setToolTip(m_data);
+        Plasma::ToolTipManager::self()->setToolTipContent(this, data);
     } else {
-        m_icon->setToolTip(Plasma::ToolTipData());
-    }*/
+        Plasma::ToolTipManager::self()->setToolTipContent(this, Plasma::ToolTipManager::ToolTipContent());
+    }
 
     emptyTrash->setEnabled(m_count>0);
 }
diff -Nur kdebase-workspace-4.0.99/plasma/applets/trash/trash.h kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/trash/trash.h
--- kdebase-workspace-4.0.99/plasma/applets/trash/trash.h	2008-04-30 15:58:26.000000000 +0200
+++ kdebase-workspace-4.0.99-plasma-tooltips/plasma/applets/trash/trash.h	2008-07-19 17:35:30.000000000 +0200
@@ -75,8 +75,6 @@
         QAction *emptyTrash;
         int m_count;
         bool m_showText;
-        //FIXME PORT TO TOOLTIP MANAGER
-	//Plasma::ToolTipData m_data;
         KFilePlacesModel *m_places;
 };
 
diff -Nur kdebase-workspace-4.0.99/plasma/design/tooltips kdebase-workspace-4.0.99-plasma-tooltips/plasma/design/tooltips
--- kdebase-workspace-4.0.99/plasma/design/tooltips	1970-01-01 01:00:00.000000000 +0100
+++ kdebase-workspace-4.0.99-plasma-tooltips/plasma/design/tooltips	2008-07-19 17:34:22.000000000 +0200
@@ -0,0 +1,39 @@
+Tooltips
+==========
+
+Overview
+--------
+libplasma provides facilities to manage tooltips that display extended information in a visually pleasing and consistent manner for QGraphicsWidgets. These tooltip windows are themed using Plasma::Theme.
+
+Timeline
+--------
+Introduced in: libplasma 2.1 (KDE 4.2.0)
+
+Component Type
+--------------
+ToolTipManager is a QObject subclass in libplasma.
+ToolTip is an internal QWidget subclass in libplasma.
+
+Registering Tooltips
+--------------------
+ToolTipManger is quite simple to use: simply call setWidgetToolTipContent using the struct ToolTipContent. This causes the widget to be registered if it isn't already. Alternatively, for widgets that fill the data on demand, call registerWidget directly.
+
+Widgets are unregistered automatically upon destruction, but can also be manually unregsitered by calling ToolTipMnager::unregisterWidget.
+
+An event filter is registered on each registered widget and hover events that occur trigger calls to showToolTip and hideToolTip. The hover events are not, however, filtered out. 
+
+Note: If another event filter is placed on registered widget that filters out these events, it may be necessary to manually call showToolTip and hideToolTip.
+
+ToolTip Updates
+---------------
+Updating tooltip data is supported by means of invoking slots on the associated widget if they exist. In particular, just prior to being shown the toolTipAboutToShow method is invoked and when hiding the toolTipHidden method is invoked.
+
+ToolTip Visualization
+---------------------
+The internal (non-exported) ToolTip class is used to actually display the tooltips. These are associated with widgets and created as necessary.
+
+ToolTip displays are only created when data is set, and are deleted if an empty ToolTipData struct is passed in. This keeps memory usage due to ToolTip objects down.
+
+Future Work
+-----------
+N/A


Index: kdebase-workspace.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kdebase-workspace/devel/kdebase-workspace.spec,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -r1.107 -r1.108
--- kdebase-workspace.spec	18 Jul 2008 15:16:58 -0000	1.107
+++ kdebase-workspace.spec	19 Jul 2008 15:57:44 -0000	1.108
@@ -4,7 +4,7 @@
 Name: kdebase-workspace
 Version: 4.0.99
 
-Release: 1%{?dist}
+Release: 2%{?dist}
 Source0: ftp://ftp.kde.org/pub/kde/unstable/%{version}/src/kdebase-workspace-%{version}.tar.bz2
 License: GPLv2
 Group: User Interface/Desktops
@@ -26,6 +26,11 @@
 Patch11: kdebase-workspace-4.0.85-plasma-default-wallpaper.patch
 
 # upstream patches:
+# backport Plasma tooltip manager from KDE 4.2 (fixes regression from 4.0)
+# This is a cumulative patch from the following revision pairs: 833271:833299,
+# 833385:833386, 833479:833545, 833580:833581, 833587:833620, 834651:834652
+# This is backwards BC wrt 4.1, but the API of the new classes is not finalized.
+Patch100: kdebase-workspace-4.0.99-plasma-tooltips.patch
 
 # plasma-4.0-openSUSE patches:
 Patch204: kdebase-workspace-4.0.98-kickoff-suspend.patch
@@ -139,6 +144,7 @@
 %patch11 -p1 -b .plasma-default-wallpaper
 
 # upstream patches
+%patch100 -p1 -b .plasma-tooltips
 
 # plasma-4.0-openSUSE patches:
 %patch204 -p1 -b .kickoff-suspend
@@ -274,6 +280,12 @@
 
 
 %changelog
+* Sat Jul 19 2008 Kevin Kofler <Kevin at tigcc.ticalc.org> 4.0.99-2
+- backport Plasma tooltip manager from KDE 4.2 (fixes regression from 4.0)
+  WARNING: Adds some new APIs from 4.2 (Plasma::popupPosition, Plasma::viewFor,
+           Plasma::ToolTip*), use at your own risk, we have no control to
+           guarantee that they will not change!
+
 * Fri Jul 18 2008 Rex Dieter <rdieter at fedoraproject.org> 4.0.99-1
 - 4.0.99
 




More information about the scm-commits mailing list