mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Moving elements by mouse does not respect the grid settings
When moving element by mouse, snapping to grid uses fixed 10 px steps hardcoded in source instead of using the value from grid settings. When moved by keyboard, the grid step is respected. It is due to QPointF Diagram::snapToGrid(const QPointF &p) function not considering the settings. Thanks jethro for this patch
This commit is contained in:
parent
abe5fc3b4e
commit
99064fe2ab
@ -1652,6 +1652,10 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
|
||||
*/
|
||||
QPointF Diagram::snapToGrid(const QPointF &p)
|
||||
{
|
||||
QSettings settings;
|
||||
int xGrid = settings.value("diagrameditor/Xgrid", Diagram::xGrid).toInt();
|
||||
int yGrid = settings.value("diagrameditor/Ygrid", Diagram::yGrid).toInt();
|
||||
|
||||
//Return a point rounded to the nearest pixel
|
||||
if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier))
|
||||
{
|
||||
@ -1661,8 +1665,8 @@ QPointF Diagram::snapToGrid(const QPointF &p)
|
||||
}
|
||||
|
||||
//Return a point snapped to the grid
|
||||
int p_x = qRound(p.x() / Diagram::xGrid) * Diagram::xGrid;
|
||||
int p_y = qRound(p.y() / Diagram::yGrid) * Diagram::yGrid;
|
||||
int p_x = qRound(p.x() / xGrid) * xGrid;
|
||||
int p_y = qRound(p.y() / yGrid) * yGrid;
|
||||
return (QPointF(p_x, p_y));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user