summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp16
2 files changed, 29 insertions, 5 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index bd8d404..b4f36f4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -277,8 +277,10 @@ void QDeclarativeTextInput::setSelectionColor(const QColor &color)
QPalette p = d->control->palette();
p.setColor(QPalette::Highlight, d->selectionColor);
d->control->setPalette(p);
- clearCache();
- update();
+ if (d->control->hasSelectedText()) {
+ clearCache();
+ update();
+ }
emit selectionColorChanged(color);
}
@@ -303,8 +305,10 @@ void QDeclarativeTextInput::setSelectedTextColor(const QColor &color)
QPalette p = d->control->palette();
p.setColor(QPalette::HighlightedText, d->selectedTextColor);
d->control->setPalette(p);
- clearCache();
- update();
+ if (d->control->hasSelectedText()) {
+ clearCache();
+ update();
+ }
emit selectedTextColorChanged(color);
}
@@ -1233,8 +1237,12 @@ void QDeclarativeTextInput::setPasswordCharacter(const QString &str)
Q_D(QDeclarativeTextInput);
if(str.length() < 1)
return;
- emit passwordCharacterChanged();
d->control->setPasswordCharacter(str.constData()[0]);
+ EchoMode echoMode_ = echoMode();
+ if (echoMode_ == Password || echoMode_ == PasswordEchoOnEdit) {
+ updateSize();
+ }
+ emit passwordCharacterChanged();
}
/*!
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index ca9009d..98a6012 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -98,6 +98,7 @@ private slots:
void validators();
void inputMethods();
+ void passwordCharacter();
void cursorDelegate();
void navigation();
void copyAndPaste();
@@ -768,6 +769,21 @@ void tst_qdeclarativetextinput::copyAndPaste() {
#endif
}
+void tst_qdeclarativetextinput::passwordCharacter()
+{
+ QString componentStr = "import Qt 4.7\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
+ QDeclarativeComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->setPasswordCharacter("X");
+ QSize contentsSize = textInput->contentsSize();
+ textInput->setPasswordCharacter(".");
+ // QTBUG-12383 content is updated and redrawn
+ QVERIFY(contentsSize != textInput->contentsSize());
+}
+
void tst_qdeclarativetextinput::cursorDelegate()
{
QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml");