| 204 | } |
| 205 | |
| 206 | bool DrawWidget::event(QEvent * event) |
| 207 | { |
| 208 | #if !defined(OMIM_OS_LINUX) |
| 209 | return QOpenGLWidget::event(event); |
| 210 | #else |
| 211 | // TouchScreen |
| 212 | if (auto dfTouchEventType = qtTouchEventTypeToDfTouchEventType(event->type()); |
| 213 | dfTouchEventType != df::TouchEvent::TOUCH_NONE) |
| 214 | { |
| 215 | event->accept(); |
| 216 | QTouchEvent const * qtTouchEvent = dynamic_cast<QTouchEvent const *>(event); |
| 217 | df::TouchEvent dfTouchEvent; |
| 218 | // The SetTouchType hast to be set even if `qtTouchEvent->points()` is empty |
| 219 | // which theoretically can happen in case of `QEvent::TouchCancel` |
| 220 | dfTouchEvent.SetTouchType(dfTouchEventType); |
| 221 | |
| 222 | int64_t i = 0; |
| 223 | for (auto it = qtTouchEvent->points().cbegin(); |
| 224 | it != qtTouchEvent->points().cend() && i < 2; /* For now drape_frontend can only handle max 2 touches */ |
| 225 | ++it, ++i) |
| 226 | { |
| 227 | df::Touch touch; |
| 228 | touch.m_id = i; |
| 229 | touch.m_location = m2::PointD(L2D(it->position().x()), L2D(it->position().y())); |
| 230 | if (i == 0) |
| 231 | dfTouchEvent.SetFirstTouch(touch); |
| 232 | else |
| 233 | dfTouchEvent.SetSecondTouch(touch); |
| 234 | } |
| 235 | m_framework.TouchEvent(dfTouchEvent); |
| 236 | return true; |
| 237 | } |
| 238 | // TouchPad |
| 239 | else if (event->type() == QEvent::NativeGesture) |
| 240 | { |
| 241 | event->accept(); |
| 242 | auto qNativeGestureEvent = dynamic_cast<QNativeGestureEvent *>(event); |
| 243 | if (qNativeGestureEvent->gestureType() == Qt::ZoomNativeGesture) |
| 244 | { |
| 245 | QPointF const pos = qNativeGestureEvent->position(); |
| 246 | double const factor = qNativeGestureEvent->value(); |
| 247 | m_framework.Scale(exp(factor), m2::PointD(L2D(pos.x()), L2D(pos.y())), false); |
| 248 | return true; |
| 249 | } |
| 250 | } |
| 251 | // Everything else |
| 252 | return QOpenGLWidget::event(event); |
| 253 | #endif |
| 254 | } |
| 255 | |
| 256 | void DrawWidget::mousePressEvent(QMouseEvent * e) |
| 257 | { |
nothing calls this directly
no test coverage detected