Merge pull request #1180 from Kellermorph/plc-place

Element editor: save the moved position of the PLC table
This commit is contained in:
Laurent Trinques
2026-10-01 08:13:11 +02:00
committed by GitHub
+7 -2
View File
@@ -370,8 +370,13 @@ void PartPlcTable::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
const QDomElement PartPlcTable::toXml(QDomDocument &xml_document) const
{
QDomElement xml_element = xml_document.createElement("plc_table");
qreal x = qRound(m_rect.x() * 100.0) / 100.0;
qreal y = qRound(m_rect.y() * 100.0) / 100.0;
//The move of this part lives in pos(), not in m_rect (which always
//starts at the item origin), so the scene coordinates must be written
//here, exactly like every other part does (see PartRectangle::toXml).
//Otherwise the position is silently reset to (0, 0) on the next load.
const QPointF top_left = mapToScene(m_rect.topLeft());
qreal x = qRound(top_left.x() * 100.0) / 100.0;
qreal y = qRound(top_left.y() * 100.0) / 100.0;
xml_element.setAttribute("x", QString::number(x));
xml_element.setAttribute("y", QString::number(y));