Moving IconApplets when clicking on the icon

Jason Stubbs jasonbstubbs at gmail.com
Thu Jan 3 05:45:13 CET 2008


On Thursday 03 January 2008 13:20:15 JST, Christopher Blauvelt wrote:
> Attached is a patch which will allow you to move icons when clicking on the
> icon itself rather than just the clicking on the handle.  This time with
> fewer style violations. :)


-    if (boundingRect().contains(event->pos())) {
-        if (~d->states & Private::HoverState) {
-            d->states |= Private::HoverState;
-            update();
-        }
-    } else {
-        if (d->states & Private::HoverState) {
-            d->states &= ~Private::HoverState;
-            update();
-        }
-    }
+    d->states |= Private::MovedState;


Why is the HoverState stuff being removed? In fact, it looks like none of the
libs/plasma/widgets/icon.* changes are necessary...


+#include <plasma/corona.h>


This also doesn't look necessary...


-    double width = qBound(minimumSize().width(), iconSize.width(), 
maximumSize().width());
-    double height = qBound(minimumSize().height(), iconSize.height(), 
maximumSize().height());
+    qreal width = qBound(minimumSize().width(), iconSize.width(), 
maximumSize().width());
+    qreal height = qBound(minimumSize().height(), iconSize.height(), 
maximumSize().height());


These sorts of changes (while correct) make patches harder to review.


+    QGraphicsItem* appletHandle = parentItem();
+
+    if(appletHandle) {
+        //don't move the icon as well because appletHandle will do it for us
+        appletHandle->moveBy(delta.x(),delta.y());


I haven't tested this, but it looks like this would move the entire panel when 
dragging an icon applet that's within the panel. I wonder if AppletHandle 
can't listen for position changes somehow and update itself...

-- 
Jason Stubbs


More information about the Panel-devel mailing list