From eb8c7d19c98d547f89caa1b5866fd2b5e43b32bf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 5 Aug 2010 14:36:57 +1000 Subject: Make sure onFocusChanged is correctly emitted for items in a FocusScope. Task-number: QTBUG-12649 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 13 +---- src/gui/graphicsview/qgraphicsitem.cpp | 5 ++ .../tst_qdeclarativefocusscope.cpp | 56 ++++++++++++++++++++++ 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 50998eb..5b74129 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2406,18 +2406,7 @@ void QDeclarativeItemPrivate::focusChanged(bool flag) Q_Q(QDeclarativeItem); if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent) emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange() - - bool inScope = false; - QGraphicsItem *p = parent; - while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - inScope = true; - break; - } - p = p->parentItem(); - } - if (!inScope) - emit q->focusChanged(flag); + emit q->focusChanged(flag); } /*! \internal */ diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1626d83..ff3dc1f 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3259,8 +3259,12 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim QGraphicsItem *p = parent; while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem; p->d_ptr->focusScopeItem = q_ptr; if (!p->focusItem() && !focusFromShow) { + if (oldFocusScopeItem) + oldFocusScopeItem->d_ptr->focusScopeItemChange(false); + focusScopeItemChange(true); // If you call setFocus on a child of a focus scope that // doesn't currently have a focus item, then stop. return; @@ -5595,6 +5599,7 @@ void QGraphicsItemPrivate::subFocusItemChange() */ void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem) { + Q_UNUSED(isSubFocusItem); } /*! diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index b0c9c03..b138f61 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -69,6 +69,7 @@ private slots: void textEdit(); void forceFocus(); void noParentFocus(); + void signalEmission(); }; /* @@ -344,6 +345,61 @@ void tst_qdeclarativefocusscope::noParentFocus() delete view; } +void tst_qdeclarativefocusscope::signalEmission() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/signalEmission.qml")); + + QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarativeRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + QVERIFY(item4 != 0); + + view->show(); + qApp->setActiveWindow(view); + qApp->processEvents(); + +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(view); +#endif + + QVariant blue(QColor("blue")); + QVariant red(QColor("red")); + + QVERIFY(view->hasFocus()); + QVERIFY(view->scene()->hasFocus()); + item1->setFocus(true); + QCOMPARE(item1->property("color"), red); + QCOMPARE(item2->property("color"), blue); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item2->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item3->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), red); + QCOMPARE(item4->property("color"), blue); + + item4->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), red); + + delete view; +} + QTEST_MAIN(tst_qdeclarativefocusscope) #include "tst_qdeclarativefocusscope.moc" -- cgit v0.12 From 4ad82cec67ce40dd167be214a2a4dcdcf6236d9d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 5 Aug 2010 14:39:52 +1000 Subject: Add missing test file. --- .../qdeclarativefocusscope/data/signalEmission.qml | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml b/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml new file mode 100644 index 0000000..07601c7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml @@ -0,0 +1,33 @@ +import Qt 4.7 + +Rectangle { + width: 200 + height: 200 + + FocusScope { + focus: true + Rectangle { + objectName: "item1" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item2" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } + + FocusScope { + Rectangle { + objectName: "item3" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item4" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } +} -- cgit v0.12 From 4692a507dcdfbc830a0885016b6bd0bab4480bad Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 4 Aug 2010 11:42:48 +1000 Subject: Increase maximum heap size of QML Viewer Task-number: QTBUG-12029 Reviewed-by: Martin Jones --- tools/qml/qml.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index efb82d1..d794005 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -35,7 +35,7 @@ maemo5 { symbian { TARGET.UID3 = 0x20021317 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + TARGET.EPOCHEAPSIZE = 0x20000 0x4000000 TARGET.CAPABILITY = NetworkServices ReadUserData !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { LIBS += -lsensrvclient -lsensrvutil -- cgit v0.12 From 89e723153b15af5d3acbeb859d4f35bf52f8e250 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 5 Aug 2010 14:03:57 +1000 Subject: Increase drag distance on Symbian to improve finger usability on capacitive screens Task-number: QTBUG-12594 Reviewed-by: Martin Jones --- src/gui/kernel/qapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 3303800..e164baf 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -474,7 +474,7 @@ int qt_antialiasing_threshold = -1; static int drag_time = 500; #ifdef Q_OS_SYMBIAN // The screens are a bit too small to for your thumb when using only 4 pixels drag distance. -static int drag_distance = 8; +static int drag_distance = 12; #else static int drag_distance = 4; #endif -- cgit v0.12 From 563b5891e2f918f901ffefe29872dfac1b9a60e7 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 5 Aug 2010 14:10:43 +1000 Subject: Re-enable script program caching on Symbian (used to be disabled due to crash problems that no longer occur). Task-number: QTBUG-12599 Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeexpression.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 585fb69..6fc4df0 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -143,16 +143,12 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *ex } else { -#if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work? if (!dd->cachedPrograms.at(progIdx)) { dd->cachedPrograms[progIdx] = new QScriptProgram(expression, url, line); } expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx), &expressionContext); -#else - expressionFunction = evalInObjectScope(ctxt, me, expression, &expressionContext); -#endif expressionFunctionMode = ExplicitContext; expressionFunctionValid = true; -- cgit v0.12