示例#1
0
void GraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    QGraphicsWebView::mouseReleaseEvent(event);
    pressTimer.stop();
    parent->setKeepMouseGrab(false);
    ungrabMouse();
}
示例#2
0
void DeclarativeDragArea::mouseReleaseEvent(QMouseEvent* event)
{
    Q_UNUSED(event);
    m_draggingJustStarted = false;
    setKeepMouseGrab(false);
    ungrabMouse();
}
void QQuickPinchArea::clearPinch()
{
    Q_D(QQuickPinchArea);

    d->touchPoints.clear();
    if (d->inPinch) {
        d->inPinch = false;
        QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
        QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);
        pe.setStartCenter(d->pinchStartCenter);
        pe.setPreviousCenter(pinchCenter);
        pe.setPreviousAngle(d->pinchLastAngle);
        pe.setPreviousScale(d->pinchLastScale);
        pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
        pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
        pe.setPoint1(mapFromScene(d->lastPoint1));
        pe.setPoint2(mapFromScene(d->lastPoint2));
        emit pinchFinished(&pe);
        if (d->pinch && d->pinch->target())
            d->pinch->setActive(false);
    }
    d->pinchStartDist = 0;
    d->pinchActivated = false;
    d->initPinch = false;
    d->pinchRejected = false;
    d->stealMouse = false;
    d->id1 = -1;
    QQuickWindow *win = window();
    if (win && win->mouseGrabberItem() == this)
        ungrabMouse();
    setKeepMouseGrab(false);
}
示例#4
0
void Connection::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsObject::mouseReleaseEvent(event);
    if (drag_state == CONNECTED)
        return;

    ungrabMouse();
    clearFocus();
    setFlag(QGraphicsItem::ItemIsFocusable, false);

    InputPort* target = gscene()->getInputPortAt(endPos());
    Datum* datum = target ? target->getDatum() : NULL;
    if (target && datum->acceptsLink(link))
    {
        datum->addLink(link);
        drag_state = CONNECTED;

        connect(endInspector(), &NodeInspector::moved,
                this, &Connection::onInspectorMoved);
        connect(endInspector(), &NodeInspector::hiddenChanged,
                this, &Connection::onHiddenChanged);

        App::instance()->pushStack(new UndoAddLinkCommand(link));
    }
    else
    {
        link->deleteLater();
    }

    prepareGeometryChange();
}
示例#5
0
void Connection::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsObject::mouseReleaseEvent(event);
    if (drag_state == CONNECTED)
        return;

    ungrabMouse();
    clearFocus();
    setFlag(QGraphicsItem::ItemIsFocusable, false);

    InputPort* t = gscene()->getInputPortAt(endPos());
    Datum* datum = target ? target->getDatum() : NULL;
    if (t && datum->acceptsLink(source->getDatum()))
    {
        target = t;
        t->install(this);

        datum->installLink(source->getDatum());
        drag_state = CONNECTED;
        App::instance()->pushStack(
                new UndoAddLinkCommand(source->getDatum(), datum));
        onPortsMoved();

        emit(changed());
    }
    else
    {
        deleteLater();
    }

    prepareGeometryChange();
}
示例#6
0
void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    d->stealMouse = false;
    if (!d->enabled && !d->pressed) {
        QQuickItem::mouseReleaseEvent(event);
    } else {
        d->saveEvent(event);
        setPressed(event->button(), false);
        if (!d->pressed) {
            // no other buttons are pressed
#ifndef QT_NO_DRAGANDDROP
            if (d->drag)
                d->drag->setActive(false);
#endif
            // If we don't accept hover, we need to reset containsMouse.
            if (!acceptHoverEvents())
                setHovered(false);
            QQuickWindow *w = window();
            if (w && w->mouseGrabberItem() == this)
                ungrabMouse();
            setKeepMouseGrab(false);
        }
    }
    d->doubleClick = false;
}
示例#7
0
void ItemTile::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent )
{
    if(scene->DrawMode)
    {
        unsetCursor();
        ungrabMouse();
        this->setSelected(false);
        return;
    }

    //Discard multi-mouse keys
    if((mouseLeft)||(mouseMid)||(mouseRight))
    {
        mouseEvent->accept();
        return;
    }

    if( mouseEvent->buttons() & Qt::LeftButton )
        mouseLeft=true;
    if( mouseEvent->buttons() & Qt::MiddleButton )
        mouseMid=true;
    if( mouseEvent->buttons() & Qt::RightButton )
        mouseRight=true;

    QGraphicsItem::mousePressEvent(mouseEvent);
}
示例#8
0
void BlurItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
  ungrabMouse();
  setFlag(ItemIsSelectable, false);
  m_pixmap = QPixmap();

  QGraphicsRectItem::mouseReleaseEvent(event);
}
bool
QcMapItem::send_mouse_event(QMouseEvent * event)
{
  qInfo() << event;

  QPointF local_position = mapFromScene(event->windowPos());
  QQuickWindow * _window = window();
  QQuickItem * grabber = _window ? _window->mouseGrabberItem() : nullptr;
  // Fixme: faster ? / duplicated
  bool is_mouse_area = !grabber or QString(grabber->metaObject()->className()).startsWith(QStringLiteral("QQuickMouseArea"));
  bool steal_event = m_gesture_area->is_active(); // means pan or pinch is active

  // grabber is QQuickMouseArea, steal_event is false first then true
  // qInfo() << event << "\ngrabber" << grabber << "\nsteal_event" << steal_event << is_mouse_area;

  if (is_mouse_area and (steal_event or contains(local_position)) and (!grabber or !grabber->keepMouseGrab())) {
    QScopedPointer<QMouseEvent> mouseEvent(QQuickWindowPrivate::cloneMouseEvent(event, &local_position));
    mouseEvent->setAccepted(false);

    switch (mouseEvent->type()) {
    case QEvent::MouseMove:
      m_gesture_area->handle_mouse_move_event(mouseEvent.data());
      break;
    case QEvent::MouseButtonPress:
      m_gesture_area->handle_mouse_press_event(mouseEvent.data());
      break;
    case QEvent::MouseButtonRelease:
      m_gesture_area->handle_mouse_release_event(mouseEvent.data());
      break;
    default:
      break;
    }

    steal_event = m_gesture_area->is_active(); // recheck value
    // Fixme: duplicated code ???
    grabber = _window ? _window->mouseGrabberItem() : nullptr;
    // qInfo() << "grabber" << grabber << "\nsteal_event" << steal_event;

    if (grabber and steal_event and !grabber->keepMouseGrab() and grabber != this) {
      // qInfo() << "grab mouse";
      grabMouse();
    }

    if (steal_event) {
      event->setAccepted(true);
      return true; // do not deliver event
    } else
      return false; // deliver event

  } else {
    // ungrab if necessary and deliver event
    if (event->type() == QEvent::MouseButtonRelease
        and (_window and _window->mouseGrabberItem() == this))
      // qInfo() << "ungrab mouse";
      ungrabMouse();
    return false; // deliver event
  }
}
示例#10
0
void ConnectorLine::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
   event->accept();

   m_pConnector->remNullLines();

   setCursor(Qt::CrossCursor);
   ungrabMouse();
}
示例#11
0
/*!
    \internal
*/
void QDeclarativeGeoMap::mouseReleaseEvent(QMouseEvent *event)
{
    if (isInteractive()) {
        m_gestureArea->handleMouseReleaseEvent(event);
        ungrabMouse();
    } else {
        QQuickItem::mouseReleaseEvent(event);
    }
}
示例#12
0
bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    QGraphicsSceneMouseEvent mouseEvent(event->type());
    QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();

    QGraphicsScene *s = scene();
    QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
    bool stealThisEvent = d->stealMouse;
    if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
        mouseEvent.setAccepted(false);
        for (int i = 0x1; i <= 0x10; i <<= 1) {
            if (event->buttons() & i) {
                Qt::MouseButton button = Qt::MouseButton(i);
                mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
            }
        }
        mouseEvent.setScenePos(event->scenePos());
        mouseEvent.setLastScenePos(event->lastScenePos());
        mouseEvent.setPos(mapFromScene(event->scenePos()));
        mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));

        switch(mouseEvent.type()) {
        case QEvent::GraphicsSceneMouseMove:
            mouseMoveEvent(&mouseEvent);
            break;
        case QEvent::GraphicsSceneMousePress:
            mousePressEvent(&mouseEvent);
            break;
        case QEvent::GraphicsSceneMouseRelease:
            mouseReleaseEvent(&mouseEvent);
            break;
        default:
            break;
        }
        grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
        if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
            grabMouse();

        return stealThisEvent;
    }
    if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
        if (d->pressed) {
            d->pressed = false;
            d->stealMouse = false;
            if (s && s->mouseGrabberItem() == this)
                ungrabMouse();
            emit canceled();
            emit pressedChanged();
            if (d->hovered) {
                d->hovered = false;
                emit hoveredChanged();
            }
        }
    }
    return false;
}
示例#13
0
void Window::setMouseGrabbed(bool grabbed)
{
	if (grabbed) {
		//qDebug() << "sm grabbing mouse";
		grabMouse();
	} else {
		//qDebug() << "sm ungrabbing mouse";
		ungrabMouse();
	}
}
示例#14
0
void DragVtx::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        selected=false;
        std::cout<<"released"<<std::endl;
        setCoord(event->pos().x(),event->pos().y());
    }
    ungrabMouse();
}
示例#15
0
void STClearButtonView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
    if(m_drag){
        m_drag=false;
        relayout();
        ungrabMouse();
        if(m_hover){
            emit activated();
        }
    }
}
示例#16
0
void DragBBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        selected=false;
        vtx[0]->setCoord(event->pos().x()-x1,event->pos().y()-y1);
        vtx[1]->setCoord(event->pos().x()-x2,event->pos().y()-y2);
    }
    ungrabMouse();
}
示例#17
0
void STButtonView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
    if(m_pressed){
        m_pressed=false;
        if(m_hover){
            emit activated();
        }
        updateState();
    }
    ungrabMouse();
   //QGraphicsObject::mouseReleaseEvent(event);
}
void
QcMapItem::mouseReleaseEvent(QMouseEvent * event)
{
  // Called when mouse is grabbed
  qInfo();
  if (is_interactive()) {
    m_gesture_area->handle_mouse_release_event(event);
    ungrabMouse();
  } else
    QQuickItem::mouseReleaseEvent(event);
}
示例#19
0
bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event)
{
    Q_D(QQuickMouseArea);
    QPointF localPos = mapFromScene(event->windowPos());

    QQuickWindow *c = window();
    QQuickItem *grabber = c ? c->mouseGrabberItem() : 0;
    bool stealThisEvent = d->stealMouse;
    if ((stealThisEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab())) {
        QMouseEvent mouseEvent(event->type(), localPos, event->windowPos(), event->screenPos(),
                               event->button(), event->buttons(), event->modifiers());
        mouseEvent.setAccepted(false);

        switch (event->type()) {
        case QEvent::MouseMove:
            mouseMoveEvent(&mouseEvent);
            break;
        case QEvent::MouseButtonPress:
            mousePressEvent(&mouseEvent);
            break;
        case QEvent::MouseButtonRelease:
            mouseReleaseEvent(&mouseEvent);
            stealThisEvent = d->stealMouse;
            break;
        default:
            break;
        }
        grabber = c ? c->mouseGrabberItem() : 0;
        if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
            grabMouse();

        return stealThisEvent;
    }
    if (event->type() == QEvent::MouseButtonRelease) {
        if (d->pressed) {
            d->pressed &= ~event->button();
            emit pressedButtonsChanged();
            if (!d->pressed) {
                // no other buttons are pressed
                d->stealMouse = false;
                if (c && c->mouseGrabberItem() == this)
                    ungrabMouse();
                emit canceled();
                emit pressedChanged();
                emit containsPressChanged();
                if (d->hovered) {
                    d->hovered = false;
                    emit hoveredChanged();
                }
            }
        }
    }
    return false;
}
示例#20
0
void QDeclarativePinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativePinchArea);
    d->stealMouse = false;
    if (!d->absorb) {
        QDeclarativeItem::mouseReleaseEvent(event);
    } else {
        QGraphicsScene *s = scene();
        if (s && s->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
}
示例#21
0
void QSGPinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QSGPinchArea);
    d->stealMouse = false;
    if (!d->absorb) {
        QSGItem::mouseReleaseEvent(event);
    } else {
        QSGCanvas *c = canvas();
        if (c && c->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
}
示例#22
0
void PixmapButton::setManualMode(bool manualModeEnabled) {
    if (manualModeEnabled) {
        ungrabMouse();
        if (m_pExpandedHitTarget) {
            m_pExpandedHitTarget->ungrabMouse();
        }
    } else {
        if (m_pExpandedHitTarget) {
            m_pExpandedHitTarget->grabMouse();
        } else {
            grabMouse();
        }
    }
}
示例#23
0
bool QSGPinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QSGPinchArea);
    QGraphicsSceneMouseEvent mouseEvent(event->type());
    QRectF myRect = mapRectToScene(QRectF(0, 0, width(), height()));

    QSGCanvas *c = canvas();
    QSGItem *grabber = c ? c->mouseGrabberItem() : 0;
    bool stealThisEvent = d->stealMouse;
    if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
        mouseEvent.setAccepted(false);
        for (int i = 0x1; i <= 0x10; i <<= 1) {
            if (event->buttons() & i) {
                Qt::MouseButton button = Qt::MouseButton(i);
                mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
            }
        }
        mouseEvent.setScenePos(event->scenePos());
        mouseEvent.setLastScenePos(event->lastScenePos());
        mouseEvent.setPos(mapFromScene(event->scenePos()));
        mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));

        switch(mouseEvent.type()) {
        case QEvent::GraphicsSceneMouseMove:
            mouseMoveEvent(&mouseEvent);
            break;
        case QEvent::GraphicsSceneMousePress:
            mousePressEvent(&mouseEvent);
            break;
        case QEvent::GraphicsSceneMouseRelease:
            mouseReleaseEvent(&mouseEvent);
            break;
        default:
            break;
        }
        grabber = c->mouseGrabberItem();
        if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
            grabMouse();

        return stealThisEvent;
    }
    if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
        d->stealMouse = false;
        if (c && c->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
    return false;
}
示例#24
0
void PixmapButtonHitTarget::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
    if (m_qpButton.isNull())
    {
        event->ignore();
        return;
    }
    PixmapButton
    ungrabMouse();
    m_qpButton->grabMouse();
    m_qpButton->mousePressEvent(event);		//careful if PixmapButton's mousePressEvent()
    //ever needs to consider event's coordinates - they'll be in the wrong
    //coordinate space

}
示例#25
0
void NodeInspector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    QGraphicsItem::mouseReleaseEvent(event);

    if (dragging)
    {
        ungrabMouse();
    }
    else if (event->button() == Qt::LeftButton)
    {
        // Store an Undo command for this drag
        auto delta = event->scenePos() -
                     event->buttonDownScenePos(Qt::LeftButton);
        static_cast<GraphScene*>(scene())->endDrag(delta);
    }
    dragging = false;
}
示例#26
0
void PixmapButton::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    if(!isVisible())
        return;

    if(m_pressed && !isUnderMouse()) {
        m_pressed = false;

        if(m_active)
            setPixmap(m_onPixmap);
        else
            setPixmap(m_offPixmap);

        update();
        ungrabMouse();
        Q_EMIT clickComplete();
    }
}
示例#27
0
bool QQuickMultiPointTouchArea::sendMouseEvent(QMouseEvent *event)
{
    QPointF localPos = mapFromScene(event->windowPos());

    QQuickWindow *c = window();
    QQuickItem *grabber = c ? c->mouseGrabberItem() : 0;
    bool stealThisEvent = _stealMouse;
    if ((stealThisEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab())) {
        QMouseEvent mouseEvent(event->type(), localPos, event->windowPos(), event->screenPos(),
                               event->button(), event->buttons(), event->modifiers());
        mouseEvent.setAccepted(false);
        QGuiApplicationPrivate::setMouseEventCapsAndVelocity(&mouseEvent,
                                                             QGuiApplicationPrivate::mouseEventCaps(event),
                                                             QGuiApplicationPrivate::mouseEventVelocity(event));
        QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, Qt::MouseEventSynthesizedByQt);

        switch (mouseEvent.type()) {
        case QEvent::MouseMove:
            mouseMoveEvent(&mouseEvent);
            break;
        case QEvent::MouseButtonPress:
            mousePressEvent(&mouseEvent);
            break;
        case QEvent::MouseButtonRelease:
            mouseReleaseEvent(&mouseEvent);
            break;
        default:
            break;
        }
        grabber = c ? c->mouseGrabberItem() : 0;
        if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
            grabMouse();

        return stealThisEvent;
    }
    if (event->type() == QEvent::MouseButtonRelease) {
        _stealMouse = false;
        if (c && c->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
    return false;
}
示例#28
0
void BBox::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    if (!(event->buttons() & Qt::LeftButton))
    return;
    if((event->pos()-dragStartPos).manhattanLength()<2)
    return;
    std::cout<<this->scene()->mouseGrabberItem()<<"|"<<this<<std::endl;
    QDrag *drag = new QDrag(event->widget());
    QMimeData *mimeData = new QMimeData;
    int datarr[3]={event->pos().x(),event->pos().y(),bbid};
    QByteArray iddata((const char *)datarr,sizeof(int)*3);
    mimeData->setData("id",iddata);
    drag->setMimeData(mimeData);
    //QPixmap pixmap(vtx[2]-vtx[0],vtx[3]-vtx[1]);
    //drag->setPixmap(pixmap);
    linePen.setStyle(Qt::DotLine);
    Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
    linePen.setStyle(Qt::SolidLine);
    ungrabMouse();
}
示例#29
0
void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_D(QDeclarativeMouseArea);
    d->stealMouse = false;
    if (!d->absorb) {
        QDeclarativeItem::mouseReleaseEvent(event);
    } else {
        d->saveEvent(event);
        setPressed(false);
        if (d->drag)
            d->drag->setActive(false);
        // If we don't accept hover, we need to reset containsMouse.
        if (!acceptHoverEvents())
            setHovered(false);
        QGraphicsScene *s = scene();
        if (s && s->mouseGrabberItem() == this)
            ungrabMouse();
        setKeepMouseGrab(false);
    }
}
示例#30
0
void QQuickMultiPointTouchArea::mouseReleaseEvent(QMouseEvent *event)
{
    _stealMouse = false;
    if (!isEnabled() || !_mouseEnabled) {
        QQuickItem::mouseReleaseEvent(event);
        return;
    }

    if (event->source() != Qt::MouseEventNotSynthesized)
        return;

    if (_mouseTouchPoint) {
        updateTouchData(event);
        _mouseTouchPoint->setInUse(false);
        _releasedTouchPoints.removeAll(_mouseTouchPoint);
        _mouseTouchPoint = Q_NULLPTR;
    }

    QQuickWindow *c = window();
    if (c && c->mouseGrabberItem() == this)
        ungrabMouse();
    setKeepMouseGrab(false);
}