QmlDesigner: Paint indicator for start in flow

Change-Id: I1db165489e89bed1db22433b961caff080b87305
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2020-03-24 16:55:50 +01:00
parent 0e2144135c
commit 03aed15fe9

View File

@@ -924,14 +924,29 @@ void FormEditorTransitionItem::paint(QPainter *painter, const QStyleOptionGraphi
QmlFlowActionAreaNode areaNode = ModelNode();
if (from.isValid() && to.isValid())
bool isStartLine = false;
for (const QmlFlowActionAreaNode &area : from.flowActionAreas()) {
if (area.targetTransition() == qmlItemNode().modelNode())
areaNode = area;
}
} else {
if (from == qmlItemNode().rootModelNode()) {
isStartLine = true;
} else {
}
}
QRectF fromRect = QmlItemNode(from).instanceBoundingRect();
fromRect.translate(QmlItemNode(from).flowPosition());
if (isStartLine) {
fromRect = QRectF(0,0,100,100);
fromRect.translate(QmlItemNode(to).flowPosition()- QPoint(200, 0));
}
if (areaNode.isValid()) {
fromRect = QmlItemNode(areaNode).instanceBoundingRect();
@@ -942,6 +957,11 @@ void FormEditorTransitionItem::paint(QPainter *painter, const QStyleOptionGraphi
QRectF toRect = QmlItemNode(to).instanceBoundingRect();
toRect.translate(QmlItemNode(to).flowPosition());
if (isStartLine) {
fromRect = QRectF(0,0,50,50);
fromRect.translate(QmlItemNode(to).flowPosition() + QPoint(-120, toRect.height() / 2 - 25));
}
toRect.translate(-pos());
fromRect.translate(-pos());
@@ -961,6 +981,9 @@ void FormEditorTransitionItem::paint(QPainter *painter, const QStyleOptionGraphi
QColor color = "#e71919";
if (isStartLine)
color = "blue";
bool dash = false;
if (qmlItemNode().modelNode().hasAuxiliaryData("color"))
@@ -985,6 +1008,23 @@ void FormEditorTransitionItem::paint(QPainter *painter, const QStyleOptionGraphi
paintConnection(painter, fromRect, toRect, width, adjustedWidth ,color, dash, outOffset, inOffset, breakOffset);
if (isStartLine) {
QPen pen;
pen.setCosmetic(true);
pen.setColor(color);
painter->setPen(pen);
painter->drawRect(fromRect);
if (scaleFactor > 0.4) {
painter->drawLine(fromRect.topRight() + QPoint(20,10), fromRect.bottomRight() + QPoint(20,-10));
painter->drawLine(fromRect.topRight() + QPoint(25,12), fromRect.bottomRight() + QPoint(25,-12));
painter->drawLine(fromRect.topRight() + QPoint(30,15), fromRect.bottomRight() + QPoint(30,-15));
painter->drawLine(fromRect.topRight() + QPoint(35,17), fromRect.bottomRight() + QPoint(35,-17));
painter->drawLine(fromRect.topRight() + QPoint(40,20), fromRect.bottomRight() + QPoint(40,-20));
}
}
painter->restore();
}