Skip to content
Permalink
Browse files

[FEATURE] Allow panning of composer by holding space key

  • Loading branch information
nyalldawson committed Oct 10, 2013
1 parent eb0c794 commit 9290d7a8b11419c2c4e76e920b8c055002b7242a
Showing with 46 additions and 0 deletions.
  1. +45 −0 src/gui/qgscomposerview.cpp
  2. +1 −0 src/gui/qgscomposerview.h
@@ -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();

@@ -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() );
@@ -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 );

0 comments on commit 9290d7a

Please sign in to comment.
You can’t perform that action at this time.