From eed0410c56e870238cfa33382f9865c9d9287ef4 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 11 Feb 2008 06:11:13 +0000 Subject: [PATCH] * make setSize virtual as well since it sets d->size internally, so Applet needs to intercept that call * remove some dead code in widgets.cpp svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=773475 --- applet.cpp | 9 ++++++++- applet.h | 5 +++++ widgets/widget.cpp | 14 -------------- widgets/widget.h | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/applet.cpp b/applet.cpp index 776119058..5c75d32e8 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1352,6 +1352,11 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value) return Widget::itemChange(change, value); } +void Applet::setSize(const QSizeF &size) +{ + setGeometry(QRectF(pos(), size)); +} + void Applet::setGeometry(const QRectF& geometry) { Plasma::Constraints updatedConstraints(0); @@ -1361,7 +1366,9 @@ void Applet::setGeometry(const QRectF& geometry) qreal width = qBound(minimumSize().width(), geometry.size().width(), maximumSize().width()); qreal height = qBound(minimumSize().height(), geometry.size().height(), maximumSize().height()); - setSize(QSizeF(width, height)); + // it is important we call Widget::setSize(QSizeF) here to avoid recursing back to this + // method, creating an infinite loop + Widget::setSize(QSizeF(width, height)); if (layout()) { layout()->setGeometry(QRectF(QPoint(0, 0), contentSize())); diff --git a/applet.h b/applet.h index 0279c5e08..996a917c9 100644 --- a/applet.h +++ b/applet.h @@ -729,6 +729,11 @@ class PLASMA_EXPORT Applet : public Widget */ QVariant itemChange(GraphicsItemChange change, const QVariant &value); + /** + * Reimplemented from QGraphicsItem + */ + void setSize(const QSizeF& size); + protected Q_SLOTS: /** * @internal used to show the configuration of an applet on first show diff --git a/widgets/widget.cpp b/widgets/widget.cpp index 8e1664c4e..cc181b110 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -251,13 +251,6 @@ QRectF Widget::geometry() const return QRectF(pos(), d->size); } -#if 0 -QRectF Widget::localGeometry() const -{ - return QRectF(QPointF(0.0f, 0.0f), boundingRect().size); -} -#endif - void Widget::setGeometry(const QRectF& geometry) { if (geometry.size().width() > 0 && geometry.size().height() > 0 && d->size != geometry.size()) { @@ -318,12 +311,6 @@ QFont Widget::font() const return QApplication::font(); } -/* -void Widget::setFont(const QFront& font) -{ -} -*/ - QRectF Widget::boundingRect() const { return QRectF(QPointF(0,0), d->size); @@ -331,7 +318,6 @@ QRectF Widget::boundingRect() const void Widget::resize(const QSizeF& size) { - //FIXME: we need to respect minimum size here i think setGeometry(QRectF(pos(), size)); } diff --git a/widgets/widget.h b/widgets/widget.h index efbd69404..dda0b4194 100644 --- a/widgets/widget.h +++ b/widgets/widget.h @@ -308,7 +308,7 @@ protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value); void setSize(qreal width, qreal height); - void setSize(const QSizeF& size); + virtual void setSize(const QSizeF& size); void managingLayoutChanged(); virtual bool sceneEvent(QEvent *event);