- boundingRect() now is pure virtual in Toolbox class

- correctly places the toolbox in vertical panels

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=799135
This commit is contained in:
Marco Martin 2008-04-20 14:23:37 +00:00
parent f27fb3fc1b
commit b175042a04
7 changed files with 21 additions and 13 deletions

View File

@ -252,10 +252,12 @@ void Containment::containmentConstraintsUpdated(Plasma::Constraints constraints)
//The placement assumes that the geometry width/height is no more than the screen
if (d->type == PanelContainment) {
if (formFactor() == Vertical) {
d->toolbox->setPos(geometry().width()/2 - d->toolbox->boundingRect().width()/2, geometry().bottom());
d->toolbox->setOrientation(Qt::Vertical);
d->toolbox->setPos(geometry().width()/2 - d->toolbox->boundingRect().width()/2, geometry().height());
//defaulting to Horizontal right now
} else {
d->toolbox->setPos(geometry().right(), geometry().height()/2 - d->toolbox->boundingRect().height()/2);
d->toolbox->setOrientation(Qt::Horizontal);
d->toolbox->setPos(geometry().width(), geometry().height()/2 - d->toolbox->boundingRect().height()/2);
}
} else {
d->toolbox->setPos(geometry().right() - qAbs(d->toolbox->boundingRect().width()), 0);

View File

@ -98,6 +98,16 @@ DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
d(new Private)
{
connect(Plasma::Phase::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
setZValue(10000000);
setFlag(ItemClipsToShape, true);
setFlag(ItemClipsChildrenToShape, false);
setFlag(ItemIgnoresTransformations, true);
}
QRectF DesktopToolbox::boundingRect() const
{
return QRectF(0, 0, -size()*2, size()*2);
}
void DesktopToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)

View File

@ -43,6 +43,7 @@ class DesktopToolbox : public Toolbox
public:
explicit DesktopToolbox(QGraphicsItem *parent = 0);
QRectF boundingRect() const;
QPainterPath shape() const;
void showToolbox();

View File

@ -97,6 +97,11 @@ PanelToolbox::PanelToolbox(QGraphicsItem *parent)
d(new Private)
{
connect(Plasma::Phase::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
setZValue(10000000);
setFlag(ItemClipsToShape, true);
setFlag(ItemClipsChildrenToShape, false);
setFlag(ItemIgnoresTransformations, true);
}
QRectF PanelToolbox::boundingRect() const

View File

@ -43,7 +43,7 @@ class PanelToolbox : public Toolbox
public:
explicit PanelToolbox(QGraphicsItem *parent = 0);
virtual QRectF boundingRect() const;
QRectF boundingRect() const;
QPainterPath shape() const;
void showToolbox();

View File

@ -59,15 +59,6 @@ Toolbox::Toolbox(QGraphicsItem *parent)
d(new Private)
{
setAcceptsHoverEvents(true);
setZValue(10000000);
setFlag(ItemClipsToShape, true);
setFlag(ItemClipsChildrenToShape, false);
setFlag(ItemIgnoresTransformations, true);
}
QRectF Toolbox::boundingRect() const
{
return QRectF(0, 0, -size()*2, size()*2);
}
void Toolbox::addTool(QGraphicsItem *tool, const QString &name)

View File

@ -38,7 +38,6 @@ class Toolbox : public QObject, public QGraphicsItem
public:
explicit Toolbox(QGraphicsItem *parent = 0);
virtual QRectF boundingRect() const;
void addTool(QGraphicsItem *tool, const QString &name);
void enableTool(const QString &tool, bool enabled);