File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -812,6 +812,26 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
812
812
return ;
813
813
}
814
814
815
+ if ( mPanning )
816
+ return ;
817
+
818
+ if ( e->key () == Qt::Key_Space )
819
+ {
820
+ // Pan composer with space bar
821
+ if ( ! e->isAutoRepeat () )
822
+ {
823
+ mPanning = true ;
824
+ mMouseLastXY = mMouseCurrentXY ;
825
+ if ( composition () )
826
+ {
827
+ // prevent cursor changes while panning
828
+ composition ()->setPreventCursorChange ( true );
829
+ }
830
+ viewport ()->setCursor ( Qt::ClosedHandCursor );
831
+ }
832
+ return ;
833
+ }
834
+
815
835
QList<QgsComposerItem*> composerItemList = composition ()->selectedComposerItems ();
816
836
QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin ();
817
837
@@ -861,6 +881,31 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
861
881
}
862
882
}
863
883
884
+ void QgsComposerView::keyReleaseEvent ( QKeyEvent * e )
885
+ {
886
+ if ( e->key () == Qt::Key_Space && !e->isAutoRepeat () && mPanning )
887
+ {
888
+ // end of panning with space key
889
+ mPanning = false ;
890
+
891
+ // reset cursor
892
+ if ( mCurrentTool == Pan )
893
+ {
894
+ viewport ()->setCursor ( Qt::OpenHandCursor );
895
+ }
896
+ else
897
+ {
898
+ if ( composition () )
899
+ {
900
+ // allow cursor changes again
901
+ composition ()->setPreventCursorChange ( false );
902
+ }
903
+ viewport ()->setCursor ( Qt::ArrowCursor );
904
+ }
905
+ return ;
906
+ }
907
+ }
908
+
864
909
void QgsComposerView::wheelEvent ( QWheelEvent* event )
865
910
{
866
911
QPointF scenePoint = mapToScene ( event->pos () );
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
135
135
void mouseDoubleClickEvent ( QMouseEvent* e );
136
136
137
137
void keyPressEvent ( QKeyEvent * e );
138
+ void keyReleaseEvent ( QKeyEvent * e );
138
139
139
140
void wheelEvent ( QWheelEvent* event );
140
141
You can’t perform that action at this time.
0 commit comments