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

List:       kde-commits
Subject:    KDE/kdebase/workspace
From:       Rob Scheepmaker <r.scheepmaker () student ! utwente ! nl>
Date:       2008-08-25 13:55:28
Message-ID: 1219672528.525883.31212.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 852189 by scheepmaker:

Some changes to PopupApplet to make it a useful base class for extender using applets, 
and some changes to libplasmaclock to make it's dialog get the correct size.
Works quite well, but for some reason dragging extender items from the dialog doesn't 
work correctly right now, I'm working on that.



 M  +10 -6     libs/plasma/extenderitem.cpp  
 M  +27 -0     libs/plasma/popupapplet.cpp  
 M  +1 -0      libs/plasma/popupapplet.h  
 M  +3 -0      plasma/applets/libplasmaclock/clockapplet.cpp  


--- trunk/KDE/kdebase/workspace/libs/plasma/extenderitem.cpp #852188:852189
@@ -95,14 +95,14 @@
                 if (widget->geometry().intersects(rect)) {
                     //is this widget a plasma view, a different view then our current one,
                     //AND not a dashboardview?
-                    Plasma::View *v = qobject_cast<View*>(widget);
-                    Plasma::View *currentV = 0;
+                    QGraphicsView *v = qobject_cast<QGraphicsView*>(widget);
+                    QGraphicsView *currentV = 0;
 
                     if (hostApplet()) {
-                        currentV = qobject_cast<View*>(hostApplet()->containment()->view());
+                        currentV = qobject_cast<QGraphicsView*>(hostApplet()->containment()->view());
                     }
-                    if (v && v != currentV
-                          && v->containment() != hostApplet()->containment()) {
+
+                    if (v && v != currentV) {
                         return true;
                     }
                 }
@@ -474,7 +474,6 @@
 
 void ExtenderItem::addAction(const QString &name, QAction *action)
 {
-
     Q_ASSERT(action);
 
     d->actions[name] = action;
@@ -653,6 +652,11 @@
         d->extender->itemHoverMoveEvent(this, d->extender->mapFromScene(mousePos));
     }
 
+    //call the move event, since that spawns a toplevel view when this extender item is in a
+    //Plasma::Dialog, which is very essential since else the dialog will close before having been
+    //able to receive any move events.
+    mouseMoveEvent(event);
+
     QApplication::setOverrideCursor(Qt::ClosedHandCursor);
 }
 
--- trunk/KDE/kdebase/workspace/libs/plasma/popupapplet.cpp #852188:852189
@@ -29,6 +29,7 @@
 
 #include <plasma/dialog.h>
 #include <plasma/corona.h>
+#include <plasma/containment.h>
 #include <plasma/widgets/icon.h>
 
 namespace Plasma
@@ -136,6 +137,12 @@
         connect(d->icon, SIGNAL(clicked()), this, SLOT(togglePopup()));
     }
 
+    //since we call this function when an extender's geometry gets updated, we want to avoid doing
+    //anything if the StartupCompletedConstraint hasn't been called yet.
+    if (!d->layout) {
+        return;
+    }
+
     if (constraints & Plasma::FormFactorConstraint) {
         d->layout->removeAt(0);
 
@@ -220,6 +227,11 @@
 
             d->dialog->adjustSize();
             d->layout->addItem(d->icon);
+
+            setMinimumSize(QSizeF(0, 0));
+            setMaximumWidth(containment()->size().height());
+            setMaximumHeight(containment()->size().height());
+
             break;
         }
     }
@@ -253,6 +265,21 @@
     }
 }
 
+void PopupApplet::widgetGeometryChanged()
+{
+    if (graphicsWidget()) {
+        //sizes are recalculated in the constraintsevent so let's just call that.
+        if (layout()) {
+            constraintsEvent(Plasma::FormFactorConstraint);
+
+            //resize vertically if necesarry.
+            if (formFactor() == Plasma::MediaCenter || formFactor() == Plasma::Planar) {
+                resize(QSizeF(size().width(), minimumHeight()));
+            }
+        }
+    }
+}
+
 void PopupAppletPrivate::togglePopup()
 {
    if (dialog) {
--- trunk/KDE/kdebase/workspace/libs/plasma/popupapplet.h #852188:852189
@@ -51,6 +51,7 @@
 
 public Q_SLOTS:
     void hidePopup();
+    void widgetGeometryChanged();
 
 protected:
     void constraintsEvent(Plasma::Constraints constraints);
--- trunk/KDE/kdebase/workspace/plasma/applets/libplasmaclock/clockapplet.cpp #852188:852189
@@ -243,12 +243,15 @@
     
     Plasma::Extender *extender = new Plasma::Extender(this);
     containment()->corona()->addOffscreenWidget(extender);
+    connect(extender, SIGNAL(geometryChanged()), this, SLOT(adjustView()));
 }
 
 void ClockApplet::showCalendar(QGraphicsSceneMouseEvent *event)
 {
     Q_UNUSED(event);
 
+    adjustView();
+
     if (!d->calendarDialog) {
         if (!extender()) {
             // in case the subclass didn't call the parent init() properly
[prev in list] [next in list] [prev in thread] [next in thread] 

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