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
This commit is contained in:
Marco Martin 2008-08-07 10:34:14 +00:00
parent 748d03d7d0
commit a2d36c8844
2 changed files with 15 additions and 2 deletions

View File

@ -133,6 +133,10 @@ void Dialog::resizeEvent(QResizeEvent *e)
void Dialog::setGraphicsWidget(QGraphicsWidget *widget) void Dialog::setGraphicsWidget(QGraphicsWidget *widget)
{ {
if (d->widget) {
d->widget->removeEventFilter(this);
}
d->widget = widget; d->widget = widget;
if (widget) { if (widget) {
@ -154,7 +158,7 @@ void Dialog::setGraphicsWidget(QGraphicsWidget *widget)
adjustSize(); adjustSize();
connect(widget, SIGNAL(geometryChanged()), this, SLOT(adjustView())); widget->installEventFilter(this);
} else { } else {
delete d->view; delete d->view;
d->view = 0; d->view = 0;
@ -166,5 +170,14 @@ QGraphicsWidget *Dialog::graphicsWidget()
return d->widget; 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" #include "dialog.moc"

View File

@ -65,6 +65,7 @@ class PLASMA_EXPORT Dialog : public QWidget
*/ */
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
bool eventFilter(QObject *watched, QEvent *event);
private: private:
DialogPrivate * const d; DialogPrivate * const d;
@ -72,7 +73,6 @@ class PLASMA_EXPORT Dialog : public QWidget
* React to theme changes * React to theme changes
*/ */
Q_PRIVATE_SLOT(d, void themeUpdated()) Q_PRIVATE_SLOT(d, void themeUpdated())
Q_PRIVATE_SLOT(d, void adjustView())
}; };
} // Plasma namespace } // Plasma namespace