Update cursor on alt press/release for zoom tool

This commit is contained in:
Nyall Dawson 2017-07-05 18:20:24 +10:00
parent 7974597c08
commit dc0425abee
4 changed files with 29 additions and 1 deletions

View File

@ -31,6 +31,10 @@ class QgsLayoutViewToolZoom : QgsLayoutViewTool
virtual void layoutReleaseEvent( QgsLayoutViewMouseEvent *event );
virtual void keyPressEvent( QKeyEvent *event );
virtual void keyReleaseEvent( QKeyEvent *event );
virtual void deactivate();

View File

@ -108,7 +108,7 @@ void QgsLayoutViewTool::activate()
if ( mAction )
mAction->setChecked( true );
mView->setCursor( mCursor );
mView->viewport()->setCursor( mCursor );
emit activated();
}

View File

@ -96,6 +96,28 @@ void QgsLayoutViewToolZoom::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
view()->fitInView( newBoundsRect, Qt::KeepAspectRatio );
}
void QgsLayoutViewToolZoom::keyPressEvent( QKeyEvent *event )
{
//respond to changes in the alt key status and update cursor accordingly
if ( ! event->isAutoRepeat() )
{
QPixmap zoomQPixmap = QPixmap( ( const char ** )( ( event->modifiers() & Qt::AltModifier ) ? zoom_out : zoom_in ) );
QCursor zoomCursor = QCursor( zoomQPixmap, 7, 7 );
view()->viewport()->setCursor( zoomCursor );
}
}
void QgsLayoutViewToolZoom::keyReleaseEvent( QKeyEvent *event )
{
//respond to changes in the alt key status and update cursor accordingly
if ( !event->isAutoRepeat() )
{
QPixmap zoomQPixmap = QPixmap( ( const char ** )( ( event->modifiers() & Qt::AltModifier ) ? zoom_out : zoom_in ) );
QCursor zoomCursor = QCursor( zoomQPixmap, 7, 7 );
view()->viewport()->setCursor( zoomCursor );
}
}
void QgsLayoutViewToolZoom::deactivate()
{
if ( mMarqueeZoom )

View File

@ -42,6 +42,8 @@ class GUI_EXPORT QgsLayoutViewToolZoom : public QgsLayoutViewTool
void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override;
void layoutMoveEvent( QgsLayoutViewMouseEvent *event ) override;
void layoutReleaseEvent( QgsLayoutViewMouseEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;
void keyReleaseEvent( QKeyEvent *event ) override;
void deactivate() override;
private: