diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2012-12-03 07:03:02 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-05 04:09:00 (GMT) |
commit | a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6 (patch) | |
tree | 85020b7051d0985c475933cfd35d5244484ab692 /src/gui/graphicsview | |
parent | c74b83d9baca9210588f7ee107e10f2dffffdc73 (diff) | |
download | Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.zip Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.tar.gz Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.tar.bz2 |
Clear focus of GraphicsItem focus scopes and their children.
A focus scope has effective focus if one of its children is the focus item,
clearFocus() should remove effective focus from an item and its children
not just from the focus item.
Task-number: QTBUG-28328
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
(cherry picked from commit ab97a44b6ae5cc826460f3704669383afd398594)
Change-Id: Ib6f43b40091cb1bb1a0d5b8b9ac71e44f35b037b
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f7075e9..b4b302a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3349,6 +3349,12 @@ void QGraphicsItem::clearFocus() */ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) { + QGraphicsItem *subFocusItem = q_ptr; + if (flags & QGraphicsItem::ItemIsFocusScope) { + while (subFocusItem->d_ptr->focusScopeItem) + subFocusItem = subFocusItem->d_ptr->focusScopeItem; + } + if (giveFocusToParent) { // Pass focus to the closest parent focus scope if (!inDestructor) { @@ -3357,10 +3363,10 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) if (p->flags() & QGraphicsItem::ItemIsFocusScope) { if (p->d_ptr->focusScopeItem == q_ptr) { p->d_ptr->focusScopeItem = 0; - if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere + if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere focusScopeItemChange(false); } - if (q_ptr->hasFocus()) + if (subFocusItem->hasFocus()) p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, /* focusFromHide = */ false); return; @@ -3370,7 +3376,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) } } - if (q_ptr->hasFocus()) { + if (subFocusItem->hasFocus()) { // Invisible items with focus must explicitly clear subfocus. clearSubFocus(q_ptr); |