diff options
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 4 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsproxywidget.cpp | 15 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsscene.cpp | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview.cpp | 13 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget_p.cpp | 4 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget_p.h | 3 |
6 files changed, 23 insertions, 18 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 65708fa1ca..ca30c72db5 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -449,8 +449,8 @@ \value ItemSendsGeometryChanges The item enables itemChange() notifications for ItemPositionChange, ItemPositionHasChanged, - ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, - ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, + ItemTransformChange, ItemTransformHasChanged, ItemRotationChange, + ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For performance reasons, these notifications are disabled by default. You must enable this flag to receive notifications for position and transform diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index f1b01fbb4d..2b6712075f 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -697,9 +697,7 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto if (!newWidget->testAttribute(Qt::WA_Resized)) newWidget->adjustSize(); - int left, top, right, bottom; - newWidget->getContentsMargins(&left, &top, &right, &bottom); - q->setContentsMargins(left, top, right, bottom); + q->setContentsMargins(newWidget->contentsMargins()); q->setWindowTitle(newWidget->windowTitle()); // size policies and constraints.. @@ -1293,8 +1291,15 @@ void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) pos = d->mapToReceiver(pos, receiver); // Send mouse event. - QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(), - event->buttons(), event->modifiers(), event->orientation()); + QPoint angleDelta; + if (event->orientation() == Qt::Horizontal) + angleDelta.setX(event->delta()); + else + angleDelta.setY(event->delta()); + // pixelDelta, inverted, scrollPhase and source from the original QWheelEvent + // were not preserved in the QGraphicsSceneWheelEvent unfortunately + QWheelEvent wheelEvent(pos, event->screenPos(), QPoint(), angleDelta, + event->buttons(), event->modifiers(), Qt::NoScrollPhase, false); QPointer<QWidget> focusWidget = d->widget->focusWidget(); extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); qt_sendSpontaneousEvent(receiver, &wheelEvent); diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 2cdbdc2072..313939e638 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -2805,7 +2805,7 @@ QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon, Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the - origin in the items coordinate system. + origin in the item's coordinate system. If the item is visible (i.e., QGraphicsItem::isVisible() returns \c true), QGraphicsScene will emit changed() once control goes back to the event diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 3ec9668cde..7f14218720 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -691,7 +691,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) } // Find the topmost item under the mouse with a cursor. foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) { - if (item->hasCursor()) { + if (item->isEnabled() && item->hasCursor()) { _q_setViewportCursor(item->cursor()); return; } @@ -808,7 +808,7 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor() Q_Q(QGraphicsView); const auto items = q->items(lastMouseEvent.pos()); for (QGraphicsItem *item : items) { - if (item->hasCursor()) { + if (item->isEnabled() && item->hasCursor()) { _q_setViewportCursor(item->cursor()); return; } @@ -3426,12 +3426,13 @@ void QGraphicsView::wheelEvent(QWheelEvent *event) QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel); wheelEvent.setWidget(viewport()); - wheelEvent.setScenePos(mapToScene(event->pos())); - wheelEvent.setScreenPos(event->globalPos()); + wheelEvent.setScenePos(mapToScene(event->position().toPoint())); + wheelEvent.setScreenPos(event->globalPosition().toPoint()); wheelEvent.setButtons(event->buttons()); wheelEvent.setModifiers(event->modifiers()); - wheelEvent.setDelta(event->delta()); - wheelEvent.setOrientation(event->orientation()); + const bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()); + wheelEvent.setDelta(horizontal ? event->angleDelta().x() : event->angleDelta().y()); + wheelEvent.setOrientation(horizontal ? Qt::Horizontal : Qt::Vertical); wheelEvent.setAccepted(false); QCoreApplication::sendEvent(d->scene, &wheelEvent); event->setAccepted(wheelEvent.isAccepted()); diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index cc08b1c566..fd47f444ea 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -110,8 +110,6 @@ QGraphicsWidgetPrivate::QGraphicsWidgetPrivate() QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate() { - // Remove any lazily allocated data - delete windowData; } /*! @@ -147,7 +145,7 @@ void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const void QGraphicsWidgetPrivate::ensureWindowData() { if (!windowData) - windowData = new WindowData; + windowData = qt_make_unique<WindowData>(); } void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette) diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h index 5e0fdb693b..e4cc2c3016 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.h +++ b/src/widgets/graphicsview/qgraphicswidget_p.h @@ -190,7 +190,8 @@ public: , buttonMouseOver(false) , buttonSunken(false) {} - } *windowData; + }; + std::unique_ptr<WindowData> windowData; void ensureWindowData(); bool setWindowFrameMargins; |