diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-06 16:05:20 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-05-21 05:17:38 +0000 |
commit | 01d78ba86a631386a4d47b7c12d2a359da28f517 (patch) | |
tree | bc50b60ff60a7d4d10b4da141e2c518812e9c240 /tests/manual | |
parent | e227b8ecf686bb2ace31be62e683bd76591ad7b1 (diff) |
Android: generate QTabletEvents for stylus devices such as the S Pen
For example the Galaxy Note series of devices. This makes possible
drawing applications which handle stylus events differently from touch
or mouse. As on any other platform, if the application does not accept
the QTabletEvent, a QMouseEvent will be synthesized.
Also fix the tablet manual test to show larger circles on hidpi devices.
[ChangeLog][Android] stylus devices such as the S Pen generate
QTabletEvents
Task-number: QTBUG-38379
Change-Id: Ib594f453b8403cc06aa4e440a76f07afa3bac38c
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/qtabletevent/regular_widgets/main.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp index 5a83decfa2..c8353a40c0 100644 --- a/tests/manual/qtabletevent/regular_widgets/main.cpp +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -100,17 +100,19 @@ EventReportWidget::EventReportWidget() void EventReportWidget::paintEvent(QPaintEvent *) { QPainter p(this); + int lineSpacing = fontMetrics().lineSpacing(); + int halfLineSpacing = lineSpacing / 2; const QRectF geom = QRectF(QPoint(0, 0), size()); p.fillRect(geom, Qt::white); p.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1,1))); p.setPen(Qt::white); QPainterPath ellipse; - ellipse.addEllipse(0, 0, 50, 10); + ellipse.addEllipse(0, 0, halfLineSpacing * 5, halfLineSpacing); foreach (const TabletPoint &t, m_points) { if (geom.contains(t.pos)) { QPainterPath pp; - pp.addEllipse(t.pos, 8, 8); - QRectF pointBounds(t.pos.x() - 10, t.pos.y() - 10, 20, 20); + pp.addEllipse(t.pos, halfLineSpacing, halfLineSpacing); + QRectF pointBounds(t.pos.x() - halfLineSpacing, t.pos.y() - halfLineSpacing, lineSpacing, lineSpacing); switch (t.type) { case TabletButtonPress: p.fillPath(pp, Qt::darkGreen); @@ -133,7 +135,7 @@ void EventReportWidget::paintEvent(QPaintEvent *) p.drawPath(ellipse); p.restore(); } else { - p.drawEllipse(t.pos, t.pressure * 10.0, t.pressure * 10.0); + p.drawEllipse(t.pos, t.pressure * halfLineSpacing, t.pressure * halfLineSpacing); } p.setPen(Qt::white); } else { |