Skip to content
Permalink
Browse files

[FEATURE] Mouse wheel over sliders in color dialog to change value by

increments
  • Loading branch information
nyalldawson committed Jul 11, 2016
1 parent 4145e33 commit d3582abbf68e760a10f5785f29be6a1d43967380
Showing with 23 additions and 0 deletions.
  1. +1 −0 python/gui/qgscolorwidgets.sip
  2. +21 −0 src/gui/qgscolorwidgets.cpp
  3. +1 −0 src/gui/qgscolorwidgets.h
@@ -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 );
};
@@ -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() );
@@ -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;

0 comments on commit d3582ab

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