Add touchpoint feedback to regular_widgets tablet manual test

We need to ensure that simultaneous touch and tablet input is possible.

Change-Id: I0c0d06e382b6b89e11ed06c1e4ad0db63b3b7c82
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Shawn Rutledge 2017-05-29 10:37:33 +02:00
parent a75d42eebe
commit 84f006b671

View File

@ -79,6 +79,8 @@ protected:
void tabletEvent(QTabletEvent *);
bool event(QEvent *event);
void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
@ -89,6 +91,7 @@ private:
bool m_lastIsTabletMove;
Qt::MouseButton m_lastButton;
QVector<TabletPoint> m_points;
QVector<QPointF> m_touchPoints;
int m_tabletMoveCount;
int m_paintEventCount;
};
@ -100,6 +103,7 @@ EventReportWidget::EventReportWidget()
, m_tabletMoveCount(0)
, m_paintEventCount(0)
{
setAttribute(Qt::WA_AcceptTouchEvents);
startTimer(1000);
}
@ -151,6 +155,11 @@ void EventReportWidget::paintEvent(QPaintEvent *)
}
}
}
p.setPen(Qt::blue);
for (QPointF t : m_touchPoints) {
p.drawLine(t.x() - 40, t.y(), t.x() + 40, t.y());
p.drawLine(t.x(), t.y() - 40, t.x(), t.y() + 40);
}
++m_paintEventCount;
}
@ -193,6 +202,27 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
m_lastIsTabletMove = isMove;
}
bool EventReportWidget::event(QEvent *event)
{
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
event->accept();
m_touchPoints.clear();
for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints())
m_touchPoints.append(p.pos());
update();
break;
case QEvent::TouchEnd:
m_touchPoints.clear();
update();
break;
default:
return QWidget::event(event);
}
return true;
}
void EventReportWidget::outputMouseEvent(QMouseEvent *event)
{
if (event->type() == QEvent::MouseMove) {