Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Allow panning of composer by holding space key
  • Loading branch information
nyalldawson committed Oct 10, 2013
1 parent eb0c794 commit 9290d7a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/gui/qgscomposerview.cpp
Expand Up @@ -812,6 +812,26 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
return;
}

if ( mPanning )
return;

if ( e->key() == Qt::Key_Space )
{
// Pan composer with space bar
if ( ! e->isAutoRepeat() )
{
mPanning = true;
mMouseLastXY = mMouseCurrentXY;
if ( composition() )
{
//prevent cursor changes while panning
composition()->setPreventCursorChange( true );
}
viewport()->setCursor( Qt::ClosedHandCursor );
}
return;
}

QList<QgsComposerItem*> composerItemList = composition()->selectedComposerItems();
QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin();

Expand Down Expand Up @@ -861,6 +881,31 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
}
}

void QgsComposerView::keyReleaseEvent( QKeyEvent * e )
{
if ( e->key() == Qt::Key_Space && !e->isAutoRepeat() && mPanning )
{
//end of panning with space key
mPanning = false;

//reset cursor
if ( mCurrentTool == Pan )
{
viewport()->setCursor( Qt::OpenHandCursor );
}
else
{
if ( composition() )
{
//allow cursor changes again
composition()->setPreventCursorChange( false );
}
viewport()->setCursor( Qt::ArrowCursor );
}
return;
}
}

void QgsComposerView::wheelEvent( QWheelEvent* event )
{
QPointF scenePoint = mapToScene( event->pos() );
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscomposerview.h
Expand Up @@ -135,6 +135,7 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void mouseDoubleClickEvent( QMouseEvent* e );

void keyPressEvent( QKeyEvent * e );
void keyReleaseEvent( QKeyEvent * e );

void wheelEvent( QWheelEvent* event );

Expand Down

0 comments on commit 9290d7a

Please sign in to comment.