Beispiel #1
0
void MenuWindowManager::flickGestureEvent(QGestureEvent* event)
{
	if(m_systemMenuOpened) {
		return; // ignore gestures
	}

	if (m_penDownState != PenDownInMenu) {
		return;
	}

	if (!m_winArray.empty()) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
		QGesture* g = event->gesture((Qt::GestureType) SysMgrGestureFlick);
#else
        QGesture* g = event->gesture(FlickGesture::gestureType());
#endif
		Q_ASSERT(g != 0);
		FlickGesture* flick = static_cast<FlickGesture*>(g);

		Window* targetWin = m_winArray.first();
		QPointF pos = mapFromScene(event->mapToGraphicsScene(flick->hotSpot()));

		Event ev;
		ev.type = Event::PenFlick;
		ev.setMainFinger(true);
		ev.x = pos.x();
		ev.y = pos.y();
		ev.flickXVel = flick->velocity().x();
		ev.flickYVel = flick->velocity().y();
		ev.time = Time::curSysTimeMs();
		mapCoordToWindow(targetWin, ev.x, ev.y);
		WebAppMgrProxy::instance()->inputEvent(targetWin, &ev);
	}
}
bool DashboardWindowContainer::sceneEvent(QEvent* event)
{
	if (event->type() == QEvent::GestureOverride) {
		QGestureEvent* ge = static_cast<QGestureEvent*>(event);
		ge->accept();
		return true;
	}
	else if (event->type() == QEvent::Gesture) {
		QGesture* g = static_cast<QGestureEvent*>(event)->gesture(Qt::TapGesture);
		if (g) {
			QTapGesture* tap = static_cast<QTapGesture*>(g);
			if (tap->state() == Qt::GestureFinished) {
				handleTap(mapFromScene(tap->position()));
			}
			
			return true;
		}

		if(!m_isMenu) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
			g = static_cast<QGestureEvent*>(event)->gesture((Qt::GestureType) SysMgrGestureFlick);
#else
            g = static_cast<QGestureEvent*>(event)->gesture(FlickGesture::gestureType());
#endif
			if (g) {
				FlickGesture* flick = static_cast<FlickGesture*>(g);
				if (flick->state() == Qt::GestureFinished) {
					bool flick_delete = abs(flick->velocity().x()) > abs(flick->velocity().y());

					if (flick_delete) {
						if (DashboardWindow* w = m_draggedWindow.data()) {
							m_draggedWindow.clear();
							if (!w->persistent()) {
								m_seenFlick = true;
								triggerItemDelete(w);
							}
						}
					}
				}
				return true;
			}
		}
	} else if (event->type() == QEvent::TouchBegin) {
		return true;
	} else if (event->type() == QEvent::TouchUpdate) {
		return true;
	} else if (event->type() == QEvent::TouchEnd){
		return true;
	}

	return QGraphicsObject::sceneEvent(event);        
}
Beispiel #3
0
bool PageTabBar::sceneEvent(QEvent* event)
{
	if (event->type() == QEvent::GestureOverride) {
		QGestureEvent* ge = static_cast<QGestureEvent*>(event);
		ge->accept();
		return true;
	}
	else if (event->type() == QEvent::Gesture) {
		QGestureEvent* ge = static_cast<QGestureEvent*>(event);
		QGesture * g = 0;
//		QGesture* g = ge->gesture(Qt::TapGesture);
//		if (g) {
//			QTapGesture* tap = static_cast<QTapGesture*>(g);
//			if (tap->state() == Qt::GestureFinished) {
//				tapGestureEvent(tap);
//			}
//			return true;
//		}
//		g = ge->gesture(Qt::TapAndHoldGesture);
//		if (g) {
//			QTapAndHoldGesture* hold = static_cast<QTapAndHoldGesture*>(g);
//			if (hold->state() == Qt::GestureFinished) {
//				tapAndHoldGestureEvent(hold);
//			}
//			return true;
//		}
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
		g = ge->gesture((Qt::GestureType) SysMgrGestureFlick);
#else
        g = ge->gesture(FlickGesture::gestureType());
#endif
		if (g) {
			FlickGesture* flick = static_cast<FlickGesture*>(g);
			if (flick->state() == Qt::GestureFinished) {
				flickGesture(flick);
			}
			return true;
		}
	}
	return QGraphicsObject::sceneEvent(event);
}