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

List:       kde-commits
Subject:    KDE/kdelibs/plasma/private
From:       Marco Martin <notmart () gmail ! com>
Date:       2010-04-24 18:54:34
Message-ID: 20100424185434.DF841AC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1118438 by mart:

use an itembackground


 M  +23 -0     desktoptoolbox.cpp  


--- trunk/KDE/kdelibs/plasma/private/desktoptoolbox.cpp #1118437:1118438
@@ -41,6 +41,7 @@
 #include <plasma/tooltipcontent.h>
 #include <plasma/tooltipmanager.h>
 #include <plasma/widgets/iconwidget.h>
+#include <plasma/widgets/itembackground.h>
 
 namespace Plasma
 {
@@ -59,6 +60,7 @@
             m_background->setImagePath("widgets/background");
             m_background->setEnabledBorders(FrameSvg::AllBorders);
             m_layout->setOrientation(Qt::Vertical);
+            m_itemBackground = new Plasma::ItemBackground(this);
             updateMargins();
         }
 
@@ -81,13 +83,23 @@
         void clearLayout()
         {
             while (m_layout->count()) {
+                //safe? at the moment everything it's thre will always be QGraphicsWidget
+                static_cast<QGraphicsWidget *>(m_layout->itemAt(0))->removeEventFilter(this);
                 m_layout->removeAt(0);
             }
         }
 
         void addToLayout(QGraphicsWidget *widget)
         {
+            qreal left, top, right, bottom;
+            m_itemBackground->getContentsMargins(&left, &top, &right, &bottom);
+            widget->setContentsMargins(left, top, right, bottom);
             m_layout->addItem(widget);
+            widget->installEventFilter(this);
+
+            if (m_layout->count() == 1) {
+                m_itemBackground->setTargetItem(widget);
+            }
         }
 
     protected:
@@ -96,10 +108,20 @@
             m_background->resizeFrame(size());
         }
 
+        bool eventFilter(QObject *watched, QEvent *event)
+        {
+            QGraphicsWidget *widget = qobject_cast<QGraphicsWidget *>(watched);
+            if (event->type() == QEvent::GraphicsSceneHoverEnter) {
+                m_itemBackground->setTargetItem(widget);
+            }
+            return false;
+        }
+
     private:
         QRectF m_rect;
         Plasma::FrameSvg *m_background;
         QGraphicsLinearLayout *m_layout;
+        Plasma::ItemBackground *m_itemBackground;
 };
 
 // used with QGrahphicsItem::setData
@@ -525,6 +547,7 @@
         //kDebug() << "showing off" << it.key() << icon->text();
         if (icon->isEnabled()) {
             icon->show();
+            icon->setDrawBackground(false);
             d->toolBacker->addToLayout(icon);
         } else {
             icon->hide();
[prev in list] [next in list] [prev in thread] [next in thread] 

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