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