Commit 757c699e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: use float for rate and fix a bug when mouseWheeling

parent 9ac719c3
......@@ -426,11 +426,11 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
speedControlMenu->addAction( widgetAction );
/* Change the SpeedRate in the Status Bar */
CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) );
DCONNECT( THEMIM, inputChanged( input_thread_t * ),
speedControl, activateOnState() );
setRate( INPUT_RATE_DEFAULT / var_InheritFloat( p_intf, "rate" ) );
setRate( var_InheritFloat( p_intf, "rate" ) );
}
SpeedLabel::~SpeedLabel()
......@@ -449,10 +449,10 @@ void SpeedLabel::showSpeedMenu( QPoint pos )
+ QPoint( 0, height() ) );
}
void SpeedLabel::setRate( int rate )
void SpeedLabel::setRate( float rate )
{
QString str;
str.setNum( ( 1000 / (double)rate ), 'f', 2 );
str.setNum( rate, 'f', 2 );
str.append( "x" );
setText( str );
setToolTip( str );
......@@ -480,7 +480,7 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
speedSlider->setPageStep( 1 );
speedSlider->setTickInterval( 17 );
CONNECT( speedSlider, sliderMoved( int ), this, updateRate( int ) );
CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
QToolButton *normalSpeedButton = new QToolButton( this );
normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
......@@ -504,7 +504,7 @@ void SpeedControlWidget::activateOnState()
speedSlider->setEnabled( THEMIM->getIM()->hasInput() );
}
void SpeedControlWidget::updateControls( int rate )
void SpeedControlWidget::updateControls( float rate )
{
if( speedSlider->isSliderDown() )
{
......@@ -512,7 +512,7 @@ void SpeedControlWidget::updateControls( int rate )
return;
}
double value = 17 * log( (double)INPUT_RATE_DEFAULT / rate ) / log( 2 );
double value = 17 * log( rate ) / log( 2 );
int sliderValue = (int) ( ( value > 0 ) ? value + .5 : value - .5 );
if( sliderValue < speedSlider->minimum() )
......
......@@ -172,7 +172,7 @@ protected:
}
private slots:
void showSpeedMenu( QPoint );
void setRate( int );
void setRate( float );
private:
intf_thread_t *p_intf;
QMenu *speedControlMenu;
......@@ -185,7 +185,7 @@ class SpeedControlWidget : public QFrame
Q_OBJECT
public:
SpeedControlWidget( intf_thread_t *, QWidget * );
void updateControls( int );
void updateControls( float );
private:
intf_thread_t *p_intf;
QSlider *speedSlider;
......
......@@ -79,7 +79,7 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
artUrl = "";
p_input = NULL;
p_input_vbi = NULL;
i_rate = 0;
f_rate = 0;
p_item = NULL;
b_video = false;
timeA = 0;
......@@ -111,14 +111,14 @@ void InputManager::setInput( input_thread_t *_p_input )
UpdateVout();
addCallbacks();
p_item = input_GetItem( p_input );
emit rateChanged( INPUT_RATE_DEFAULT / var_GetFloat( p_input, "rate" ) );
emit rateChanged( var_GetFloat( p_input, "rate" ) );
}
else
{
p_input = NULL;
p_item = NULL;
assert( !p_input_vbi );
emit rateChanged( INPUT_RATE_DEFAULT / var_InheritFloat( p_intf, "rate" ) );
emit rateChanged( var_InheritFloat( p_intf, "rate" ) );
}
}
......@@ -149,7 +149,7 @@ void InputManager::delInput()
p_input = NULL;
emit positionUpdated( -1.0, 0 ,0 );
emit rateChanged( INPUT_RATE_DEFAULT / var_InheritFloat( p_intf, "rate" ) );
emit rateChanged( var_InheritFloat( p_intf, "rate" ) );
emit nameChanged( "" );
emit chapterChanged( 0 );
emit titleChanged( 0 );
......@@ -431,12 +431,12 @@ void InputManager::UpdateStatus()
void InputManager::UpdateRate()
{
/* Update Rate */
int i_new_rate = INPUT_RATE_DEFAULT / var_GetFloat( p_input, "rate" );
if( i_new_rate != i_rate )
float f_new_rate = var_GetFloat( p_input, "rate" );
if( f_new_rate != f_rate )
{
i_rate = i_new_rate;
f_rate = f_new_rate;
/* Update rate */
emit rateChanged( i_rate );
emit rateChanged( f_rate );
}
}
......
......@@ -144,7 +144,7 @@ private:
int i_old_playing_status;
QString oldName;
QString artUrl;
int i_rate;
float f_rate;
float f_cache;
bool b_video;
mtime_t timeA, timeB;
......@@ -204,7 +204,7 @@ signals:
/// Send new position, new time and new length
void positionUpdated( float , int64_t, int );
void seekRequested( float pos );
void rateChanged( int );
void rateChanged( float );
void nameChanged( const QString& );
/// Used to signal whether we should show navigation buttons
void titleChanged( bool );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment