Beispiel #1
0
void VCButton_Test::toggle()
{
    QWidget w;

    Scene* sc = new Scene(m_doc);
    sc->setValue(0, 0, 255);
    sc->setFadeInSpeed(1000);
    sc->setFadeOutSpeed(1000);
    m_doc->addFunction(sc);

    VCButton btn(&w, m_doc);
    btn.setCaption("Foobar");
    btn.setFunction(sc->id());
    btn.setAction(VCButton::Toggle);
    btn.setKeySequence(QKeySequence(keySequenceB));
    btn.enableStartupIntensity(true);
    btn.setStartupIntensity(qreal(0.2));

    // Mouse button press in design mode doesn't toggle the function
    QCOMPARE(m_doc->mode(), Doc::Design);
    QMouseEvent ev(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0, 0);
    btn.mousePressEvent(&ev);
    QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 0);
    ev = QMouseEvent(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::LeftButton, 0, 0);
    btn.mouseReleaseEvent(&ev);
    QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 0);

    // Mouse button press in operate mode should toggle the function
    m_doc->setMode(Doc::Operate);
    btn.slotKeyPressed(QKeySequence(keySequenceB));
    // tell MasterTimer to process start queue
    m_doc->masterTimer()->timerTick();
    QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 1);
    QCOMPARE(m_doc->masterTimer()->m_functionList[0], sc);
    QCOMPARE(sc->getAttributeValue(Function::Intensity), btn.startupIntensity());
    btn.slotKeyReleased(QKeySequence(keySequenceB));
    m_doc->masterTimer()->timerTick(); // Allow MasterTimer to take the function under execution
    QCOMPARE(sc->stopped(), false);
    QCOMPARE(btn.isOn(), true);

    ev = QMouseEvent(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0, 0);
    btn.mousePressEvent(&ev);
    QCOMPARE(sc->m_stop, true);
    QCOMPARE(btn.isOn(), true);

    btn.slotFunctionStopped(sc->id());
    QCOMPARE(btn.isOn(), false);
    VCButton another(&w, m_doc);
    QVERIFY(btn.palette().color(QPalette::Button) != another.palette().color(QPalette::Button));
    QTest::qWait(500);
    QVERIFY(btn.palette().color(QPalette::Button) == another.palette().color(QPalette::Button));

    ev = QMouseEvent(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::LeftButton, 0, 0);
    btn.mouseReleaseEvent(&ev);
}
static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt::MouseButton _button, Qt::KeyboardModifiers _stateKey, QPointF _pos, int _delay = -1)
{
    if (_delay == -1 || _delay < 30)
        _delay = 30;
    if (_delay > 0)
        QTest::qWait(_delay);

    if (_action == MouseClick)
    {
        mouseEvent(MousePress, _window, _item, _button, _stateKey, _pos);
        mouseEvent(MouseRelease, _window, _item, _button, _stateKey, _pos);
        return;
    }

    QPoint pos = _pos.toPoint();
    QQuickItem* sgitem = qobject_cast<QQuickItem*>(_item);
    if (sgitem)
        pos = sgitem->mapToScene(_pos).toPoint();

    _stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);

    QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, _button, _stateKey);
    switch (_action)
    {
    case MousePress:
        me = QMouseEvent(QEvent::MouseButtonPress, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
        break;
    case MouseRelease:
        me = QMouseEvent(QEvent::MouseButtonRelease, pos, _window->mapToGlobal(pos), _button, 0, _stateKey);
        break;
    case MouseDoubleClick:
        me = QMouseEvent(QEvent::MouseButtonDblClick, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
        break;
    case MouseMove:
        // with move event the _button is NoButton, but 'buttons' holds the currently pressed buttons
        me = QMouseEvent(QEvent::MouseMove, pos, _window->mapToGlobal(pos), Qt::NoButton, _button, _stateKey);
        break;
    default:
        break;
    }
    QSpontaneKeyEvent::setSpontaneous(&me);
    if (!qApp->notify(_window, &me))
    {
        static const char* mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" };
        QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
        QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(_action)])).toLatin1().data());
    }
}
Beispiel #3
0
QMouseEvent
ImageView::mapMousePositionToImage( QMouseEvent * e )
{
   int x = (e->pos().x()-_imagePosition.left()) / _scaleFactor;
   int y = (e->pos().y()-_imagePosition.top()) / _scaleFactor;
   return QMouseEvent(e->type(),QPoint(x,y),e->button(),e->buttons(),e->modifiers());
}
void KisAlternateInvocationAction::mouseMoved(const QPointF &lastPos, const QPointF &pos)
{
    Q_UNUSED(lastPos);

    QMouseEvent targetEvent(QEvent::MouseMove, pos.toPoint(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);

    switch (m_savedShortcut) {
    case PrimaryAlternateToggleShortcut:
        targetEvent = QMouseEvent(QEvent::MouseMove, pos.toPoint(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
        break;
    case SecondaryAlternateToggleShortcut:
        targetEvent = QMouseEvent(QEvent::MouseMove, pos.toPoint(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier | Qt::AltModifier);
        break;
    }

    inputManager()->toolProxy()->mouseMoveEvent(&targetEvent, inputManager()->widgetToPixel(pos));
}
void KisAlternateInvocationAction::end(QEvent *event)
{
    QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);

    QMouseEvent targetEvent(*mouseEvent);

    switch (m_savedShortcut) {
    case PrimaryAlternateToggleShortcut:
        targetEvent = QMouseEvent(QEvent::MouseButtonRelease, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
        break;
    case SecondaryAlternateToggleShortcut:
        targetEvent = QMouseEvent(QEvent::MouseButtonRelease, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier | Qt::AltModifier);
        break;
    }

    inputManager()->toolProxy()->mouseReleaseEvent(&targetEvent, inputManager()->widgetToPixel(mouseEvent->posF()));

    KisAbstractInputAction::end(event);
}
Beispiel #6
0
void
EvTabBar::mousePressEvent ( QMouseEvent * inMouseEvent )
{
	if( inMouseEvent->button() == Qt::RightButton && mTabBar->count() > 1 )
	{
		mousePressEvent( &QMouseEvent( QEvent::MouseButtonPress, inMouseEvent->pos(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier ) );
		mContextualMenu->popup( inMouseEvent->globalPos() );
	}
	QWidget::mousePressEvent( inMouseEvent );
}
Beispiel #7
0
QMouseEvent storeMouseEvent(QMouseEvent* event)
{
    return QMouseEvent(QEvent::MouseMove,
                       event->localPos(),
                       event->windowPos(),
                       event->screenPos(),
                       event->button(),
                       event->buttons(),
                       event->modifiers());
}
Beispiel #8
0
bool PopupItem::eventFilter( QObject *object, QEvent *e )
{
    MarbleWidget *widget = dynamic_cast<MarbleWidget*> ( object );
    if ( !widget ) {
        return BillboardGraphicsItem::eventFilter( object, e );
    }

    if ( e->type() == QEvent::MouseButtonDblClick
            || e->type() == QEvent::MouseMove
            || e->type() == QEvent::MouseButtonPress
            || e->type() == QEvent::MouseButtonRelease )
    {
        // Mouse events are forwarded to the underlying widget
        QMouseEvent *event = static_cast<QMouseEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        bool const forcedMouseRelease = m_needMouseRelease && e->type() == QEvent::MouseButtonRelease;
        if ( !shiftedPos.isNull() || forcedMouseRelease ) {
            if ( !m_needMouseRelease && e->type() == QEvent::MouseButtonPress ) {
                m_needMouseRelease = true;
            } else if ( forcedMouseRelease ) {
                m_needMouseRelease = false;
            }
            widget->setCursor( Qt::ArrowCursor );
            // transform to children's coordinates
            QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
                                                    event->globalPos(), event->button(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    } else if ( e->type() == QEvent::Wheel ) {
        // Wheel events are forwarded to the underlying widget
        QWheelEvent *event = static_cast<QWheelEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        if ( !shiftedPos.isNull() ) {
            widget->setCursor( Qt::ArrowCursor );
            QWheelEvent shiftedEvent = QWheelEvent( shiftedPos,
                                                    event->globalPos(), event->delta(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    }

    return BillboardGraphicsItem::eventFilter( object, e );
}
Beispiel #9
0
void QQuickPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
{
    if (!qobject_cast<QQuickPopupWindow*>(transientParent())
        && ((m_mouseMoved && e->type() == QEvent::MouseButtonRelease)
            || e->type() == QEvent::MouseButtonPress)) {
        // Clicked outside any popup
        dismissPopup();
    } else if (transientParent()) {
        QPoint parentPos = transientParent()->mapFromGlobal(mapToGlobal(e->pos()));
        QMouseEvent pe = QMouseEvent(e->type(), parentPos, e->button(), e->buttons(), e->modifiers());
        QGuiApplication::sendEvent(transientParent(), &pe);
    }
}
Beispiel #10
0
void KisAlternateInvocationAction::inputEvent(QEvent* event)
{
    if (event && event->type() == QEvent::MouseMove) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

        QMouseEvent targetEvent(QEvent::MouseMove, mouseEvent->pos(), Qt::NoButton, Qt::LeftButton, Qt::ShiftModifier);

        switch (m_d->savedAction) {
        case KisTool::AlternatePickFgNode:
            targetEvent = QMouseEvent(QEvent::MouseMove, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
            break;
        case KisTool::AlternateThird:
            targetEvent = QMouseEvent(QEvent::MouseMove, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier | Qt::AltModifier);
            break;
        }

        inputManager()->toolProxy()->forwardEvent(
            KisToolProxy::CONTINUE, m_d->savedAction, &targetEvent, event,
            inputManager()->lastTabletEvent(),
            inputManager()->canvas()->canvasWidget()->mapToGlobal(QPoint(0, 0)));
    }
}
Beispiel #11
0
/*! \reimp
*/
void QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
{
    if (d->page) {
        const bool accepted = ev->isAccepted();
        QMouseEvent me = QMouseEvent(QEvent::MouseMove,
                ev->pos().toPoint(), Qt::NoButton,
                Qt::NoButton, Qt::NoModifier);
        d->page->event(&me);
        ev->setAccepted(accepted);
    }

    if (!ev->isAccepted())
        QGraphicsItem::hoverMoveEvent(ev);
}
void popupWindow::mouseReleaseEvent(QMouseEvent *e) {
    QRect rect = QRect(QPoint(), size());
    if (rect.contains(e->pos())) {
        if(m_mouseMoved) {
            QMouseEvent pe = QMouseEvent(QEvent::MouseButtonPress, e->pos(), e->button(),
                                         e->buttons(), e->modifiers());
            QQuickWindow::mousePressEvent(&pe);
            QQuickWindow::mouseReleaseEvent(e);
        }
        m_mouseMoved = true; // Initial mouse release counts as move.
    } else {
        forwardEventToTransientParent(e);
    }
}
Beispiel #13
0
void Visualizer::handleMouseEvent(QMouseEvent* e)
{
  m_mouseDragReleased = false;
  if (!m_mouseDrag && e->buttons() != Qt::NoButton && e->type() == QEvent::MouseMove)
  {
    m_mouseDrag = true;
    m_mouseDragStart = m_lastMouseEvent.pos();
  }
  if (m_mouseDrag && e->buttons() == Qt::NoButton)
  {
    m_mouseDrag = false;
    m_mouseDragReleased = true;
  }
  m_lastMouseEvent = QMouseEvent(e->type(), e->pos(), e->globalPos(), e->button(), e->buttons(), e->modifiers());
}
Beispiel #14
0
void KisAlternateInvocationAction::end(QEvent *event)
{
    if (!event) return;

    QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);

    QMouseEvent targetEvent(*mouseEvent);

    switch (m_d->savedAction) {
    case KisTool::AlternatePickFgNode:
        targetEvent = QMouseEvent(QEvent::MouseButtonRelease, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier);
        break;
    case KisTool::AlternateThird:
        targetEvent = QMouseEvent(QEvent::MouseButtonRelease, mouseEvent->pos(), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier | Qt::AltModifier);
        break;
    }

    inputManager()->toolProxy()->forwardEvent(
        KisToolProxy::END, m_d->savedAction, &targetEvent, event,
        inputManager()->lastTabletEvent(),
        inputManager()->canvas()->canvasWidget()->mapToGlobal(QPoint(0, 0)));

    KisAbstractInputAction::end(event);
}
void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{
	if(event->key() == Qt::Key_Shift)
	{
		view->setMouseTracking(true);
		m_selecting = true;

		// generate a false mouse move to update drawing on shift keypressed !
		QPoint p = m_schnapps->getSelectedView()->mapFromGlobal(QCursor::pos());
		QMouseEvent me = QMouseEvent(QEvent::MouseMove, p, Qt::NoButton, Qt::NoButton, Qt::ShiftModifier);
		mouseMove(view, &me);

		view->updateGL();
	}
}
Beispiel #16
0
ssr::QOpenGLPlotter::QOpenGLPlotter(Publisher& controller, const Scene& scene
        , const std::string& path_to_gui_images
        , QWidget *parent)
  : QGLWidget(parent),
    _controller(controller),
    _scene(scene), 
    _active_source(-1),
    _path_to_gui_images(path_to_gui_images),
    _id_of_last_clicked_source(0),
    _zoom_factor(STDZOOMFACTOR),
    _previous_mouse_event(QMouseEvent(QEvent::MouseButtonPress,
          QPoint(),
          Qt::LeftButton,
          Qt::LeftButton,
          Qt::NoModifier)), // dummy event
    _ctrl_pressed(false),
    _alt_pressed(false),
    _rubber_band_starting_point(Position()),
    _rubber_band_ending_point(Position()),
    _window_x_offset(0.0f),
    _window_y_offset(STDWINDOWYOFFSET),
    _window_z_offset(0.0f),
    _x_offset(0.0f),
    _y_offset(0.0f),
    _z_offset(0.0f),
    _rotation_x(0.0f),
    _rotation_y(0.0f),
    _rotation_z(0.0f),
    _reference_selected(false),
    _volume_slider_selected(false),
    _direction_handle_selected(false),
    _allow_displaying_text(true),
    _glu_quadric(gluNewQuadric()),
    _plot_listener(false)
{
  _set_zoom(100); // 100%

  _soloed_sources.clear();

  // define possible colors for sources
  _color_vector.push_back(QColor(163, 95, 35));
  _color_vector.push_back(QColor( 43,174,247));
  _color_vector.push_back(QColor( 75,135, 35));
  _color_vector.push_back(QColor( 97, 31,160));
  _color_vector.push_back(QColor(173, 54, 35));
  //_color_vector.push_back(QColor(242,226, 22));  // yellow is too hard to read

}
Beispiel #17
0
// Triggered in the view thread (usually the main thread)
bool MouseEventFilter::eventFilter(QObject *obj, QEvent *e)
{
    Q_UNUSED(obj);
    switch (e->type()) {
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonRelease:
    case QEvent::MouseMove:
        // Store event to be processed later on in an InputAspect job
        m_inputHandler->appendMouseEvent(QMouseEvent(*static_cast<QMouseEvent *>(e)));
        break;
    default:
        break;
    }

    return false;
}
Beispiel #18
0
QMouseEvent PanelKMenu::translateMouseEvent( QMouseEvent* e )
{
    QRect side = sideImageRect();

    if ( !side.contains( e->pos() ) )
        return *e;

    QPoint newpos( e->pos() );
    QApplication::isRightToLeft() ?
        newpos.setX( newpos.x() - side.width() ) :
        newpos.setX( newpos.x() + side.width() );
    QPoint newglobal( e->globalPos() );
    QApplication::isRightToLeft() ?
        newglobal.setX( newpos.x() - side.width() ) :
        newglobal.setX( newpos.x() + side.width() );

    return QMouseEvent( e->type(), newpos, newglobal, e->button(), e->state() );
}
void KisAlternateInvocationAction::end(QEvent *event)
{
    if (!event) return;

    Qt::KeyboardModifiers modifiers;

    switch (m_d->savedAction) {
    case KisTool::AlternatePickFgNode:
        modifiers = Qt::ControlModifier;
        break;
    case KisTool::AlternateThird:
        modifiers = Qt::ControlModifier | Qt::AltModifier;
        break;
    default:
        ;
    }

    QMouseEvent targetEvent = QMouseEvent(QEvent::MouseButtonRelease, eventPosF(event), Qt::LeftButton, Qt::LeftButton, modifiers);
    inputManager()->toolProxy()->forwardEvent(KisToolProxy::END, m_d->savedAction, &targetEvent, event);

    KisAbstractInputAction::end(event);
}
bool QMeeGoOverlayWidget::eventFilter(QObject *, QEvent *event)
{
    if (event->spontaneous() == false)
        return false;

    switch(event->type()) {
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonRelease:
    {
        QMouseEvent *e = static_cast <QMouseEvent *>(event);
        QMouseEvent newEvent = QMouseEvent(e->type(),
                                           convertPoint(e->pos()),
                                           convertPoint(e->globalPos()),
                                           e->button(),
                                           e->buttons(),
                                           e->modifiers());
        QCoreApplication::sendEvent(this, &newEvent);
        return true;
    }

    default:
        return false;
    }
}
    static void mouseEvent(MouseAction action, QWidget *widget,
                           QObject *item, Qt::MouseButton button,
                           Qt::KeyboardModifiers stateKey, QPointF _pos, int delay=-1)
    {
        QTEST_ASSERT(widget);
        QTEST_ASSERT(item);

        if (delay == -1 || delay < QTest::defaultMouseDelay())
            delay = QTest::defaultMouseDelay();
        if (delay > 0)
            QTest::qWait(delay);

        if (action == MouseClick) {
            mouseEvent(MousePress, widget, item, button, stateKey, _pos);
            mouseEvent(MouseRelease, widget, item, button, stateKey, _pos);
            return;
        }

        QPoint pos;
        QDeclarativeView *view = qobject_cast<QDeclarativeView *>(widget);
        QWidget *eventWidget = widget;
        QDeclarativeItem *ditem = qobject_cast<QDeclarativeItem *>(item);
        if (!ditem) {
            qWarning("Mouse event target is not an Item");
            return;
        }
        pos = view->mapFromScene(ditem->mapToScene(_pos));
        eventWidget = view->viewport();

        QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
        QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);

        stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);

        QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
        switch (action)
        {
            case MousePress:
                me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
                break;
            case MouseRelease:
                me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
                break;
            case MouseDoubleClick:
                me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
                break;
            case MouseMove:
                if (button == Qt::NoButton) {
                    // If we send a mouse move event with no button pressed, it will be
                    // rejected (unless mouseTracking is set to true); simulate instead
                    QCursor::setPos(widget->mapToGlobal(pos));
                    qApp->processEvents();
                } else {
                    me = QMouseEvent(QEvent::MouseMove, pos, widget->mapToGlobal(pos), button, button, stateKey);
                }
                break;
            default:
                QTEST_ASSERT(false);
        }
        QSpontaneKeyEvent::setSpontaneous(&me);
        if (!qApp->notify(eventWidget, &me)) {
            static const char *mouseActionNames[] =
                { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" };
            QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
            QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
        }
    }
Beispiel #22
0
    QPoint wep[2];
    int we[2];

    ds >> type
        >> e.context
        >> ke[0]
        >> ke[1]
        >> ke[2]
        >> me[0]
        >> mepf
        >> me[1]
        >> me[2]
        >> me[3]
        >> wepf[0]
        >> wepf[1]
        >> wep[0]
        >> wep[1]
        >> we[0]
        >> we[1];

    e.type = static_cast<QVREventType>(type);
    e.keyEvent = QKeyEvent(static_cast<QEvent::Type>(ke[0]), ke[1], static_cast<Qt::KeyboardModifier>(ke[2]));
    e.mouseEvent = QMouseEvent(static_cast<QEvent::Type>(me[0]), mepf,
            static_cast<Qt::MouseButton>(me[1]), static_cast<Qt::MouseButtons>(me[2]),
            static_cast<Qt::KeyboardModifier>(me[3]));
    e.wheelEvent = QWheelEvent(wepf[0], wepf[1], wep[0], wep[1], 0, Qt::Horizontal,
            static_cast<Qt::MouseButtons>(we[0]), static_cast<Qt::KeyboardModifier>(we[1]));

    return ds;
}
Beispiel #23
0
    static void mouseEvent(MouseAction action, QWindow *window,
                           QObject *item, Qt::MouseButton button,
                           Qt::KeyboardModifiers stateKey, QPointF _pos, int delay=-1)
    {
        QTEST_ASSERT(window);
        QTEST_ASSERT(item);

        if (delay == -1 || delay < QTest::defaultMouseDelay())
            delay = QTest::defaultMouseDelay();
        if (delay > 0)
            QTest::qWait(delay);

        if (action == MouseClick) {
            mouseEvent(MousePress, window, item, button, stateKey, _pos);
            mouseEvent(MouseRelease, window, item, button, stateKey, _pos);
            return;
        }

        if (action == MouseDoubleClickSequence) {
            mouseEvent(MousePress, window, item, button, stateKey, _pos);
            mouseEvent(MouseRelease, window, item, button, stateKey, _pos);
            mouseEvent(MousePress, window, item, button, stateKey, _pos);
            mouseEvent(MouseDoubleClick, window, item, button, stateKey, _pos);
            mouseEvent(MouseRelease, window, item, button, stateKey, _pos);
            return;
        }

        QPoint pos;
        QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
        if (sgitem)
            pos = sgitem->mapToScene(_pos).toPoint();
        QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
        QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);

        stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);

        QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
        switch (action)
        {
            case MousePress:
                me = QMouseEvent(QEvent::MouseButtonPress, pos, window->mapToGlobal(pos), button, button, stateKey);
                break;
            case MouseRelease:
                me = QMouseEvent(QEvent::MouseButtonRelease, pos, window->mapToGlobal(pos), button, 0, stateKey);
                break;
            case MouseDoubleClick:
                me = QMouseEvent(QEvent::MouseButtonDblClick, pos, window->mapToGlobal(pos), button, button, stateKey);
                break;
            case MouseMove:
                // with move event the button is NoButton, but 'buttons' holds the currently pressed buttons
                me = QMouseEvent(QEvent::MouseMove, pos, window->mapToGlobal(pos), Qt::NoButton, button, stateKey);
                break;
            default:
                QTEST_ASSERT(false);
        }
        QSpontaneKeyEvent::setSpontaneous(&me);
        if (!qApp->notify(window, &me)) {
            static const char *mouseActionNames[] =
                { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove", "MouseDoubleClickSequence" };
            QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
            QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
        }
    }
Beispiel #24
0
void Visualizer::initMouse()
{
  m_lastMouseEvent = QMouseEvent(QEvent::None, QPoint(0,0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
  m_mouseDrag = false;
  m_mouseDragStart = QPoint(0,0);
}
Beispiel #25
0
void KUrlNavigatorMenu::dragMoveEvent(QDragMoveEvent* event)
{
      QMouseEvent mouseEvent(QMouseEvent(QEvent::MouseMove, event->pos(),
          Qt::LeftButton, event->mouseButtons(), event->keyboardModifiers()));
      mouseMoveEvent(&mouseEvent);
}