summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andrhans@cisco.com>2012-04-12 05:46:19 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-12 05:52:21 (GMT)
commitb8dd42f52e70ff1c63ec21d1fe0830f34a9e1094 (patch)
treed7535509ee4e925ba15af1edefd05aa47d6be8ff /tests
parentc2dd028bc55ccd53e88da91f9a752743aef652e2 (diff)
downloadQt-b8dd42f52e70ff1c63ec21d1fe0830f34a9e1094.zip
Qt-b8dd42f52e70ff1c63ec21d1fe0830f34a9e1094.tar.gz
Qt-b8dd42f52e70ff1c63ec21d1fe0830f34a9e1094.tar.bz2
Fixes a regression; missing cursor blink when input mask is set.
I can't say for sure why q*linecontrol passes an empty rect to the updateNeeded() signal when an input mask is set; presumably the empty rect at some point has meant "full update", but there are a few problems with this. Surely a full update is wrong, even if the semantics have been lost in translation somewhere (likely the qlinecontrol refactoring). This fix ensures that empty rects from updateNeeded() are interpreted as a request to update the whole widget. A further improvement would be to ensure the line control doesn't request a full update when an input mask is set. The cursor is usually wider when a mask is set but because of QLineEdit::paintEvent()'s implementation, there is currently a mismatch between the cursor width as seen by q*linecontrol and what is actually drawn, which causes rendering artifacts if updateNeeded() sends the cursorRect(). Since QLineEdit and Q*LineControl aren't actively developed, it's best to keep this fix minimal, although the performance cost of updating the whole line edit when an input mask is set is unfortunate. cherry-picked from qt5/qtbase a9cda515177db1615f8d47becf2aa781f26955ae Task-number: QTBUG-7174 Change-Id: Ie51e015d760915e07b0220b770f04fc958d93a12 Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 9000fd0..ec57ce2 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -282,6 +282,7 @@ private slots:
void taskQTBUG_7395_readOnlyShortcut();
void QTBUG697_paletteCurrentColorGroup();
void QTBUG13520_textNotVisible();
+ void QTBUG7174_inputMaskCursorBlink();
#ifdef QT3_SUPPORT
void validateAndSet_data();
@@ -3823,6 +3824,30 @@ void tst_QLineEdit::QTBUG13520_textNotVisible()
}
+class UpdateRegionLineEdit : public QLineEdit
+{
+public:
+ QRegion updateRegion;
+protected:
+ void paintEvent(QPaintEvent *event)
+ {
+ updateRegion = event->region();
+ }
+};
+
+void tst_QLineEdit::QTBUG7174_inputMaskCursorBlink()
+{
+ UpdateRegionLineEdit edit;
+ edit.setInputMask(QLatin1String("AAAA"));
+ edit.setFocus();
+ edit.setText(QLatin1String("AAAA"));
+ edit.show();
+ QRect cursorRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect();
+ QTest::qWaitForWindowShown(&edit);
+ edit.updateRegion = QRegion();
+ QTest::qWait(QApplication::cursorFlashTime());
+ QVERIFY(edit.updateRegion.contains(cursorRect));
+}
void tst_QLineEdit::bidiVisualMovement_data()
{