summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsview.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-05 14:36:15 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-06 11:19:59 (GMT)
commitd9c226c72105ef221c766cb9f616d10329197880 (patch)
tree8f8a03a4c873353d63197508480a952080d5d11e /src/gui/graphicsview/qgraphicsview.cpp
parentf8a0b7b9ea2e077be7167c58d4eac27360d4cee6 (diff)
downloadQt-d9c226c72105ef221c766cb9f616d10329197880.zip
Qt-d9c226c72105ef221c766cb9f616d10329197880.tar.gz
Qt-d9c226c72105ef221c766cb9f616d10329197880.tar.bz2
Fix QGraphicsScene::isActive if the view is shown while the window is active.
We need to make sure the active state is preserved if graphicsview are dinamically shown/hide while window is active. Or if scene is changed with setScene. This fixes KRunner focus regressions Reviewed-by: Andreas Task-number: QTBUG-5281
Diffstat (limited to 'src/gui/graphicsview/qgraphicsview.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index d1dd26f..87585a2 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -1512,6 +1512,11 @@ void QGraphicsView::setScene(QGraphicsScene *scene)
this, SLOT(updateSceneRect(QRectF)));
d->scene->d_func()->removeView(this);
d->connectedToScene = false;
+
+ if (isActiveWindow() && isVisible()) {
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+ QApplication::sendEvent(d->scene, &windowDeactivate);
+ }
}
// Assign the new scene and update the contents (scrollbars, etc.)).
@@ -1533,6 +1538,11 @@ void QGraphicsView::setScene(QGraphicsScene *scene)
// enable touch events if any items is interested in them
if (!d->scene->d_func()->allItemsIgnoreTouchEvents)
d->viewport->setAttribute(Qt::WA_AcceptTouchEvents);
+
+ if (isActiveWindow() && isVisible()) {
+ QEvent windowActivate(QEvent::WindowActivate);
+ QApplication::sendEvent(d->scene, &windowActivate);
+ }
} else {
d->recalculateContentSize();
}
@@ -2638,6 +2648,19 @@ bool QGraphicsView::viewportEvent(QEvent *event)
d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
QApplication::sendEvent(d->scene, event);
break;
+ case QEvent::Show:
+ if (d->scene && isActiveWindow()) {
+ QEvent windowActivate(QEvent::WindowActivate);
+ QApplication::sendEvent(d->scene, &windowActivate);
+ }
+ break;
+ case QEvent::Hide:
+ // spontaneous event will generate a WindowDeactivate.
+ if (!event->spontaneous() && d->scene && isActiveWindow()) {
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+ QApplication::sendEvent(d->scene, &windowDeactivate);
+ }
+ break;
case QEvent::Leave:
// ### This is a temporary fix for until we get proper mouse grab
// events. activeMouseGrabberItem should be set to 0 if we lose the