Skip to content
Permalink
Browse files

Update cursor on alt press/release for zoom tool

  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent 7974597 commit dc0425abee2f4e9495cd25932037637f16257a15
@@ -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();


@@ -108,7 +108,7 @@ void QgsLayoutViewTool::activate()
if ( mAction )
mAction->setChecked( true );

mView->setCursor( mCursor );
mView->viewport()->setCursor( mCursor );
emit activated();
}

@@ -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 )
@@ -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:

0 comments on commit dc0425a

Please sign in to comment.
You can’t perform that action at this time.