summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-03-10 06:38:20 (GMT)
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-03-11 04:44:48 (GMT)
commit27f0c5054e5326bf16f40436ba4e72927ea89cc1 (patch)
treed0658e2ed1632db0561c3413b74240214a34537e
parent68415b0bcc3e531dc16516aa6788aeef8bced6f2 (diff)
downloadQt-27f0c5054e5326bf16f40436ba4e72927ea89cc1.zip
Qt-27f0c5054e5326bf16f40436ba4e72927ea89cc1.tar.gz
Qt-27f0c5054e5326bf16f40436ba4e72927ea89cc1.tar.bz2
Don't reveal TextInput text on refocus in PasswordEchoOnEdit mode.
In PasswordEchoOnEdit mode return the display text instead of the real text from inputMethodQuery() when not editing the password and clear old password if new input is received through an input method event. Change-Id: I7f24f510bf8e356e460900c3b9ff55ea16b32ab3 Task-number: QTBUG-17562 Reviewed-by: Joona Petrell
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp7
-rw-r--r--src/gui/widgets/qlinecontrol.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp10
3 files changed, 21 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 12d0c98..b4395e3 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -1374,7 +1374,10 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property)
case Qt::ImCursorPosition:
return QVariant(d->control->cursor());
case Qt::ImSurroundingText:
- return QVariant(text());
+ if (d->control->echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing())
+ return QVariant(displayText());
+ else
+ return QVariant(text());
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
@@ -1867,6 +1870,8 @@ void QDeclarativeTextInputPrivate::init()
#endif // QT_NO_CLIPBOARD
q->connect(control, SIGNAL(updateMicroFocus()),
q, SLOT(updateMicroFocus()));
+ q->connect(control, SIGNAL(displayTextChanged(QString)),
+ q, SLOT(updateRect()));
q->updateSize();
oldValidity = control->hasAcceptableInput();
lastSelectionStart = 0;
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index bffc2b5..5a281ad 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -414,10 +414,14 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
if (isGettingInput) {
// If any text is being input, remove selected text.
priorState = m_undoState;
+ if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing()) {
+ updatePasswordEchoEditing(true);
+ m_selstart = 0;
+ m_selend = m_text.length();
+ }
removeSelectedText();
}
-
int c = m_cursor; // cursor position after insertion of commit string
if (event->replacementStart() <= 0)
c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength());
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 796ac23..45f38a4 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -1829,13 +1829,23 @@ void tst_qdeclarativetextinput::echoMode()
QCOMPARE(input->inputMethodHints(), ref);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10);
QCOMPARE(input->text(), QLatin1String("a"));
QCOMPARE(input->displayText(), QLatin1String("a"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
input->setFocus(false);
QVERIFY(input->hasActiveFocus() == false);
QCOMPARE(input->displayText(), QLatin1String("Q"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
+ input->setFocus(true);
+ QInputMethodEvent inputEvent;
+ inputEvent.setCommitString(initial);
+ QApplication::sendEvent(canvas, &inputEvent);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), initial);
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
delete canvas;
}