Skip to content

Commit

Permalink
[FEATURE] Mouse wheel over sliders in color dialog to change value by
Browse files Browse the repository at this point in the history
increments
  • Loading branch information
nyalldawson committed Jul 11, 2016
1 parent 4145e33 commit d3582ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/gui/qgscolorwidgets.sip
Expand Up @@ -373,6 +373,7 @@ class QgsColorRampWidget : QgsColorWidget
protected:

virtual void mouseMoveEvent( QMouseEvent *event );
virtual void wheelEvent( QWheelEvent* event );
virtual void mousePressEvent( QMouseEvent *event );
virtual void keyPressEvent( QKeyEvent * event );
};
Expand Down
21 changes: 21 additions & 0 deletions src/gui/qgscolorwidgets.cpp
Expand Up @@ -1178,6 +1178,27 @@ void QgsColorRampWidget::mouseMoveEvent( QMouseEvent *event )
QgsColorWidget::mouseMoveEvent( event );
}

void QgsColorRampWidget::wheelEvent( QWheelEvent *event )
{
int oldValue = componentValue();

if ( event->delta() > 0 )
{
setComponentValue( componentValue() + 1 );
}
else
{
setComponentValue( componentValue() - 1 );
}

if ( componentValue() != oldValue )
{
//value has changed
emit colorChanged( mCurrentColor );
emit valueChanged( componentValue() );
}
}

void QgsColorRampWidget::mousePressEvent( QMouseEvent *event )
{
setColorFromPoint( event->posF() );
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscolorwidgets.h
Expand Up @@ -515,6 +515,7 @@ class GUI_EXPORT QgsColorRampWidget : public QgsColorWidget
protected:

virtual void mouseMoveEvent( QMouseEvent *event ) override;
virtual void wheelEvent( QWheelEvent* event ) override;
virtual void mousePressEvent( QMouseEvent *event ) override;
virtual void keyPressEvent( QKeyEvent * event ) override;

Expand Down

0 comments on commit d3582ab

Please sign in to comment.