Skip to content

Commit

Permalink
Use cursors to indicate interactivability
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 26, 2020
1 parent cb8574a commit aa832aa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/qgsrangeslider.cpp
Expand Up @@ -36,7 +36,8 @@ QgsRangeSlider::QgsRangeSlider( Qt::Orientation orientation, QWidget *parent )
setSizePolicy( sp );
setAttribute( Qt::WA_WState_OwnSizePolicy, false );

installEventFilter( this );
setAttribute( Qt::WA_Hover );
setMouseTracking( true );
}

int QgsRangeSlider::maximum() const
Expand Down Expand Up @@ -233,30 +234,39 @@ bool QgsRangeSlider::newHoverControl( const QPoint &pos )
mHoverRect = lowerHandleRect;
mHoverControl = Lower;
mHoverSubControl = QStyle::SC_SliderHandle;
setCursor( Qt::OpenHandCursor );
}
else if ( upperHandleRect.contains( pos ) )
{
mHoverRect = upperHandleRect;
mHoverControl = Upper;
mHoverSubControl = QStyle::SC_SliderHandle;
setCursor( Qt::OpenHandCursor );
}
else if ( grooveRect.contains( pos ) )
{
mHoverRect = grooveRect;
mHoverControl = None;
mHoverSubControl = QStyle::SC_SliderGroove;

if ( selectedRangeRect().contains( pos ) )
setCursor( Qt::OpenHandCursor );
else
unsetCursor();
}
else if ( tickmarksRect.contains( pos ) )
{
mHoverRect = tickmarksRect;
mHoverControl = None;
mHoverSubControl = QStyle::SC_SliderTickmarks;
unsetCursor();
}
else
{
mHoverRect = QRect();
mHoverControl = None;
mHoverSubControl = QStyle::SC_None;
unsetCursor();
}
return mHoverSubControl != lastHoverSubControl || mHoverControl != lastHoverControl;
}
Expand Down

0 comments on commit aa832aa

Please sign in to comment.