diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index 8f9a70186..1af1ba677 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -754,27 +754,56 @@ void QuarterWidget::paintEvent(QPaintEvent* event) } bool QuarterWidget::viewportEvent(QEvent* event) -{ - if( event->type() == QEvent::Paint || event->type() == QEvent::Resize) { +{ + //TODO: After 0.16 is out activate the code below. +#if 1 + if (event->type() == QEvent::Paint || event->type() == QEvent::Resize) { + return QGraphicsView::viewportEvent(event); + } + else if (event->type() == QEvent::MouseMove || + event->type() == QEvent::Wheel || + event->type() == QEvent::MouseButtonDblClick || + event->type() == QEvent::MouseButtonRelease || + event->type() == QEvent::MouseButtonPress) { + QMouseEvent* mouse = static_cast(event); + QGraphicsItem *item = itemAt(mouse->pos()); + if (!item) { + return false; + } + return QGraphicsView::viewportEvent(event); - } - else if(event->type() == QEvent::MouseMove - || event->type() == QEvent::Wheel - || event->type() == QEvent::MouseButtonDblClick - || event->type() == QEvent::MouseButtonRelease - || event->type() == QEvent::MouseButtonPress) { - - QMouseEvent* mouse = static_cast(event); - QGraphicsItem *item = itemAt(mouse->pos()); - if(!item) { - return false; - } - return QGraphicsView::viewportEvent(event); } + //if we return false the events get processed normally, this means they get passed to the quarter //event filters for processing in the scene graph. If we return true event processing stops here. return false; - +#else + // If no item is selected still let the graphics scene handle it but + // additionally handle it by this viewer. This is e.g. needed when + // resizing a widget item because the cursor may already be outside + // this widget. + if (event->type() == QEvent::Wheel || + event->type() == QEvent::MouseButtonDblClick || + event->type() == QEvent::MouseButtonPress) { + QMouseEvent* mouse = static_cast(event); + QGraphicsItem *item = itemAt(mouse->pos()); + if (!item) { + QGraphicsView::viewportEvent(event); + return false; + } + } + else if (event->type() == QEvent::MouseMove || + event->type() == QEvent::MouseButtonRelease) { + QMouseEvent* mouse = static_cast(event); + QGraphicsScene* glScene = this->scene(); + if (!(glScene && glScene->mouseGrabberItem())) { + QGraphicsView::viewportEvent(event); + return false; + } + } + + return QGraphicsView::viewportEvent(event); +#endif } /*! diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index ff9915d47..0e2b4a515 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2530,10 +2530,17 @@ void View3DInventorViewer::setCursorRepresentation(int modearg) // won't be changed as long as the user doesn't leave and enter // the canvas. To fix this we explicitly set Qt::WA_UnderMouse // if the mouse is inside the canvas. - QWidget* w = this->getGLWidget(); + QWidget* glWindow = this->getGLWidget(); - if (w && w->rect().contains(QCursor::pos())) - w->setAttribute(Qt::WA_UnderMouse); + // When a widget is added to the QGraphicsScene and the user + // hovered over it the 'WA_SetCursor' attribute is set to the + // GL widget but never reset and thus would cause that the + // cursor on this widget won't be set. + if (glWindow) + glWindow->setAttribute(Qt::WA_SetCursor, false); + + if (glWindow && glWindow->rect().contains(QCursor::pos())) + glWindow->setAttribute(Qt::WA_UnderMouse); switch (modearg) { case NavigationStyle::IDLE: diff --git a/src/Mod/Sandbox/Gui/GLGraphicsView.cpp b/src/Mod/Sandbox/Gui/GLGraphicsView.cpp index ff0d01bdb..3dd3a2efc 100644 --- a/src/Mod/Sandbox/Gui/GLGraphicsView.cpp +++ b/src/Mod/Sandbox/Gui/GLGraphicsView.cpp @@ -111,6 +111,21 @@ void GraphicsView::resizeEvent(QResizeEvent *event) QGraphicsView::resizeEvent(event); } + +//QDialog *dialog = new QDialog(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); + +////dialog->setWindowOpacity(0.8); +//dialog->setWindowTitle(tr("Titel")); +//dialog->setLayout(new QVBoxLayout); +//dialog->layout()->addWidget(new QLabel(tr("Use mouse wheel to zoom model, and click and drag to rotate model"))); +//dialog->layout()->addWidget(new QLabel(tr("Move the sun around to change the light position"))); +//dialog->layout()->addWidget(new QSpinBox); + +//QGraphicsScene* scene = _viewer->scene(); +//QGraphicsProxyWidget* g1 = scene->addWidget(dialog); +//g1->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); + + // ---------------------------------------------------------------------------- class SceneEventFilter::Private