From e0c798ebb4fc56fa6be38f6ec3e82de147891260 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 16 Aug 2010 19:02:46 +1000 Subject: Repaint TextInput when password character changes in password mode Task-number: QTBUG-12838 Reviewed-by: Martin Jones --- .../graphicsitems/qdeclarativetextinput.cpp | 18 +++++++++++++----- .../tst_qdeclarativetextinput.cpp | 16 ++++++++++++++++ 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(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"); -- cgit v0.12 From 401ff4b290fcff0ef599af5986bc0b7816380575 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 18 Aug 2010 15:12:31 +1000 Subject: Add visible background element to declarative examples that didn't have any Invisible areas cause redraw artifacts with OpenVg paint engine. Task-number: Reviewed-by: Martin Jones --- examples/declarative/modelviews/package/view.qml | 3 +- examples/declarative/sqllocalstorage/hello.qml | 48 ++++++++++++---------- .../threading/threadedlistmodel/timedisplay.qml | 40 ++++++++++-------- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml index 152881a..26230ef 100644 --- a/examples/declarative/modelviews/package/view.qml +++ b/examples/declarative/modelviews/package/view.qml @@ -40,7 +40,8 @@ import Qt 4.7 -Item { +Rectangle { + color: "white" width: 400 height: 200 diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml index 421a74c..19b7378 100644 --- a/examples/declarative/sqllocalstorage/hello.qml +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -40,32 +40,38 @@ //![0] import Qt 4.7 -Text { - text: "?" +Rectangle { + color: "white" + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + function findGreetings() { + var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - function findGreetings() { - var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r } - text = r - } - ) - } + ) + } - Component.onCompleted: findGreetings() + Component.onCompleted: findGreetings() + } } //![0] diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml index 997f7a0..9fc3eb3 100644 --- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml +++ b/examples/declarative/threading/threadedlistmodel/timedisplay.qml @@ -41,31 +41,35 @@ // ![0] import Qt 4.7 -ListView { +Rectangle { + color: "white" width: 200 height: 300 - model: listModel - delegate: Component { - Text { text: time } - } + ListView { - ListModel { id: listModel } + model: listModel + delegate: Component { + Text { text: time } + } - WorkerScript { - id: worker - source: "dataloader.js" - } + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } } } } -- cgit v0.12 From a082d8ee8d27aaa190d28c2493b8f0326e2c9724 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 18 Aug 2010 15:22:36 +1000 Subject: Fix previous commit Task-number: Reviewed-by: Trust me --- examples/declarative/threading/threadedlistmodel/timedisplay.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml index 9fc3eb3..d807955 100644 --- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml +++ b/examples/declarative/threading/threadedlistmodel/timedisplay.qml @@ -47,7 +47,7 @@ Rectangle { height: 300 ListView { - + anchors.fill: parent model: listModel delegate: Component { Text { text: time } -- cgit v0.12