Skip to content

Commit b3e5263

Browse files
committed
[fix #18892] avoid high jumps by setting a minimum pixel size for rect in map tool zoom
1 parent f00e43d commit b3e5263

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/gui/qgsmaptoolzoom.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ void QgsMapToolZoom::canvasReleaseEvent( QgsMapMouseEvent *e )
9191
// We are not really dragging in this case. This is sometimes caused by
9292
// a pen based computer reporting a press, move, and release, all the
9393
// one point.
94-
if ( mDragging && ( mZoomRect.topLeft() == mZoomRect.bottomRight() ) )
94+
if ( !mDragging || ( mZoomRect.topLeft() - mZoomRect.bottomRight() ).manhattanLength() < mMinPixelZoom )
9595
{
9696
mDragging = false;
9797
delete mRubberBand;
9898
mRubberBand = nullptr;
99-
}
10099

101-
if ( mDragging )
100+
// change to zoom in/out by the default multiple
101+
mCanvas->zoomWithCenter( e->x(), e->y(), !zoomOut );
102+
}
103+
else
102104
{
103105
mDragging = false;
104106
delete mRubberBand;
@@ -126,11 +128,6 @@ void QgsMapToolZoom::canvasReleaseEvent( QgsMapMouseEvent *e )
126128

127129
mCanvas->refresh();
128130
}
129-
else // not dragging
130-
{
131-
// change to zoom in/out by the default multiple
132-
mCanvas->zoomWithCenter( e->x(), e->y(), !zoomOut );
133-
}
134131
}
135132

136133
void QgsMapToolZoom::deactivate()

src/gui/qgsmaptoolzoom.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class GUI_EXPORT QgsMapToolZoom : public QgsMapTool
4545
protected:
4646
//! stores actual zoom rect
4747
QRect mZoomRect;
48+
// minimum pixel size of diagonal of the zoom rectangle
49+
int mMinPixelZoom = 20;
4850

4951
//! indicates whether we're zooming in or out
5052
bool mZoomOut;

0 commit comments

Comments
 (0)