summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-03-09 14:32:05 (GMT)
committeraxis <qt-info@nokia.com>2010-03-18 07:53:43 (GMT)
commite483886bcfcf7252af9ac7cc89de15f912bf69da (patch)
treee2282912c00717b7632570f07a9b8cc02ba77a96
parent05c20cbf719746f295ac4c3ebb484ea6c3555d70 (diff)
downloadQt-e483886bcfcf7252af9ac7cc89de15f912bf69da.zip
Qt-e483886bcfcf7252af9ac7cc89de15f912bf69da.tar.gz
Qt-e483886bcfcf7252af9ac7cc89de15f912bf69da.tar.bz2
Fixed a bug where a proxy widget received FocusIn over and over.
This also fixed the issue where an input panel would not be requested by the widget, because it thought it was being focused over and over, instead of focused, and then clicked (focus followed by click is default input panel popup behavior on Symbian). AutoTest: Included and passed RevBy: yoann RevBy: Jan-Arve
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp5
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget_p.h1
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp12
4 files changed, 19 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index a39ccfd..483eb62 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -1315,6 +1315,8 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
return;
}
+ d->proxyIsGivingFocus = true;
+
switch (event->reason()) {
case Qt::TabFocusReason: {
if (QWidget *focusChild = d->findFocusChild(0, true))
@@ -1328,10 +1330,11 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
default:
if (d->widget && d->widget->focusWidget()) {
d->widget->focusWidget()->setFocus(event->reason());
- return;
}
break;
}
+
+ d->proxyIsGivingFocus = false;
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsproxywidget_p.h b/src/gui/graphicsview/qgraphicsproxywidget_p.h
index 60eb058..8aed363 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget_p.h
+++ b/src/gui/graphicsview/qgraphicsproxywidget_p.h
@@ -118,6 +118,7 @@ public:
quint32 styleChangeMode : 2;
quint32 paletteChangeMode : 2;
quint32 focusFromWidgetToProxy : 1;
+ quint32 proxyIsGivingFocus : 1;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index b5ccb3e..cd943cd 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -6123,6 +6123,8 @@ void QWidget::setFocus(Qt::FocusReason reason)
previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
if (previousProxyFocus && previousProxyFocus->focusProxy())
previousProxyFocus = previousProxyFocus->focusProxy();
+ if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
+ return;
}
}
#endif
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 17311e2..23b3458 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3513,6 +3513,18 @@ void tst_QGraphicsProxyWidget::clickFocus()
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter));
QVERIFY(!proxy->hasFocus());
QVERIFY(!proxy->widget()->hasFocus());
+
+ // Multiple clicks should only result in one FocusIn.
+ proxy->widget()->setFocusPolicy(Qt::StrongFocus);
+ scene.setFocusItem(0);
+ QVERIFY(!proxy->hasFocus());
+ QVERIFY(!proxy->widget()->hasFocus());
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter));
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter));
+ QVERIFY(proxy->hasFocus());
+ QVERIFY(proxy->widget()->hasFocus());
+ QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1);
}
}