From a2d36c884459ac1e272a194ac43215de772e59ef Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 7 Aug 2008 10:34:14 +0000 Subject: [PATCH] sigh, with qgraphicswidgets we don't have the luxury of the geometrychanged() signal... trying with an event filter svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=843566 --- dialog.cpp | 15 ++++++++++++++- dialog.h | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dialog.cpp b/dialog.cpp index 25a0a1aae..ea73b3a1c 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -133,6 +133,10 @@ void Dialog::resizeEvent(QResizeEvent *e) void Dialog::setGraphicsWidget(QGraphicsWidget *widget) { + if (d->widget) { + d->widget->removeEventFilter(this); + } + d->widget = widget; if (widget) { @@ -154,7 +158,7 @@ void Dialog::setGraphicsWidget(QGraphicsWidget *widget) adjustSize(); - connect(widget, SIGNAL(geometryChanged()), this, SLOT(adjustView())); + widget->installEventFilter(this); } else { delete d->view; d->view = 0; @@ -166,5 +170,14 @@ QGraphicsWidget *Dialog::graphicsWidget() return d->widget; } +bool Dialog::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == d->widget && event->type() == QEvent::GraphicsSceneResize) { + d->adjustView(); + } + + return QWidget::eventFilter(watched, event); +} + } #include "dialog.moc" diff --git a/dialog.h b/dialog.h index 18f6420cf..565b73785 100644 --- a/dialog.h +++ b/dialog.h @@ -65,6 +65,7 @@ class PLASMA_EXPORT Dialog : public QWidget */ void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); + bool eventFilter(QObject *watched, QEvent *event); private: DialogPrivate * const d; @@ -72,7 +73,6 @@ class PLASMA_EXPORT Dialog : public QWidget * React to theme changes */ Q_PRIVATE_SLOT(d, void themeUpdated()) - Q_PRIVATE_SLOT(d, void adjustView()) }; } // Plasma namespace