diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-05-28 04:06:41 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-05-28 04:21:16 (GMT) |
commit | 0da153d47da2dcc59b33bc47ea949ceaf3189579 (patch) | |
tree | 45a4b4747085b6fd13fca31d78c2790bd3ef6ce5 | |
parent | 79a587d813c2df9c45fea7423e5e6c40e2d2b67b (diff) | |
download | Qt-0da153d47da2dcc59b33bc47ea949ceaf3189579.zip Qt-0da153d47da2dcc59b33bc47ea949ceaf3189579.tar.gz Qt-0da153d47da2dcc59b33bc47ea949ceaf3189579.tar.bz2 |
Active window focus gain should not open virtual keypad
Task-number:
Reviewed-by: Martin Jones
5 files changed, 27 insertions, 6 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 3eed8d6..142920c 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,9 @@ ============================================================================= The changes below are pre Qt 4.7.0 RC +TextInput and TextEdit: + - showInputPanelOnFocus property added + - openSoftwareInputPanel() and closeSoftwareInputPanel() functions added Flickable: - overShoot is replaced by boundsBehavior enumeration - flickingHorizontally and flickingVertically properties added diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 167db77..9ccb8d2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1335,7 +1335,7 @@ void QDeclarativeTextEdit::setShowInputPanelOnFocus(bool showOnFocus) void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextEdit); - if (d->showInputPanelOnFocus && !isReadOnly()) { + if (d->showInputPanelOnFocus && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { openSoftwareInputPanel(); } QDeclarativePaintedItem::focusInEvent(event); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 18e3595..9c70ea9 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1282,7 +1282,7 @@ void QDeclarativeTextInput::setShowInputPanelOnFocus(bool showOnFocus) void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) { Q_D(const QDeclarativeTextInput); - if (d->showInputPanelOnFocus && !isReadOnly()) { + if (d->showInputPanelOnFocus && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) { openSoftwareInputPanel(); } QDeclarativePaintedItem::focusInEvent(event); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 0df28d0..d3e3c3a 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -915,9 +915,18 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() edit.setFocus(false); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); + ic.closeInputPanelReceived = false; + + // active window focus reason should not cause input panel to open + QGraphicsObject * editObject = qobject_cast<QGraphicsObject*>(&edit); + editObject->setFocus(Qt::ActiveWindowFocusReason); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); + + // and input panel should not open if focus has already been set edit.setFocus(true); - QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, true); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); edit.setShowInputPanelOnFocus(true); QCOMPARE(inputPanelonFocusSpy.count(),2); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 155223d..c01cfa5 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -819,9 +819,18 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() input.setFocus(false); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); + ic.closeInputPanelReceived = false; + + // active window focus reason should not cause input panel to open + QGraphicsObject * inputObject = qobject_cast<QGraphicsObject*>(&input); + inputObject->setFocus(Qt::ActiveWindowFocusReason); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); + + // and input panel should not open if focus has already been set input.setFocus(true); - QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, true); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); input.setShowInputPanelOnFocus(true); QCOMPARE(inputPanelonFocusSpy.count(),2); |