PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount) { m_timestamp = WebCore::currentTime(); QMouseEvent *me = 0; switch(event->type()) { case QEvent::MouseMove: m_eventType = MouseEventMoved; me = static_cast<QMouseEvent *>(event); break; case QEvent::MouseButtonDblClick: case QEvent::MouseButtonPress: m_eventType = MouseEventPressed; me = static_cast<QMouseEvent *>(event); break; case QEvent::MouseButtonRelease: m_eventType = MouseEventReleased; me = static_cast<QMouseEvent *>(event); break; case QEvent::ContextMenu: { m_eventType = MouseEventPressed; QContextMenuEvent *ce = static_cast<QContextMenuEvent *>(event); m_position = IntPoint(ce->pos()); m_globalPosition = IntPoint(ce->globalPos()); m_button = RightButton; break; } default: m_eventType = MouseEventMoved; } if (me) { m_position = IntPoint(me->pos()); m_globalPosition = IntPoint(me->globalPos()); if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton)) m_button = LeftButton; else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton)) m_button = RightButton; else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton)) m_button = MiddleButton; else m_button = NoButton; } m_clickCount = clickCount; m_shiftKey = (event->modifiers() & Qt::ShiftModifier) != 0; m_ctrlKey = (event->modifiers() & Qt::ControlModifier) != 0; m_altKey = (event->modifiers() & Qt::AltModifier) != 0; m_metaKey = (event->modifiers() & Qt::MetaModifier) != 0; }
void EWAUserAction::execute( QWebView *webViewPtr ) const { if( !webViewPtr ) { return; } //EWAWebView *pEwaWebView = qobject_cast<EWAWebView*>( webViewPtr ); //bool bNeedSetFocus = false; QEvent *pEventCopy = 0; if( isMouseEvent( m_pEvent->type() ) ) { QMouseEvent *pSrcMouseEvent = static_cast<QMouseEvent *>( m_pEvent ); QPoint clickCoords = pSrcMouseEvent->pos(); pEventCopy = new QMouseEvent( pSrcMouseEvent->type(), clickCoords, webViewPtr->mapToGlobal( clickCoords ), pSrcMouseEvent->button(), pSrcMouseEvent->buttons(), pSrcMouseEvent->modifiers() ); } else if( isKeyEvent( m_pEvent->type() ) ) { QKeyEvent *pSrcKeyEvent = static_cast<QKeyEvent*>( m_pEvent ); pEventCopy = new QKeyEvent( pSrcKeyEvent->type(), pSrcKeyEvent->key(), pSrcKeyEvent->modifiers(), pSrcKeyEvent->text(), pSrcKeyEvent->isAutoRepeat(), pSrcKeyEvent->count() ); } if( pEventCopy ) { QSize dstSz = getWebViewSize(); if( webViewPtr->page()->preferredContentsSize() != dstSz ) { webViewPtr->page()->setPreferredContentsSize( dstSz ); } EWAApplication::postEvent( webViewPtr, pEventCopy ); } }
bool StayPoppedUpComboBox::eventFilter(QObject* o, QEvent* e) { // The combo box has installed an event filter on the view. // If it catches a valid mouse button release there, it will hide the popup. // Here we prevent this by eating the event ourselves, // and then dispatching it to its destination. if (o == m_view || o == m_view->viewport()) { switch (e->type()) { case QEvent::MouseButtonRelease: { QMouseEvent* m = static_cast<QMouseEvent*>(e); if (m_view->isVisible() && m_view->rect().contains(m->pos())) { if (o == m_view) { o->event(e); } else // Viewport: Calling event() does not work, viewportEvent() is needed. // This is the event that gets redirected to the QTreeView finally! { sendViewportEventToView(e); } // we have dispatched the event privately; we filter it out from the main dispatching return true; } break; } case QEvent::ContextMenu: { if (o != m_view) { // for whatever reason, the position of the event is slightly wrong QContextMenuEvent* m = static_cast<QContextMenuEvent*>(e); QPoint correctPos = m_view->viewport()->mapFromGlobal(m->globalPos()); QContextMenuEvent corrected(m->reason(), correctPos, m->globalPos(), m->modifiers()); sendViewportEventToView(&corrected); return true; } break; } default: break; } } return QComboBox::eventFilter(o, e); }
bool WebPage::event(QEvent *ev) { QMouseEvent* mouseEvent = NULL; QWheelEvent* wheelEvent = NULL; QKeyEvent* keyEvent = NULL; QByteArray byteArray; QBuffer buffer(&byteArray); buffer.open(QIODevice::ReadWrite); QDataStream out(&buffer); out << (int) ev->type(); switch (ev->type()) { case QEvent::MouseMove: case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::MouseButtonRelease: if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica()) return false; mouseEvent = (static_cast<QMouseEvent*>(ev)); out << mouseEvent->pos() << mouseEvent->globalPos() << (int) mouseEvent->button() << (int) mouseEvent->buttons() << (int) mouseEvent->modifiers(); OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray); break; case QEvent::Wheel: if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica()) return false;; wheelEvent = (static_cast<QWheelEvent*>(ev)); out << wheelEvent->pos() << wheelEvent->globalPos() << wheelEvent->delta() << (int) wheelEvent->buttons() << (int) wheelEvent->modifiers() << (int) wheelEvent->orientation(); OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray); break; case QEvent::KeyPress: case QEvent::KeyRelease: if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica()) return false; keyEvent = (static_cast<QKeyEvent*>(ev)); out << keyEvent->key() << (int) keyEvent->modifiers() << keyEvent->text() << keyEvent->isAutoRepeat() << (int) keyEvent->count(); OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray); break; default: break; } return QWebPage::event(ev); }
bool GraphView::eventFilter(QObject *obj, QEvent *event) { bool result(true); if (currentNode && event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); QPointF mousePos = mapToScene(mouseEvent->pos()); currentNode->setVisible(true); currentNode->setCenter(mousePos); scene()->update(); } else if (edgeSource && event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); QPointF mousePos = mapToScene(mouseEvent->pos()); currentEdge->setEndPoint(mousePos); scene()->update(); } else result = QObject::eventFilter(obj, event); return result; }
bool TagConverter::eventFilter(QObject *obj, QEvent *event) { // Close this popup when one is clicking outside this Dialog (otherwise this widget stays on top) if (obj == this && event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (!rect().contains(mouseEvent->pos())) { this->setVisible(false); _convertButton->setChecked(false); return true; } } return QDialog::eventFilter(obj, event); }
bool SceneInspectorWidget::eventFilter(QObject *obj, QEvent *event) { Q_ASSERT(obj == ui->graphicsSceneView->view()->viewport()); if (event->type() == QEvent::Resize) { QMetaObject::invokeMethod(this, "visibleSceneRectChanged", Qt::QueuedConnection); } else if (event->type() == QEvent::MouseButtonRelease) { QMouseEvent *e = static_cast<QMouseEvent *>(event); if (e->button() == Qt::LeftButton && e->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) m_interface->sceneClicked(ui->graphicsSceneView->view()->mapToScene(e->pos())); } return QObject::eventFilter(obj, event); }
void KisShowPaletteAction::begin(int, QEvent *event) { QPoint pos; QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event); if (mouseEvent) { pos = mouseEvent->pos(); } else { pos = inputManager()->canvas()->canvasWidget()->mapFromGlobal(QCursor::pos()); } inputManager()->canvas()->slotShowPopupPalette(pos); }
void CPrivateInfo::mousePressEvent(QMouseEvent * ev) { QMouseEvent *mv = (QMouseEvent*) ev; if(mv->buttons() & Qt::LeftButton) { QRect labelrect = QRect(ui->lb_top->pos() + this->pos(), ui->lb_top->size()); if(labelrect.contains(mv->globalPos())) { m_Ptbefore = mv->globalPos(); m_Ptcur = mv->pos(); } } }
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))); } }
QGestureRecognizer::Result MyGestureRecognizer ::recognize(QGesture *state, QObject *, QEvent *event) { MyGesture* gesture = dynamic_cast<MyGesture*>(state); if(!gesture) { return QGestureRecognizer::CancelGesture; } if(QEvent::MouseButtonPress == event->type()) { QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); if(mouseEvent) { gesture->position = mouseEvent->pos(); return QGestureRecognizer::MayBeGesture; } } if(QEvent::MouseButtonRelease == event->type()) { QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); if(mouseEvent) { gesture->distance = gesture->position.x() - mouseEvent->pos().x(); if(100 <= qAbs(gesture->distance)) { return QGestureRecognizer::FinishGesture; } } } return QGestureRecognizer::CancelGesture; }
void PreviewPlot2D::onVZoom(const QMouseEvent& e) { // some shortcuts int axb= QwtPlot::xBottom; // Don't invert any scales which aren't inverted int x1 = qwtMin(memPoint.x(), e.pos().x()); int x2 = qwtMax(memPoint.x(), e.pos().x()); // limit selected area to a minimum of 11x11 points int lim = 5 - (x2 - x1 + 1) / 2; if (lim > 0) { x1 -= lim; x2 += lim; } // Set fixed scales if(!autoscaleX) pPlot->setAxisScale(axb, pPlot->invTransform(axb,x1), pPlot->invTransform(axb,x2)); pPlot->replot(); }
bool AsemanMouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *e) { QMouseEvent *mevent = static_cast<QMouseEvent*>(e); switch(static_cast<int>(e->type())) { case QEvent::MouseMove: { QPointF newP = mapFromItem(item, mevent->pos()); bool xChanged = (newP.x() != p->point.x()); bool yChanged = (newP.y() != p->point.y()); p->point = newP; if(xChanged) Q_EMIT mouseXChanged(); if(yChanged) Q_EMIT mouseYChanged(); Q_EMIT mousePositionChanged(); break; } case QEvent::MouseButtonPress: p->point = mapFromItem(item, mevent->pos()); Q_EMIT mousePressed(); break; case QEvent::MouseButtonRelease: p->point = mapFromItem(item, mevent->pos()); Q_EMIT mouseReleased(); break; default: p->ignoreEvent = false; break; } if(p->ignoreEvent) { p->ignoreEvent = false; return true; } else return QQuickItem::childMouseEventFilter(item, e); }
/* Checks for a focus out event. The display of the date is updated * to display the proper date when the focus leaves. */ bool AnnotationDialog::KDateEdit::eventFilter(QObject *obj, QEvent *e) { if (obj == lineEdit()) { if (e->type() == QEvent::Wheel) { // Up and down arrow keys step the date QWheelEvent* we = dynamic_cast<QWheelEvent*>(e); Q_ASSERT( we != nullptr ); int step = 0; step = we->delta() > 0 ? 1 : -1; if (we->orientation() == Qt::Vertical) { setDate( value.addDays(step) ); } } } else { // It's a date picker event switch (e->type()) { case QEvent::MouseButtonDblClick: case QEvent::MouseButtonPress: { QMouseEvent *me = (QMouseEvent*)e; if (!mDateFrame->rect().contains(me->pos())) { QPoint globalPos = mDateFrame->mapToGlobal(me->pos()); if (QApplication::widgetAt(globalPos) == this) { // The date picker is being closed by a click on the // KDateEdit widget. Avoid popping it up again immediately. mDiscardNextMousePress = true; } } break; } default: break; } } return false; }
bool ItemWidget::filterMouseEvents(QTextEdit *edit, QEvent *event) { QEvent::Type type = event->type(); switch (type) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: { QMouseEvent *e = static_cast<QMouseEvent*>(event); if ( !canMouseInteract(*e) ) e->ignore(); else if (e->button() == Qt::LeftButton) edit->setTextCursor( edit->cursorForPosition(e->pos()) ); break; } case QEvent::MouseMove: { QMouseEvent *e = static_cast<QMouseEvent*>(event); if ( !canMouseInteract(*e) ) e->ignore(); break; } case QEvent::MouseButtonRelease: { QMouseEvent *e = static_cast<QMouseEvent*>(event); if ( canMouseInteract(*e) && edit->textCursor().hasSelection() ) edit->copy(); e->ignore(); break; } default: return false; } Qt::TextInteractionFlags flags = edit->textInteractionFlags(); if (event->isAccepted()) flags |= Qt::TextSelectableByMouse; else flags &= ~Qt::TextSelectableByMouse; edit->setTextInteractionFlags(flags); return false; }
void UXInfoPlugin::processEvent(QObject *obj, QEvent *e) { QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e); QWidget *widget = dynamic_cast<QWidget*>(obj); QPoint pos; if (mouseEvent && widget && mouseEvent->type() == QMouseEvent::MouseButtonPress) { pos = widget->pos(); for (; widget; widget = dynamic_cast<QWidget*>(widget->parent())) { pos += widget->pos(); } UXInfo::reportMouseClick(mouseEvent->pos() + pos); } }
bool editDelegate::editorEvent(QEvent *event, QAbstractItemModel*, const QStyleOptionViewItem &option, const QModelIndex &index) { // Emit a signal when the icon is clicked if(event->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if(option.rect.contains(mouseEvent->pos())) { emit plusClicked(index.row()); } } return false; }
bool BookmarksComboBoxWidget::eventFilter(QObject *object, QEvent *event) { if (object == m_view->viewport() && event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event); if (mouseEvent) { m_index = m_view->indexAt(mouseEvent->pos()); } } return QComboBox::eventFilter(object, event); }
bool Pick::handleEvent(QObject * receiver, QEvent * event) { if (!m_handler) { return false; } if (event->type() == QEvent::MouseButtonPress) { QMouseEvent * evt = static_cast<QMouseEvent *>(event); if (evt->modifiers() & Qt::ShiftModifier && evt->modifiers() & Qt::ControlModifier) { m_handler->handle(receiver, evt->pos()); return true; } } return false; }
bool Manual::eventFilter(QObject *obj, QEvent *evt) { if ((evt->type() == QEvent::MouseButtonPress) || (evt->type() == QEvent::MouseMove)) { QMouseEvent *qme = dynamic_cast<QMouseEvent *>(evt); if (qme) { if (qme->buttons() & Qt::LeftButton) { QPointF qpf = qgvPosition->mapToScene(qme->pos()); qdsbX->setValue(-qpf.x()); qdsbZ->setValue(-qpf.y()); qgiPosition->setPos(qpf); } } } return QDialog::eventFilter(obj, evt); }
bool calibrationtestwidget::eventFilter ( QObject * watched, QEvent * event ){ if(watched!=frame) return false; if(event->type()==QEvent::MouseButtonPress){ QMouseEvent *mevent = static_cast<QMouseEvent *>(event); if(mevent->button() ==Qt::LeftButton){ oldpoint = mevent->pos(); paintpath.moveTo(oldpoint.x(),oldpoint.y()); candrawline = TRUE; return TRUE; } } if(candrawline&&(event->type()==QEvent::MouseMove)){ QMouseEvent *mevent = static_cast<QMouseEvent *>(event); if(mevent->buttons() ==Qt::LeftButton){ newpoint = mevent->pos(); frame->update(); return TRUE; } } if(event->type()==QEvent::MouseButtonRelease){ QMouseEvent *mevent = static_cast<QMouseEvent *>(event); if(mevent->buttons() ==Qt::LeftButton){ candrawline = FALSE; return TRUE; } } if(event->type()==QEvent::Paint){ //QPaintEvent *pevent = static_cast<QPaintEvent *>(event); QPainter painter(frame); //painter.setClipRect(oldpoint.x(),oldpoint.y(),newpoint.x(),newpoint.y()); paintpath.lineTo(newpoint); painter.drawPath(paintpath); return FALSE; } return FALSE; }
bool WindowManager::mousePressEvent(QObject *object, QEvent *event) { // cast event and check buttons/modifiers QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (!(Qt::NoModifier==mouseEvent->modifiers() && Qt::LeftButton==mouseEvent->button())) { return false; } // check lock if (isLocked()) { return false; } else { setLocked(true); } // cast to widget QWidget *widget = static_cast<QWidget*>(object); // check if widget can be dragged from current position if (isBlackListed(widget) || !canDrag(widget)) { return false; } // retrieve widget's child at event position QPoint position(mouseEvent->pos()); QWidget *child = widget->childAt(position); if (!canDrag(widget, child, position)) { return false; } // save target and drag point _target = widget; _dragPoint = position; _globalDragPoint = mouseEvent->globalPos(); _dragAboutToStart = true; // send a move event to the current child with same position // if received, it is caught to actually start the drag QPoint localPoint(_dragPoint); if (child) { localPoint = child->mapFrom(widget, localPoint); } else { child = widget; } QMouseEvent localMouseEvent(QEvent::MouseMove, localPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); qApp->sendEvent(child, &localMouseEvent); // never eat event return false; }
bool AccountView::eventFilter(QObject *obj, QEvent *event) { if (obj == account_menu_ && event->type() == QEvent::MouseButtonRelease) { QMouseEvent *ev = (QMouseEvent*)event; QAction *action = account_menu_->actionAt(ev->pos()); if (action) { action->trigger(); } } if (obj == mAccountBtn && event->type() == QEvent::Paint) { QRect rect(0, 0, AvatarService::kAvatarSize, AvatarService::kAvatarSize); QPainter painter(mAccountBtn); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing); // get the device pixel radio from current painter device int scale_factor = 1; #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) scale_factor = painter.device()->devicePixelRatio(); #endif // QT5 QPixmap image(mAccountBtn->icon().pixmap(rect.size()).scaled(scale_factor * rect.size())); QRect actualRect(QPoint(0, 0), image.size()); QImage masked_image(actualRect.size(), QImage::Format_ARGB32_Premultiplied); masked_image.fill(Qt::transparent); QPainter mask_painter; mask_painter.begin(&masked_image); mask_painter.setRenderHint(QPainter::Antialiasing); mask_painter.setRenderHint(QPainter::HighQualityAntialiasing); mask_painter.setCompositionMode(QPainter::CompositionMode_SourceOver); mask_painter.setPen(Qt::NoPen); mask_painter.setBrush(Qt::white); mask_painter.drawEllipse(actualRect); mask_painter.setCompositionMode(QPainter::CompositionMode_SourceIn); mask_painter.drawPixmap(actualRect, image); mask_painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); mask_painter.fillRect(actualRect, Qt::transparent); mask_painter.end(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) masked_image.setDevicePixelRatio(scale_factor); #endif // QT5 painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.drawImage(QPoint(0,0), masked_image); return true; } return QObject::eventFilter(obj, event); }
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); }
bool MainWindow::eventFilter(QObject *object, QEvent *event) { if (object == m_tabBar && event->type() == QEvent::MouseButtonRelease) { QMouseEvent *e = reinterpret_cast<QMouseEvent *>(event); if (e->button() == Qt::MiddleButton) { const int index = m_tabBar->tabAt(e->pos()); if (index >= 0) { closeTab(index); return true; } } } return QMainWindow::eventFilter(object, event); }
virtual bool eventFilter( QObject * obj, QEvent * e ) { if ( obj != titleLabel && obj != authorLabel && obj != dateLabel ) return false; QMouseEvent * me = 0; switch ( e->type() ) { case QEvent::MouseButtonPress: me = (QMouseEvent*)e; mousePressPos = me->pos(); break; case QEvent::MouseButtonRelease: mousePressPos = QPoint(); break; case QEvent::MouseMove: me = (QMouseEvent*)e; parentWidget()->move( me->pos() - mousePressPos + parentWidget()->pos() ); break; default: return false; } return true; }
bool Nepomuk::AnnotationDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ) { if ( event->type() == QEvent::MouseButtonPress ) { QMouseEvent* me = static_cast<QMouseEvent*>( event ); if ( me->button() == Qt::LeftButton ) { if ( plusRect( option ).contains( me->pos() ) ) { kDebug() << "Clicked plus"; Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>(); anno->create( d->resource ); delete anno; return true; } else if ( minusRect( option ).contains( me->pos() ) ) { kDebug() << "Clicked minus"; Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>(); anno->setUserRelevance( 0.0 ); delete anno; return true; } } } return false; }
bool TabBar::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (tabAt(mouseEvent->pos()) < 0) return false; if (mouseEvent->button() & Qt::MiddleButton) { emit closeTab(tabAt(mouseEvent->pos())); } else if (mouseEvent->button() & Qt::LeftButton) { if (tabAt(QPoint(mouseEvent->pos().x(), 0)) == 0) tabFixed_ = true; else tabFixed_ = false; } } else if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->buttons() & Qt::LeftButton) { if ((tabAt(QPoint(mouseEvent->pos().x()-78, 0)) <= 0) || tabFixed_) return true; } } return QTabBar::eventFilter(obj, event); }
bool KColorCombo2::eventFilter(QObject */*object*/, QEvent *event) { QMouseEvent *mouseEvent; switch (event->type()) { case QEvent::MouseButtonDblClick: case QEvent::MouseButtonPress: mouseEvent = (QMouseEvent*)event; if ( !m_popup->rect().contains(mouseEvent->pos()) ) { QPoint globalPos = m_popup->mapToGlobal(mouseEvent->pos()); if (QApplication::widgetAt(globalPos, /*child=*/true) == this) { // The popup is being closed by a click on the KColorCombo2 widget. // Avoid popping it up again immediately: m_discardNextMousePress = true; } } break; default: break; } // Don't stop the event being handled further: return false; }
bool FlexHelperImplMac::eventFilter(QObject* obj, QEvent* evt) { auto widget = qobject_cast<QWidget*>(obj); switch (evt->type()) { case QEvent::WindowStateChange: { auto state = widget->windowState(); if (state & Qt::WindowMaximized) { _buttons->maxButton()->setButton(Flex::Restore); _buttons->maxButton()->setToolTip(QWidget::tr("Restore")); } else { _buttons->maxButton()->setToolTip(QWidget::tr("Maximize")); _buttons->maxButton()->setButton(Flex::Maximize); } break; } case QEvent::MouseButtonPress: { if (widget->isMaximized()) { break; } QMouseEvent* event = static_cast<QMouseEvent*>(evt); if (event->button() == Qt::LeftButton) { hittest(widget, event->pos()); if (_hit >= 0) { widget->grabKeyboard(); if (_hit == 0) { _moving = true; QMetaObject::invokeMethod(widget, "enterMove", Q_ARG(QObject*, widget)); } _old = event->globalPos(); } }