Skip to content

Commit 3624d7b

Browse files
committed
Use window system provided cursors rather than bitmaps
1 parent afd436d commit 3624d7b

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/app/qgisapp.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -2484,9 +2484,7 @@ void QgisApp::createOverview()
24842484

24852485
mOverviewCanvas->setWhatsThis( tr( "Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas." ) );
24862486

2487-
QBitmap overviewPanBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
2488-
QBitmap overviewPanBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
2489-
mOverviewMapCursor = new QCursor( overviewPanBmp, overviewPanBmpMask, 0, 0 ); //set upper left corner as hot spot - this is better when extent marker is small; hand won't cover the marker
2487+
mOverviewMapCursor = new QCursor( Qt::OpenHandCursor );
24902488
mOverviewCanvas->setCursor( *mOverviewMapCursor );
24912489
// QVBoxLayout *myOverviewLayout = new QVBoxLayout;
24922490
// myOverviewLayout->addWidget(overviewCanvas);

src/gui/qgscursors.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
extern GUI_EXPORT const char *zoom_in[];
2525
extern GUI_EXPORT const char *zoom_out[];
2626

27-
extern GUI_EXPORT const unsigned char pan_bits[];
28-
extern GUI_EXPORT const unsigned char pan_mask_bits[];
27+
extern GUI_EXPORT const unsigned char pan_bits[]; // TODO QGIS3: Removeme
28+
extern GUI_EXPORT const unsigned char pan_mask_bits[]; // TODO QGIS3: Removeme
2929

3030
extern GUI_EXPORT const char *capture_point_cursor[];
3131
extern GUI_EXPORT const char *select_cursor[];

src/gui/qgsmaptoolpan.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )
2828
{
2929
mToolName = tr( "Pan" );
3030
// set cursor
31-
QBitmap panBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
32-
QBitmap panBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
33-
mCursor = QCursor( panBmp, panBmpMask, 5, 5 );
31+
mCursor = QCursor( Qt::OpenHandCursor );
32+
}
33+
34+
void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e )
35+
{
36+
if ( e->button() == Qt::LeftButton )
37+
mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
3438
}
3539

3640

@@ -61,4 +65,5 @@ void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent* e )
6165
mCanvas->refresh();
6266
}
6367
}
68+
mCanvas->setCursor( mCursor );
6469
}

src/gui/qgsmaptoolpan.h

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class GUI_EXPORT QgsMapToolPan : public QgsMapTool
3232
//! constructor
3333
QgsMapToolPan( QgsMapCanvas* canvas );
3434

35+
//! Mouse press event
36+
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
37+
3538
//! Overridden mouse move event
3639
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
3740

0 commit comments

Comments
 (0)