@@ -84,17 +84,15 @@ void QgsComposerView::setCurrentTool( QgsComposerView::Tool t )
84
84
{
85
85
// lock cursor to prevent composer items changing it
86
86
composition ()->setPreventCursorChange ( true );
87
- viewport ()->setCursor ( Qt::OpenHandCursor );
87
+ viewport ()->setCursor ( defaultCursorForTool ( Pan ) );
88
88
break ;
89
89
}
90
90
case QgsComposerView::Zoom:
91
91
{
92
92
// lock cursor to prevent composer items changing it
93
93
composition ()->setPreventCursorChange ( true );
94
94
// set the cursor to zoom in
95
- QPixmap myZoomQPixmap = QPixmap (( const char ** )( zoom_in ) );
96
- QCursor zoomCursor = QCursor ( myZoomQPixmap, 7 , 7 );
97
- viewport ()->setCursor ( zoomCursor );
95
+ viewport ()->setCursor ( defaultCursorForTool ( Zoom ) );
98
96
break ;
99
97
}
100
98
case QgsComposerView::AddArrow:
@@ -112,9 +110,7 @@ void QgsComposerView::setCurrentTool( QgsComposerView::Tool t )
112
110
// using a drawing tool
113
111
// lock cursor to prevent composer items changing it
114
112
composition ()->setPreventCursorChange ( true );
115
- QPixmap myCrosshairQPixmap = QPixmap (( const char ** )( cross_hair_cursor ) );
116
- QCursor crosshairCursor = QCursor ( myCrosshairQPixmap, 8 , 8 );
117
- viewport ()->setCursor ( crosshairCursor );
113
+ viewport ()->setCursor ( defaultCursorForTool ( mCurrentTool ) );
118
114
break ;
119
115
}
120
116
default :
@@ -447,6 +443,44 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
447
443
}
448
444
}
449
445
446
+ QCursor QgsComposerView::defaultCursorForTool ( Tool currentTool )
447
+ {
448
+ switch ( currentTool )
449
+ {
450
+ case Select:
451
+ return Qt::ArrowCursor;
452
+
453
+ case Zoom:
454
+ {
455
+ QPixmap myZoomQPixmap = QPixmap (( const char ** )( zoom_in ) );
456
+ return QCursor ( myZoomQPixmap, 7 , 7 );
457
+ }
458
+
459
+ case Pan:
460
+ return Qt::OpenHandCursor;
461
+
462
+ case MoveItemContent:
463
+ return Qt::ArrowCursor;
464
+
465
+ case AddArrow:
466
+ case AddMap:
467
+ case AddRectangle:
468
+ case AddTriangle:
469
+ case AddEllipse:
470
+ case AddHtml:
471
+ case AddLabel:
472
+ case AddScalebar:
473
+ case AddLegend:
474
+ case AddPicture:
475
+ case AddTable:
476
+ {
477
+ QPixmap myCrosshairQPixmap = QPixmap (( const char ** )( cross_hair_cursor ) );
478
+ return QCursor ( myCrosshairQPixmap, 8 , 8 );
479
+ }
480
+ }
481
+ return Qt::ArrowCursor;
482
+ }
483
+
450
484
void QgsComposerView::addShape ( Tool currentTool )
451
485
{
452
486
QgsComposerShape::Shape shape = QgsComposerShape::Ellipse;
@@ -691,19 +725,15 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
691
725
}
692
726
693
727
// set new cursor
694
- if ( mCurrentTool == Pan )
695
- {
696
- viewport ()->setCursor ( Qt::OpenHandCursor );
697
- }
698
- else
728
+ if ( mCurrentTool != Pan )
699
729
{
700
730
if ( composition () )
701
731
{
702
732
// allow composer items to change cursor
703
733
composition ()->setPreventCursorChange ( false );
704
734
}
705
- viewport ()->setCursor ( Qt::ArrowCursor );
706
735
}
736
+ viewport ()->setCursor ( defaultCursorForTool ( mCurrentTool ) );
707
737
}
708
738
709
739
// for every other tool, ignore clicks of non-left button
@@ -1296,19 +1326,15 @@ void QgsComposerView::keyReleaseEvent( QKeyEvent * e )
1296
1326
mKeyPanning = false ;
1297
1327
1298
1328
// reset cursor
1299
- if ( mCurrentTool == Pan )
1300
- {
1301
- viewport ()->setCursor ( Qt::OpenHandCursor );
1302
- }
1303
- else
1329
+ if ( mCurrentTool != Pan )
1304
1330
{
1305
1331
if ( composition () )
1306
1332
{
1307
1333
// allow cursor changes again
1308
1334
composition ()->setPreventCursorChange ( false );
1309
1335
}
1310
- viewport ()->setCursor ( Qt::ArrowCursor );
1311
1336
}
1337
+ viewport ()->setCursor ( defaultCursorForTool ( mCurrentTool ) );
1312
1338
return ;
1313
1339
}
1314
1340
else if ( e->key () == Qt::Key_Space && !e->isAutoRepeat () && mTemporaryZoomStatus != QgsComposerView::Inactive )
0 commit comments