summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-09-08 15:58:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@digia.com>2014-09-23 15:59:38 +0200
commit710530bc553ade8c4b8b6be1872f56bdc86b5321 (patch)
treed27b90c6292fcf9fd69f9a194da2694cb6ae4c04 /tests
parenta2b453502c657dcc4e6926e4cdfec9d143bdb90c (diff)
Fix too fast zooming in QTextEdit with smooth scrolling events
Do not zoom 1pt on every single wheel-event, but instead scale the zoom with the size of the angle delta. Change-Id: Idbe17356c7845ebd0039f655d3e611e71c6f0dd6 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index fbd8b46466..ea27405fb3 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -211,6 +211,10 @@ private slots:
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent();
+#endif
+
private:
void createSelection();
int blockCount() const;
@@ -2564,5 +2568,39 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
}
#endif
+#ifndef QT_NO_WHEELEVENT
+
+class TextEdit : public QTextEdit
+{
+public:
+ TextEdit(QWidget *parent = 0)
+ : QTextEdit(parent)
+ {}
+ void wheelEvent(QWheelEvent *event)
+ {
+ QTextEdit::wheelEvent(event);
+ }
+};
+
+void tst_QTextEdit::wheelEvent()
+{
+ TextEdit ed(0);
+ ed.setPlainText(QStringLiteral("Line\nLine\nLine\n"));
+ ed.setReadOnly(true);
+
+ float defaultFontSize = ed.font().pointSizeF();
+ QWheelEvent wheelUp(QPointF(), QPointF(), QPoint(), QPoint(0, 120), 120, Qt::Vertical, Qt::NoButton, Qt::ControlModifier);
+ ed.wheelEvent(&wheelUp);
+
+ QCOMPARE(defaultFontSize + 1, ed.font().pointSizeF());
+
+ QWheelEvent wheelHalfDown(QPointF(), QPointF(), QPoint(), QPoint(0, -60), -60, Qt::Vertical, Qt::NoButton, Qt::ControlModifier);
+ ed.wheelEvent(&wheelHalfDown);
+
+ QCOMPARE(defaultFontSize + 0.5, ed.font().pointSizeF());
+}
+
+#endif
+
QTEST_MAIN(tst_QTextEdit)
#include "tst_qtextedit.moc"