[vlc-commits] qt: replaced magic constants with QtAbstractSlider::{maximum, minimum}
Filip Roséen
git at videolan.org
Tue Mar 22 19:31:09 CET 2016
vlc | branch: master | Filip Roséen <filip at videolabs.io> | Tue Mar 22 19:26:05 2016 +0100| [53d3f94dc3427123d82d1cec1f8447afe9b5672a] | committer: Jean-Baptiste Kempf
qt: replaced magic constants with QtAbstractSlider::{maximum, minimum}
Replaced the use of constants with calls to QAbstractSlider::maximum and
QAbstractSlider::minimum, making it easier to maintain the class in the
future.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=53d3f94dc3427123d82d1cec1f8447afe9b5672a
---
modules/gui/qt/util/input_slider.cpp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt/util/input_slider.cpp b/modules/gui/qt/util/input_slider.cpp
index 6f23de6..335a916 100644
--- a/modules/gui/qt/util/input_slider.cpp
+++ b/modules/gui/qt/util/input_slider.cpp
@@ -209,7 +209,7 @@ void SeekSlider::setPosition( float pos, int64_t time, int length )
if( !isSliding )
{
- setValue( (int)( pos * 1000.0 ) );
+ setValue( pos * static_cast<float>( maximum() ) );
if ( animLoading != NULL && pos >= 0.0f && animLoading->state() != QAbstractAnimation::Stopped )
{
animLoading->stop();
@@ -230,7 +230,7 @@ void SeekSlider::startSeekTimer()
void SeekSlider::updatePos()
{
- float f_pos = (float)( value() ) / 1000.0;
+ float f_pos = value() / static_cast<float>( maximum() );
emit sliderDragged( f_pos ); /* Send new position to VLC's core */
}
@@ -336,7 +336,7 @@ void SeekSlider::mousePressEvent( QMouseEvent* event )
isSliding = true ;
- setValue( QStyle::sliderValueFromPosition( MIN_SLIDER_VALUE, MAX_SLIDER_VALUE, event->x() - handleLength() / 2, width() - handleLength(), false ) );
+ setValue( QStyle::sliderValueFromPosition( minimum(), maximum(), event->x() - handleLength() / 2, width() - handleLength(), false ) );
emit sliderMoved( value() );
event->accept();
}
@@ -353,7 +353,7 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event )
if( isSliding )
{
- setValue( QStyle::sliderValueFromPosition( MIN_SLIDER_VALUE, MAX_SLIDER_VALUE, event->x() - handleLength() / 2, width() - handleLength(), false) );
+ setValue( QStyle::sliderValueFromPosition( minimum(), maximum(), event->x() - handleLength() / 2, width() - handleLength(), false) );
emit sliderMoved( value() );
}
@@ -400,7 +400,7 @@ void SeekSlider::wheelEvent( QWheelEvent *event )
Since delta is in 1/8 of ° and mouse have steps of 15 °
and that our slider is in 0.1% and we want one step to be a 1%
increment of position */
- emit sliderDragged( value() / 1000.0 );
+ emit sliderDragged( value() / static_cast<float>( maximum() ) );
}
event->accept();
}
More information about the vlc-commits
mailing list