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.


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=852189
This commit is contained in:
Rob Scheepmaker 2008-08-25 13:55:26 +00:00
parent 9244760edb
commit 27cdeadb03
3 changed files with 38 additions and 6 deletions

View File

@ -95,14 +95,14 @@ class ExtenderItemPrivate
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 @@ bool ExtenderItem::isDetached() const
void ExtenderItem::addAction(const QString &name, QAction *action)
{
Q_ASSERT(action);
d->actions[name] = action;
@ -653,6 +652,11 @@ void ExtenderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
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);
}

View File

@ -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 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
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 @@ void PopupApplet::constraintsEvent(Plasma::Constraints constraints)
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::hidePopup()
}
}
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) {

View File

@ -51,6 +51,7 @@ public:
public Q_SLOTS:
void hidePopup();
void widgetGeometryChanged();
protected:
void constraintsEvent(Plasma::Constraints constraints);