From b175042a04f9be1d2a226bdcd07b6f80d897f1b3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 20 Apr 2008 14:23:37 +0000 Subject: [PATCH] - 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 --- containment.cpp | 6 ++++-- desktoptoolbox.cpp | 10 ++++++++++ desktoptoolbox_p.h | 1 + paneltoolbox.cpp | 5 +++++ paneltoolbox_p.h | 2 +- toolbox.cpp | 9 --------- toolbox_p.h | 1 - 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/containment.cpp b/containment.cpp index 271996af0..127ac4064 100644 --- a/containment.cpp +++ b/containment.cpp @@ -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); diff --git a/desktoptoolbox.cpp b/desktoptoolbox.cpp index c50b4c2fa..ba838258b 100644 --- a/desktoptoolbox.cpp +++ b/desktoptoolbox.cpp @@ -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) diff --git a/desktoptoolbox_p.h b/desktoptoolbox_p.h index d11780777..585a70bd9 100644 --- a/desktoptoolbox_p.h +++ b/desktoptoolbox_p.h @@ -43,6 +43,7 @@ class DesktopToolbox : public Toolbox public: explicit DesktopToolbox(QGraphicsItem *parent = 0); + QRectF boundingRect() const; QPainterPath shape() const; void showToolbox(); diff --git a/paneltoolbox.cpp b/paneltoolbox.cpp index bb04f8ad1..e736e3d53 100644 --- a/paneltoolbox.cpp +++ b/paneltoolbox.cpp @@ -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 diff --git a/paneltoolbox_p.h b/paneltoolbox_p.h index 86c9a419d..8ef07005b 100644 --- a/paneltoolbox_p.h +++ b/paneltoolbox_p.h @@ -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(); diff --git a/toolbox.cpp b/toolbox.cpp index c9b3ab935..2ce74f479 100644 --- a/toolbox.cpp +++ b/toolbox.cpp @@ -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) diff --git a/toolbox_p.h b/toolbox_p.h index 179b635dc..3a03fa818 100644 --- a/toolbox_p.h +++ b/toolbox_p.h @@ -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);