Add position-lock checkbox to element properties (issue #801)

Elements already inherited QetGraphicsItem::isMovable()/setMovable() --
the same mechanism images and drawn shapes use for their "lock position"
checkbox -- but nothing exposed it in the element properties panel, and
Element::toXml()/fromXml() never persisted it.

- ElementPropertiesWidget::generalWidget(): add a "Verrouiller la
  position" checkbox mirroring ShapeGraphicsItemPropertiesWidget's
  m_lock_pos_cb, toggling the element's inherited setMovable().
- Element::toXml()/fromXml(): persist is_movable, same attribute name
  and default-true behavior as DiagramImageItem/QetShapeItem.

Verified via headless --resave round-trip: is_movable="0" survives
load -> save unchanged, existing elements without the attribute default
to movable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HdWpDp3TrPKbHnv7YUcNJj
This commit is contained in:
ispyisail
2026-09-01 07:16:32 +12:00
parent 899f10533d
commit c69e5747a1
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -30,6 +30,7 @@
#include "masterpropertieswidget.h"
#include "plclinkwidget.h"
#include <QCheckBox>
#include <QLabel>
#include <QUndoStack>
#include <QVBoxLayout>
@@ -396,6 +397,18 @@ QWidget *ElementPropertiesWidget::generalWidget()
label->setTextInteractionFlags(Qt::TextEditorInteraction);
vlayout_->addWidget(label);
//checkbox to lock the element position on the diagram
//(same mechanism already used by images and drawn shapes)
QCheckBox *lock_pos_cb = new QCheckBox(tr("Verrouiller la position"), general_widget);
lock_pos_cb->setChecked(!m_element->isMovable());
QPointer<Element> element = m_element;
connect(lock_pos_cb, &QCheckBox::clicked, this, [element](bool checked) {
if (element) {
element->setMovable(!checked);
}
});
vlayout_->addWidget(lock_pos_cb);
//widget for the pixmap
QLabel *pix = new QLabel(general_widget);
vlayout_->addWidget(pix, 0, Qt::AlignHCenter);