Changeset View
Changeset View
Standalone View
Standalone View
kstars/skymapevents.cpp
Context not available. | |||||
32 | #include "skycomponents/starcomponent.h" | 32 | #include "skycomponents/starcomponent.h" | ||
---|---|---|---|---|---|
33 | #include "widgets/infoboxwidget.h" | 33 | #include "widgets/infoboxwidget.h" | ||
34 | 34 | | |||
35 | #include <QGestureEvent> | ||||
35 | #include <QStatusBar> | 36 | #include <QStatusBar> | ||
36 | #include <QToolTip> | 37 | #include <QToolTip> | ||
37 | 38 | | |||
Context not available. | |||||
396 | void SkyMap::stopTracking() | 397 | void SkyMap::stopTracking() | ||
397 | { | 398 | { | ||
398 | KStars *kstars = KStars::Instance(); | 399 | KStars *kstars = KStars::Instance(); | ||
400 | | ||||
399 | emit positionChanged(focus()); | 401 | emit positionChanged(focus()); | ||
400 | if (kstars && Options::isTracking()) | 402 | if (kstars && Options::isTracking()) | ||
401 | kstars->slotTrack(); | 403 | kstars->slotTrack(); | ||
402 | } | 404 | } | ||
403 | 405 | | |||
406 | bool SkyMap::event(QEvent *event) | ||||
407 | { | ||||
408 | #if !defined(KSTARS_LITE) | ||||
409 | if (event->type() == QEvent::TouchBegin) | ||||
410 | { | ||||
411 | m_touchMode = true; | ||||
412 | m_pinchScale = -1; | ||||
413 | } | ||||
414 | | ||||
415 | if (event->type() == QEvent::Gesture) | ||||
416 | { | ||||
417 | QGestureEvent* gestureEvent = static_cast<QGestureEvent*>(event); | ||||
418 | | ||||
419 | if (QPinchGesture *pinch = static_cast<QPinchGesture*>(gestureEvent->gesture(Qt::PinchGesture))) | ||||
420 | { | ||||
421 | QPinchGesture::ChangeFlags changeFlags = pinch->changeFlags(); | ||||
422 | | ||||
423 | m_pinchMode = true; | ||||
424 | if (changeFlags & QPinchGesture::ScaleFactorChanged) | ||||
425 | { | ||||
426 | if (m_pinchScale == -1) | ||||
427 | { | ||||
428 | m_pinchScale = pinch->totalScaleFactor(); | ||||
429 | return true; | ||||
430 | } | ||||
431 | if (pinch->totalScaleFactor()-m_pinchScale > 0.1) | ||||
432 | { | ||||
433 | m_pinchScale = pinch->totalScaleFactor(); | ||||
434 | zoomInOrMagStep(0); | ||||
435 | return true; | ||||
436 | } | ||||
437 | if (pinch->totalScaleFactor()-m_pinchScale < -0.1) | ||||
438 | { | ||||
439 | m_pinchScale = pinch->totalScaleFactor(); | ||||
440 | zoomOutOrMagStep(0); | ||||
441 | return true; | ||||
442 | } | ||||
443 | } | ||||
444 | } | ||||
445 | if (QTapAndHoldGesture *tapAndHold = static_cast<QTapAndHoldGesture*>(gestureEvent->gesture(Qt::TapAndHoldGesture))) | ||||
446 | { | ||||
447 | m_tapAndHoldMode = true; | ||||
448 | if (tapAndHold->state() == Qt::GestureFinished) | ||||
449 | { | ||||
450 | if (clickedObject()) | ||||
451 | { | ||||
452 | clickedObject()->showPopupMenu(pmenu, tapAndHold->position().toPoint()); | ||||
453 | } | ||||
454 | else | ||||
455 | { | ||||
456 | pmenu->createEmptyMenu(clickedPoint()); | ||||
457 | pmenu->popup(tapAndHold->position().toPoint()); | ||||
458 | } | ||||
459 | m_touchMode = false; | ||||
460 | m_pinchMode = false; | ||||
461 | m_tapAndHoldMode = false; | ||||
462 | } | ||||
463 | } | ||||
464 | return true; | ||||
465 | } | ||||
466 | #endif | ||||
467 | return QGraphicsView::event(event); | ||||
468 | } | ||||
469 | | ||||
404 | void SkyMap::keyReleaseEvent(QKeyEvent *e) | 470 | void SkyMap::keyReleaseEvent(QKeyEvent *e) | ||
405 | { | 471 | { | ||
406 | switch (e->key()) | 472 | switch (e->key()) | ||
Context not available. | |||||
429 | 495 | | |||
430 | void SkyMap::mouseMoveEvent(QMouseEvent *e) | 496 | void SkyMap::mouseMoveEvent(QMouseEvent *e) | ||
431 | { | 497 | { | ||
498 | #if !defined(KSTARS_LITE) | ||||
499 | // Skip touch points | ||||
500 | if (m_pinchMode || m_tapAndHoldMode || (m_touchMode && e->globalX() == 0 && e->globalY() == 0)) | ||||
501 | return; | ||||
502 | #endif | ||||
503 | | ||||
432 | if (Options::useHoverLabel()) | 504 | if (Options::useHoverLabel()) | ||
433 | { | 505 | { | ||
434 | //Start a single-shot timer to monitor whether we are currently hovering. | 506 | //Start a single-shot timer to monitor whether we are currently hovering. | ||
Context not available. | |||||
552 | 624 | | |||
553 | void SkyMap::mouseReleaseEvent(QMouseEvent *) | 625 | void SkyMap::mouseReleaseEvent(QMouseEvent *) | ||
554 | { | 626 | { | ||
627 | #if !defined(KSTARS_LITE) | ||||
628 | if (m_touchMode) | ||||
629 | { | ||||
630 | m_touchMode = false; | ||||
631 | m_pinchMode = false; | ||||
632 | m_tapAndHoldMode = false; | ||||
633 | } | ||||
634 | #endif | ||||
635 | | ||||
555 | if (ZoomRect.isValid()) | 636 | if (ZoomRect.isValid()) | ||
556 | { | 637 | { | ||
557 | stopTracking(); | 638 | stopTracking(); | ||
Context not available. |