summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-08-06 03:39:10 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-08 11:12:45 (GMT)
commitc73548ccd2946c502fad3128a7c8da71a9db7ed6 (patch)
treef18d9e5b548c67b073bafeae4560b8976b621d62
parent7824b7757516fbf3769ba1af4367241076b9628e (diff)
downloadQt-c73548ccd2946c502fad3128a7c8da71a9db7ed6.zip
Qt-c73548ccd2946c502fad3128a7c8da71a9db7ed6.tar.gz
Qt-c73548ccd2946c502fad3128a7c8da71a9db7ed6.tar.bz2
Top-level QML item should not have special focus handling.
It's the scene itself that acts as a focus scope, not the top-level item. Task-number: QTBUG-12682 Reviewed-by: Aaron Kennedy (cherry picked from commit 94b1c07c31ab84d30b198cb23291a48f98164827)
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp11
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp2
2 files changed, 5 insertions, 8 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 2c295cd..06862f1 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -3142,8 +3142,7 @@ bool QDeclarativeItem::hasActiveFocus() const
{
Q_D(const QDeclarativeItem);
return focusItem() == this ||
- (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) ||
- (!parentItem() && focusItem() != 0);
+ (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0);
}
/*!
@@ -3163,10 +3162,8 @@ bool QDeclarativeItem::hasActiveFocus() const
}
\endqml
- For the purposes of this property, the top level item in the scene
- is assumed to act like a focus scope, and to always have active focus
- when the scene has focus. On a practical level, that means the following
- QML will give active focus to \c input on startup.
+ For the purposes of this property, the scene as a whole is assumed to act like a focus scope.
+ On a practical level, that means the following QML will give active focus to \c input on startup.
\qml
Rectangle {
@@ -3192,7 +3189,7 @@ bool QDeclarativeItem::hasFocus() const
p = p->parentItem();
}
- return hasActiveFocus() ? true : (!QGraphicsItem::parentItem() ? true : false);
+ return hasActiveFocus();
}
/*! \internal */
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
index b0c9c03..84aff05 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -335,7 +335,7 @@ void tst_qdeclarativefocusscope::noParentFocus()
view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml"));
QVERIFY(view->rootObject());
- QVERIFY(view->rootObject()->property("focus1") == true);
+ QVERIFY(view->rootObject()->property("focus1") == false);
QVERIFY(view->rootObject()->property("focus2") == false);
QVERIFY(view->rootObject()->property("focus3") == true);
QVERIFY(view->rootObject()->property("focus4") == true);