Example #1
0
QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &s)
{
	dbg.nospace() << "\"TouchPoint\":"
			<< "{ \"id\":" << s.id()
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
			<< ", \"primary\":\"" << (s.isPrimary() ? "true" : "false") << "\""
#endif
			<< ", \"state\":" << touchStateToString(s.state())
			<< ", \"pos\":\"" << s.pos() << "\""
			<< ", \"pressure\":\"" << s.pressure() << "\""
			<< " }";
	return dbg.space();
}
PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point, State state)
    // The QTouchEvent::TouchPoint API states that ids will be >= 0.
    : m_id(point.id())
    , m_state(state)
    , m_screenPos(point.screenPos().toPoint())
    , m_pos(point.pos().toPoint())
{
    // Qt reports touch point size as rectangles, but we will pretend it is an oval.
    QRect touchRect = point.rect().toAlignedRect();
    if (touchRect.isValid()) {
        m_radiusX = point.rect().width() / 2;
        m_radiusY = point.rect().height() / 2;
    } else {
        // http://www.w3.org/TR/2011/WD-touch-events-20110505: 1 if no value is known.
        m_radiusX = 1;
        m_radiusY = 1;
    }
    m_force = point.pressure();
    // FIXME: Support m_rotationAngle if QTouchEvent at some point supports it.
}