Element editor : add a control key for moving by keyboard selected

primitives in 0.1 increments instead of 1
This commit is contained in:
Laurent Trinques
2019-08-26 12:37:58 +02:00
parent 80fd3c75ea
commit 130067ffb2

View File

@@ -110,6 +110,7 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
}
QGraphicsScene::mouseMoveEvent(e);
}
/**
@@ -209,8 +210,23 @@ void ElementScene::keyPressEvent(QKeyEvent *event)
QGraphicsObject *qgo = selectedItems().first()->toGraphicsObject();
if(qgo)
{
QPointF original_pos = qgo->pos();
QPointF p = qgo->pos();
QPointF original_pos = qgo->pos();
QPointF p = qgo->pos();
if (event->modifiers() & Qt::ControlModifier) {
int k = event->key();
if(k == Qt::Key_Right)
p.rx() += 0.1;
else if (k == Qt::Key_Left)
p.rx() -= 0.1;
else if (k == Qt::Key_Up)
p.ry() -= 0.1;
else if (k == Qt::Key_Down)
p.ry() += 0.1;
}
else {
int k = event->key();
if(k == Qt::Key_Right)
p.rx() += 1;
@@ -220,6 +236,7 @@ void ElementScene::keyPressEvent(QKeyEvent *event)
p.ry() -= 1;
else if (k == Qt::Key_Down)
p.ry() += 1;
}
qgo->setPos(p);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(qgo, "pos", QVariant(original_pos), QVariant(p));