Skip to content

Commit

Permalink
Use window system provided cursors rather than bitmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 24, 2015
1 parent afd436d commit 3624d7b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -2484,9 +2484,7 @@ void QgisApp::createOverview()

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." ) );

QBitmap overviewPanBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
QBitmap overviewPanBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
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
mOverviewMapCursor = new QCursor( Qt::OpenHandCursor );
mOverviewCanvas->setCursor( *mOverviewMapCursor );
// QVBoxLayout *myOverviewLayout = new QVBoxLayout;
// myOverviewLayout->addWidget(overviewCanvas);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgscursors.h
Expand Up @@ -24,8 +24,8 @@
extern GUI_EXPORT const char *zoom_in[];
extern GUI_EXPORT const char *zoom_out[];

extern GUI_EXPORT const unsigned char pan_bits[];
extern GUI_EXPORT const unsigned char pan_mask_bits[];
extern GUI_EXPORT const unsigned char pan_bits[]; // TODO QGIS3: Removeme
extern GUI_EXPORT const unsigned char pan_mask_bits[]; // TODO QGIS3: Removeme

extern GUI_EXPORT const char *capture_point_cursor[];
extern GUI_EXPORT const char *select_cursor[];
Expand Down
11 changes: 8 additions & 3 deletions src/gui/qgsmaptoolpan.cpp
Expand Up @@ -28,9 +28,13 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )
{
mToolName = tr( "Pan" );
// set cursor
QBitmap panBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
QBitmap panBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
mCursor = QCursor( panBmp, panBmpMask, 5, 5 );
mCursor = QCursor( Qt::OpenHandCursor );
}

void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e )
{
if ( e->button() == Qt::LeftButton )
mCanvas->setCursor( QCursor( Qt::ClosedHandCursor ) );
}


Expand Down Expand Up @@ -61,4 +65,5 @@ void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent* e )
mCanvas->refresh();
}
}
mCanvas->setCursor( mCursor );
}
3 changes: 3 additions & 0 deletions src/gui/qgsmaptoolpan.h
Expand Up @@ -32,6 +32,9 @@ class GUI_EXPORT QgsMapToolPan : public QgsMapTool
//! constructor
QgsMapToolPan( QgsMapCanvas* canvas );

//! Mouse press event
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;

//! Overridden mouse move event
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;

Expand Down

0 comments on commit 3624d7b

Please sign in to comment.