From f61c75c4542771552f8c732594db06eba74fb1ab Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 Feb 2020 17:00:13 +0100 Subject: [PATCH] QmlDesigner: Make selection indiactor ignore zoom We have to use ItemIgnoresTransformations and calculate the correct position. SelectionIndicator::updateItems() is called when the zoom is changed. Change-Id: Id3e9d643b20c15c831a4e2d8ac72eea15a6b0d1f Reviewed-by: Aleksei German Reviewed-by: Tim Jenssen --- .../components/formeditor/selectionindicator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp b/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp index 437f0e30b19..61dbe75ea32 100644 --- a/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp @@ -139,10 +139,12 @@ void SelectionIndicator::setItems(const QList &itemList) QPointF pos = labelRect.topLeft(); labelRect.moveTo(0, 0); m_labelItem->setPolygon(labelRect); - m_labelItem->setPos(pos + QPointF(0, -labelHeight)); + const int scaledHeight = labelHeight / m_layerItem->viewportTransform().m11(); + m_labelItem->setPos(pos + QPointF(0, -scaledHeight)); const int offset = (labelHeight - textItem->boundingRect().height()) / 2; textItem->setPos(QPointF(toolbar->size().width(), offset)); m_labelItem->setFlag(QGraphicsItem::ItemIsSelectable, false); + m_labelItem->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); QPen pen; pen.setCosmetic(true); pen.setWidth(2); @@ -170,7 +172,8 @@ void SelectionIndicator::updateItems(const QList &itemList) QPolygonF labelPolygon = boundingRectInLayerItemSpaceForItem(selectedItem, m_layerItem.data()); QRectF labelRect = labelPolygon.boundingRect(); QPointF pos = labelRect.topLeft(); - m_labelItem->setPos(pos + QPointF(0, -labelHeight)); + const int scaledHeight = labelHeight / m_layerItem->viewportTransform().m11(); + m_labelItem->setPos(pos + QPointF(0, -scaledHeight)); m_layerItem->update(); } }