Commit c8ecde24 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

Titler: add keyboard modifiers to limit itme movement on one axis

- Shift to keep x axis fixed
- Shift+Alt to keep y axis fixed
parent d391f6d3
Pipeline #83209 canceled with stage
...@@ -400,6 +400,12 @@ QVariant MyTextItem::itemChange(GraphicsItemChange change, const QVariant &value ...@@ -400,6 +400,12 @@ QVariant MyTextItem::itemChange(GraphicsItemChange change, const QVariant &value
int gridSize = customScene->gridSize(); int gridSize = customScene->gridSize();
int xV = (newPos.x() / gridSize) * gridSize; int xV = (newPos.x() / gridSize) * gridSize;
int yV = (newPos.y() / gridSize) * gridSize; int yV = (newPos.y() / gridSize) * gridSize;
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
xV = pos().x();
}
if (QApplication::keyboardModifiers() == (Qt::ShiftModifier | Qt::AltModifier)) {
yV = pos().y();
}
newPos = QPoint(xV, yV); newPos = QPoint(xV, yV);
} }
return newPos; return newPos;
...@@ -464,6 +470,12 @@ QVariant MyRectItem::itemChange(GraphicsItemChange change, const QVariant &value ...@@ -464,6 +470,12 @@ QVariant MyRectItem::itemChange(GraphicsItemChange change, const QVariant &value
int gridSize = customScene->gridSize(); int gridSize = customScene->gridSize();
int xV = (newPos.x() / gridSize) * gridSize; int xV = (newPos.x() / gridSize) * gridSize;
int yV = (newPos.y() / gridSize) * gridSize; int yV = (newPos.y() / gridSize) * gridSize;
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
xV = pos().x();
}
if (QApplication::keyboardModifiers() == (Qt::ShiftModifier | Qt::AltModifier)) {
yV = pos().y();
}
newPos = QPoint(xV, yV); newPos = QPoint(xV, yV);
} }
return newPos; return newPos;
...@@ -498,6 +510,12 @@ QVariant MyEllipseItem::itemChange(GraphicsItemChange change, const QVariant &va ...@@ -498,6 +510,12 @@ QVariant MyEllipseItem::itemChange(GraphicsItemChange change, const QVariant &va
int gridSize = customScene->gridSize(); int gridSize = customScene->gridSize();
int xV = (newPos.x() / gridSize) * gridSize; int xV = (newPos.x() / gridSize) * gridSize;
int yV = (newPos.y() / gridSize) * gridSize; int yV = (newPos.y() / gridSize) * gridSize;
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
xV = pos().x();
}
if (QApplication::keyboardModifiers() == (Qt::ShiftModifier | Qt::AltModifier)) {
yV = pos().y();
}
newPos = QPoint(xV, yV); newPos = QPoint(xV, yV);
} }
return newPos; return newPos;
...@@ -522,6 +540,12 @@ QVariant MyPixmapItem::itemChange(GraphicsItemChange change, const QVariant &val ...@@ -522,6 +540,12 @@ QVariant MyPixmapItem::itemChange(GraphicsItemChange change, const QVariant &val
int gridSize = customScene->gridSize(); int gridSize = customScene->gridSize();
int xV = (newPos.x() / gridSize) * gridSize; int xV = (newPos.x() / gridSize) * gridSize;
int yV = (newPos.y() / gridSize) * gridSize; int yV = (newPos.y() / gridSize) * gridSize;
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
xV = pos().x();
}
if (QApplication::keyboardModifiers() == (Qt::ShiftModifier | Qt::AltModifier)) {
yV = pos().y();
}
newPos = QPoint(xV, yV); newPos = QPoint(xV, yV);
} }
return newPos; return newPos;
...@@ -546,6 +570,12 @@ QVariant MySvgItem::itemChange(GraphicsItemChange change, const QVariant &value) ...@@ -546,6 +570,12 @@ QVariant MySvgItem::itemChange(GraphicsItemChange change, const QVariant &value)
int gridSize = customScene->gridSize(); int gridSize = customScene->gridSize();
int xV = (newPos.x() / gridSize) * gridSize; int xV = (newPos.x() / gridSize) * gridSize;
int yV = (newPos.y() / gridSize) * gridSize; int yV = (newPos.y() / gridSize) * gridSize;
if (QApplication::keyboardModifiers() == Qt::ShiftModifier) {
xV = pos().x();
}
if (QApplication::keyboardModifiers() == (Qt::ShiftModifier | Qt::AltModifier)) {
yV = pos().y();
}
newPos = QPoint(xV, yV); newPos = QPoint(xV, yV);
} }
return newPos; return newPos;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment