コード例 #1
0
ファイル: UBBoardView.cpp プロジェクト: coachal/Sankore-3.1
bool
UBBoardView::event (QEvent * e)
{
  if (e->type () == QEvent::Gesture)
    {
      QGestureEvent *gestureEvent = dynamic_cast<QGestureEvent *> (e);
      if (gestureEvent)
        {
          QSwipeGesture* swipe = dynamic_cast<QSwipeGesture*> (gestureEvent->gesture (Qt::SwipeGesture));

          if (swipe)
            {
              if (swipe->horizontalDirection () == QSwipeGesture::Left)
                {
                  mController->previousScene ();
                  gestureEvent->setAccepted (swipe, true);
                }

              if (swipe->horizontalDirection () == QSwipeGesture::Right)
                {
                  mController->nextScene ();
                  gestureEvent->setAccepted (swipe, true);
                }
            }
        }
    }

  return QGraphicsView::event (e);
}
コード例 #2
0
const SoEvent* GesturesDevice::translateEvent(QEvent* event)
{
    if (event->type() == QEvent::Gesture
            || event->type() == QEvent::GestureOverride) {
        QGestureEvent* gevent = static_cast<QGestureEvent*>(event);

        QPinchGesture* zg = static_cast<QPinchGesture*>(gevent->gesture(Qt::PinchGesture));
        if(zg){
            gevent->setAccepted(Qt::PinchGesture,true);//prefer it over pan
            return new SoGesturePinchEvent(zg,this->widget);
        }

        QPanGesture* pg = static_cast<QPanGesture*>(gevent->gesture(Qt::PanGesture));
        if(pg){
            gevent->setAccepted(Qt::PanGesture,true);
            return new SoGesturePanEvent(pg,this->widget);
        }

        QSwipeGesture* sg = static_cast<QSwipeGesture*>(gevent->gesture(Qt::SwipeGesture));
        if(sg){
            gevent->setAccepted(Qt::SwipeGesture,true);
            return new SoGesturePanEvent(pg,this->widget);
        }
    }
    return 0;
}
コード例 #3
0
static PyObject *meth_QGestureEvent_setAccepted(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        bool a0;
        QGestureEvent *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bb", &sipSelf, sipType_QGestureEvent, &sipCpp, &a0))
        {
            sipCpp->setAccepted(a0);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        QGesture* a0;
        bool a1;
        QGestureEvent *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ8b", &sipSelf, sipType_QGestureEvent, &sipCpp, sipType_QGesture, &a0, &a1))
        {
            sipCpp->setAccepted(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        Qt::GestureType a0;
        bool a1;
        QGestureEvent *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BEb", &sipSelf, sipType_QGestureEvent, &sipCpp, sipType_Qt_GestureType, &a0, &a1))
        {
            sipCpp->setAccepted(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QGestureEvent, sipName_setAccepted, doc_QGestureEvent_setAccepted);

    return NULL;
}
コード例 #4
0
ファイル: slidingstackedwidget.cpp プロジェクト: akahan/qutim
bool SlidingStackedWidget::event(QEvent *event)
{
	if (event->type() == QEvent::TouchBegin) {
		event->accept();
		return true;
	}

	if (event->type() == QEvent::Gesture) {
		QGestureEvent *ge = static_cast<QGestureEvent*>(event);

		if (QGesture *gesture = ge->gesture(fingerSwipeGestureType)) {
			FingerSwipeGesture *swipe = static_cast<FingerSwipeGesture*>(gesture);
			if (swipe->state() == Qt::GestureFinished) {
				if (swipe->isLeftToRight()) {
					emit fingerGesture(LeftToRight);
				}
				else if (swipe->isRightToLeft()) {
					emit fingerGesture(RightToLeft);
				}
				else if (swipe->isBottomToTop()) {
					emit fingerGesture(BottomToTop);
				}
				else if (swipe->isTopToBottom()) {
					emit fingerGesture(TopToBottom);
				}
			}

			ge->setAccepted(gesture, true);
			return true;
		}
	}

	//for debug
	if (event->type() == QEvent::KeyPress) {
		QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
		if (keyEvent->modifiers() == Qt::ControlModifier) {
			if (keyEvent->key() == Qt::Key_Left) {
				emit fingerGesture(LeftToRight);
			} else if (keyEvent->key() == Qt::Key_Right)
				emit fingerGesture(RightToLeft);
		}
	}

	return QStackedWidget::event(event);
}