MCPcopy Create free account
hub / github.com/IENT/YUView / event

Method event

YUViewLib/src/ui/views/MoveAndZoomableView.cpp:459–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459bool MoveAndZoomableView::event(QEvent *event)
460{
461 // IMPORTANT:
462 // We are not using the QPanGesture as this uses two fingers. This is not documented in the Qt
463 // documentation.
464
465 bool isTouchScreenEvent = false;
466 if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate ||
467 event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel)
468 {
469 auto touchEvent = static_cast<QTouchEvent *>(event);
470 auto device = touchEvent->device();
471
472#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
473 isTouchScreenEvent = (device->type() == QInputDevice::DeviceType::TouchScreen);
474#else
475 isTouchScreenEvent = (device->type() == QTouchDevice::TouchScreen);
476#endif
477 }
478
479 if (event->type() == QEvent::Gesture)
480 {
481 auto gestureEvent = static_cast<QGestureEvent *>(event);
482
483 if (QGesture *swipeGesture = gestureEvent->gesture(Qt::SwipeGesture))
484 {
485 auto swipe = static_cast<QSwipeGesture *>(swipeGesture);
486 DEBUG_VIEW("MoveAndZoomableView::event swipe gesture");
487
488 if (swipe->state() == Qt::GestureStarted)
489 // The gesture was just started. This will prevent (generated) mouse events from being
490 // interpreted.
491 this->viewAction = ViewAction::PINCHING;
492
493 if (swipe->state() == Qt::GestureFinished)
494 {
495 if (swipe->horizontalDirection() == QSwipeGesture::NoDirection &&
496 swipe->verticalDirection() == QSwipeGesture::Up)
497 this->onSwipeUp();
498 else if (swipe->horizontalDirection() == QSwipeGesture::NoDirection &&
499 swipe->verticalDirection() == QSwipeGesture::Down)
500 this->onSwipeDown();
501 else if (swipe->horizontalDirection() == QSwipeGesture::Left &&
502 swipe->verticalDirection() == QSwipeGesture::NoDirection)
503 this->onSwipeLeft();
504 else if (swipe->horizontalDirection() == QSwipeGesture::Right &&
505 swipe->verticalDirection() == QSwipeGesture::NoDirection)
506 this->onSwipeRight();
507 else
508 {
509 // The swipe was both horizontal and vertical. What is the dominating direction?
510 double a = swipe->swipeAngle();
511 if (a < 45 || a > 315)
512 this->onSwipeRight();
513 else if (a >= 45 && a < 135)
514 this->onSwipeUp();
515 else if (a >= 135 && a < 225)
516 this->onSwipeLeft();

Callers

nothing calls this directly

Calls 9

onSwipeUpMethod · 0.95
onSwipeDownMethod · 0.95
onSwipeLeftMethod · 0.95
onSwipeRightMethod · 0.95
updateMethod · 0.95
setMoveOffsetMethod · 0.95
stateMethod · 0.80
posMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected