diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-11 07:30:53 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-09-15 09:31:02 (GMT) |
commit | a06c7db92ff13a1f8a353851a586ae12755e7c6c (patch) | |
tree | 775c7364e2591045304bfd737f0dd93b88a2bf9a /src/gui/graphicsview | |
parent | 9b579d7821205250b8d64b06a19d5e4fccd56f31 (diff) | |
download | Qt-a06c7db92ff13a1f8a353851a586ae12755e7c6c.zip Qt-a06c7db92ff13a1f8a353851a586ae12755e7c6c.tar.gz Qt-a06c7db92ff13a1f8a353851a586ae12755e7c6c.tar.bz2 |
Fix bugs in handling of initial focus.
Make sure you can't set focus on an inactive scene, allow items
with subfocus to gain focus even if added to a scene that's not
active, and finally ensure that activating a panel in an active,
but unfocused scene, gives focus to the scene.
Also added a test that checks adding normal vs. panel items to an
active vs. inactive scene, and what happens if you initially say
the item should have focus.
Reviewed-by: TrustMe
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index fbd78d9..97bc010 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -581,6 +581,9 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin return; } + // Ensure the scene has focus when we change panel activation. + q->setFocus(Qt::ActiveWindowFocusReason); + // Find the item's panel. QGraphicsItem *panel = item ? item->panel() : 0; lastActivePanel = panel ? activePanel : 0; @@ -2431,7 +2434,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. - if (!d->focusItem && item->focusItem() && item->isActive()) + if (!d->focusItem && item->focusItem()) item->focusItem()->setFocus(); d->updateInputMethodSensitivityInViews(); @@ -2780,7 +2783,7 @@ bool QGraphicsScene::hasFocus() const void QGraphicsScene::setFocus(Qt::FocusReason focusReason) { Q_D(QGraphicsScene); - if (d->hasFocus) + if (d->hasFocus || !isActive()) return; QFocusEvent event(QEvent::FocusIn, focusReason); QCoreApplication::sendEvent(this, &event); |