QmlDesigner: Fix flow editors decision items selection area

Decision item must only be selectable from the item, not the label text. Text can
overlap with other items and selection becomes unnatural if it is included
in selection bounding rectangle.

Task-number: QDS-3747
Change-Id: Ic5697f124cd0210f6af00b3c004ea19d0af2cd91
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tuomo Pelkonen
2021-02-23 12:20:22 +02:00
parent 29307b7b15
commit dab168fa81

View File

@@ -2015,6 +2015,7 @@ void FormEditorFlowDecisionItem::updateGeometry()
size = qmlItemNode().modelNode().auxiliaryData("blockSize").toInt();
QRectF boundingRect(0, 0, size, size);
QRectF selectionRect = boundingRect;
QTransform transform;
if (qmlItemNode().isFlowDecision()) {
transform.translate(boundingRect.center().x(), boundingRect.center().y());
@@ -2073,14 +2074,15 @@ void FormEditorFlowDecisionItem::updateGeometry()
}
}
// Unite the rotate item bounding rect with the label bounding rect.
// bounding rect is combination of label and icon but only icon can be clicked
boundingRect = transform.mapRect(boundingRect);
selectionRect = boundingRect;
boundingRect = boundingRect.united(labelBoundingRect);
}
m_selectionBoundingRect = boundingRect;
m_paintedBoundingRect = m_selectionBoundingRect;
m_boundingRect = m_paintedBoundingRect;
m_selectionBoundingRect = selectionRect;
m_boundingRect = boundingRect;
m_paintedBoundingRect = boundingRect;
setTransform(qmlItemNode().instanceTransformWithContentTransform());
const QPointF pos = qmlItemNode().flowPosition();
setTransform(QTransform::fromTranslate(pos.x(), pos.y()));