diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index 226380fc4..393d280b9 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -124,6 +124,7 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { if (m_event_interface) { if (m_event_interface -> mouseMoveEvent(e)) { + emit mouseMoved(e -> scenePos()); if (m_event_interface->isFinish()) { delete m_event_interface; m_event_interface = nullptr; @@ -136,6 +137,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) if (!(e -> modifiers() & Qt::ControlModifier)) event_pos = snapToGrid(event_pos); + emit mouseMoved(event_pos); + if (m_behavior == PasteArea) { QRectF current_rect(m_paste_area -> rect()); current_rect.moveCenter(event_pos); diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index f3d77748c..97ec4812a 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -179,6 +179,8 @@ class ElementScene : public QGraphicsScene void elementInfoChanged(); /// Signal emitted when the element type changes void elementTypeChanged(); + /// Signal emitted with the current cursor position (scene coordinates) on every mouse move + void mouseMoved(const QPointF &pos); }; Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions) diff --git a/sources/editor/ui/qetelementeditor.cpp b/sources/editor/ui/qetelementeditor.cpp index ae8f24891..90828fa7e 100644 --- a/sources/editor/ui/qetelementeditor.cpp +++ b/sources/editor/ui/qetelementeditor.cpp @@ -1194,6 +1194,16 @@ void QETElementEditor::initGui() if (te) te->refreshMasterLabelVisibility(); }); + //Live cursor position readout, in the same scene coordinates as the parts' X/Y properties + m_position_label = new QLabel(this); + m_position_label->setMinimumWidth(120); + statusBar()->addPermanentWidget(m_position_label); + connect(m_elmt_scene, &ElementScene::mouseMoved, this, [this](const QPointF &pos) { + m_position_label->setText(tr("X: %1 Y: %2") + .arg(pos.x(), 0, 'f', 1) + .arg(pos.y(), 0, 'f', 1)); + }); + statusBar()->showMessage(tr("Éditeur d'éléments", "status bar message")); } diff --git a/sources/editor/ui/qetelementeditor.h b/sources/editor/ui/qetelementeditor.h index 44b353afb..160986d82 100644 --- a/sources/editor/ui/qetelementeditor.h +++ b/sources/editor/ui/qetelementeditor.h @@ -161,6 +161,8 @@ class QETElementEditor : public QMainWindow QLabel *m_default_informations = nullptr; + QLabel *m_position_label = nullptr; + }; #endif // QETELEMENTEDITOR_H