View Issue Details

IDProjectCategoryView StatusLast Update
0000187QElectroTechwebsitepublic2021-02-15 00:50
Reporterjethro Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Summary0000187: Moving elements by mouse does not respect the grid settings - fix included
DescriptionWhen moving element by mouse, snapping to grid uses fixed 10 px steps hardcoded in source instead of using the value from 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.
Additional InformationPatch:

diff --git a/sources/diagram.cpp b/sources/diagram.cpp
index 249b632b7..8794bb331 100644
--- a/sources/diagram.cpp
+++ b/sources/diagram.cpp
@@ -1652,7 +1652,11 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
  */
 QPointF Diagram::snapToGrid(const QPointF &p)
 {
-               //Return a point rounded to the nearest pixel
+       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))
        {
                int p_x = qRound(p.x());
@@ -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));
 }

TagsNo tags attached.
Attached Files

Activities

jethro

2020-03-27 11:07

reporter   ~0000414

Patch file.
Copy to/from browser breaks something so the patch is not applicable. This file works.
mouse.patch (1,017 bytes)   
diff --git a/sources/diagram.cpp b/sources/diagram.cpp
index 249b632b7..8794bb331 100644
--- a/sources/diagram.cpp
+++ b/sources/diagram.cpp
@@ -1652,7 +1652,11 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
  */
 QPointF Diagram::snapToGrid(const QPointF &p)
 {
-		//Return a point rounded to the nearest pixel
+	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))
 	{
 		int p_x = qRound(p.x());
@@ -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));
 }
 
mouse.patch (1,017 bytes)   

scorpio810_mantis

2020-03-27 21:23

administrator   ~0000415

Last edited: 2020-03-27 21:24

Merged, thanks jethro.
https://git.tuxfamily.org/qet/qet.git/commit/?id=99064fe2ab32ed97a6e29bedfbe0ddb9dc893c8f

Issue History

Date Modified Username Field Change
2020-03-27 10:48 jethro New Issue
2020-03-27 10:49 jethro Description Updated
2020-03-27 10:49 jethro Description Updated
2020-03-27 11:07 jethro File Added: mouse.patch
2020-03-27 11:07 jethro Note Added: 0000414
2020-03-27 21:23 scorpio810_mantis Note Added: 0000415
2020-03-27 21:24 scorpio810_mantis Note Edited: 0000415
2021-02-15 00:44 user245 Product Version SVN/trunk => 0.8
2021-02-15 00:45 user245 Fixed in Version => SVN/trunk
2021-02-15 00:47 user245 Product Version 0.8 => SVN/trunk
2021-02-15 00:50 user245 Category Diagram Editor => website