Skip to content

Commit

Permalink
Handle pan via scrollbar in zoom history
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ committed Sep 22, 2024
1 parent 968fa8d commit 8f896a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gui/layout/qgslayoutview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <QMenu>
#include <QClipboard>
#include <QMimeData>
#include <QScrollBar>

#define MIN_VIEW_SCALE 0.05
#define MAX_VIEW_SCALE 1000.0
Expand Down Expand Up @@ -67,6 +68,9 @@ QgsLayoutView::QgsLayoutView( QWidget *parent )
connect( this, &QgsLayoutView::zoomLevelChanged, this, &QgsLayoutView::invalidateCachedRenders );
connect( this, &QgsLayoutView::zoomLevelChanged, this, &QgsLayoutView::extentChanged );

verticalScrollBar()->installEventFilter( this );
horizontalScrollBar()->installEventFilter( this );

mScreenHelper = new QgsScreenHelper( this );
}

Expand Down Expand Up @@ -1301,6 +1305,17 @@ void QgsLayoutView::wheelZoom( QWheelEvent *event )
}
}


bool QgsLayoutView::eventFilter( QObject *object, QEvent *event )
{
if ( event->type() == QEvent::MouseButtonRelease )
{
emit extentChanged();
}
return QGraphicsView::eventFilter( object, event );

}

QGraphicsLineItem *QgsLayoutView::createSnapLine() const
{
std::unique_ptr< QGraphicsLineItem> item( new QGraphicsLineItem( nullptr ) );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/layout/qgslayoutview.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
*/
void setSectionLabel( const QString &label );

/**
* Event filter to handle mouse release on scroll bars
*/
bool eventFilter( QObject *object, QEvent *event ) override;

public slots:

/**
Expand Down

0 comments on commit 8f896a5

Please sign in to comment.