Commit 18120e5a authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

Qt4: allow speedlabel in toolbars

Modified-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 38227c24
...@@ -468,6 +468,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -468,6 +468,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
case ASPECT_RATIO_COMBOBOX: case ASPECT_RATIO_COMBOBOX:
widget = new AspectRatioComboBox( p_intf ); widget = new AspectRatioComboBox( p_intf );
break; break;
case SPEED_LABEL:
widget = new SpeedLabel( p_intf, this );
break;
default: default:
msg_Warn( p_intf, "This should not happen %i", button ); msg_Warn( p_intf, "This should not happen %i", button );
break; break;
......
...@@ -100,6 +100,7 @@ typedef enum buttonType_e ...@@ -100,6 +100,7 @@ typedef enum buttonType_e
ADVANCED_CONTROLLER, ADVANCED_CONTROLLER,
PLAYBACK_BUTTONS, PLAYBACK_BUTTONS,
ASPECT_RATIO_COMBOBOX, ASPECT_RATIO_COMBOBOX,
SPEED_LABEL,
SPECIAL_MAX, SPECIAL_MAX,
WIDGET_SPACER = 0x40, WIDGET_SPACER = 0x40,
......
...@@ -343,11 +343,15 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent ) ...@@ -343,11 +343,15 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
widgetAction->setDefaultWidget( speedControl ); widgetAction->setDefaultWidget( speedControl );
speedControlMenu->addAction( widgetAction ); speedControlMenu->addAction( widgetAction );
/* Change the SpeedRate in the Status Bar */ /* Change the SpeedRate in the Label */
CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) ); CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) );
DCONNECT( THEMIM, inputChanged( input_thread_t * ), DCONNECT( THEMIM, inputChanged( input_thread_t * ),
speedControl, activateOnState() ); speedControl, activateOnState() );
setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
setLineWidth( 1 );
setRate( var_InheritFloat( p_intf, "rate" ) ); setRate( var_InheritFloat( p_intf, "rate" ) );
} }
...@@ -364,7 +368,7 @@ SpeedLabel::~SpeedLabel() ...@@ -364,7 +368,7 @@ SpeedLabel::~SpeedLabel()
void SpeedLabel::showSpeedMenu( QPoint pos ) void SpeedLabel::showSpeedMenu( QPoint pos )
{ {
speedControlMenu->exec( QCursor::pos() - pos speedControlMenu->exec( QCursor::pos() - pos
+ QPoint( 0, height() ) ); + QPoint( -70 + width()/2, height() ) );
} }
void SpeedLabel::setRate( float rate ) void SpeedLabel::setRate( float rate )
...@@ -383,15 +387,14 @@ void SpeedLabel::setRate( float rate ) ...@@ -383,15 +387,14 @@ void SpeedLabel::setRate( float rate )
SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
: QFrame( _parent ), p_intf( _p_i ) : QFrame( _parent ), p_intf( _p_i )
{ {
QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed ); QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Maximum );
sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 ); sizePolicy.setVerticalStretch( 0 );
speedSlider = new QSlider( this ); speedSlider = new QSlider( this );
speedSlider->setSizePolicy( sizePolicy ); speedSlider->setSizePolicy( sizePolicy );
speedSlider->setMaximumSize( QSize( 80, 200 ) ); speedSlider->setMinimumSize( QSize( 140, 20 ) );
speedSlider->setOrientation( Qt::Vertical ); speedSlider->setOrientation( Qt::Horizontal );
speedSlider->setTickPosition( QSlider::TicksRight );
speedSlider->setRange( -34, 34 ); speedSlider->setRange( -34, 34 );
speedSlider->setSingleStep( 1 ); speedSlider->setSingleStep( 1 );
...@@ -401,18 +404,28 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) ...@@ -401,18 +404,28 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
CONNECT( speedSlider, valueChanged( 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, 16 ) );
normalSpeedButton->setAutoRaise( true ); normalSpeedButton->setAutoRaise( true );
normalSpeedButton->setText( "1x" ); normalSpeedButton->setText( "1x" );
normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) ); normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
CONNECT( normalSpeedButton, clicked(), this, resetRate() ); CONNECT( normalSpeedButton, clicked(), this, resetRate() );
QVBoxLayout *speedControlLayout = new QVBoxLayout( this ); /* spinBox = new QDoubleSpinBox();
speedControlLayout->setContentsMargins( 4, 4, 4, 4 ); spinBox->setDecimals( 2 );
speedControlLayout->setSpacing( 4 ); spinBox->setMaximum( 32 );
speedControlLayout->addWidget( speedSlider ); spinBox->setMinimum( 0.03F );
speedControlLayout->addWidget( normalSpeedButton ); spinBox->setSingleStep( 0.10F );
spinBox->setAlignment( Qt::AlignRight );
CONNECT( spinBox, valueChanged( double ), this, updateSpinBoxRate( double ) ); */
QGridLayout* speedControlLayout = new QGridLayout( this );
speedControlLayout->addWidget( speedSlider, 0, 0, 1, 3 );
speedControlLayout->addWidget( normalSpeedButton, 1, 1 );
//speedControlLayout->addWidget( spinBox );
speedControlLayout->setContentsMargins( 0, 0, 0, 0 );
speedControlLayout->setSpacing( 0 );
lastValue = 0; lastValue = 0;
...@@ -422,6 +435,7 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent ) ...@@ -422,6 +435,7 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
void SpeedControlWidget::activateOnState() void SpeedControlWidget::activateOnState()
{ {
speedSlider->setEnabled( THEMIM->getIM()->hasInput() ); speedSlider->setEnabled( THEMIM->getIM()->hasInput() );
//spinBox->setEnabled( THEMIM->getIM()->hasInput() );
} }
void SpeedControlWidget::updateControls( float rate ) void SpeedControlWidget::updateControls( float rate )
...@@ -446,6 +460,7 @@ void SpeedControlWidget::updateControls( float rate ) ...@@ -446,6 +460,7 @@ void SpeedControlWidget::updateControls( float rate )
lastValue = sliderValue; lastValue = sliderValue;
speedSlider->setValue( sliderValue ); speedSlider->setValue( sliderValue );
//spinBox->setValue( rate );
} }
void SpeedControlWidget::updateRate( int sliderValue ) void SpeedControlWidget::updateRate( int sliderValue )
...@@ -457,6 +472,12 @@ void SpeedControlWidget::updateRate( int sliderValue ) ...@@ -457,6 +472,12 @@ void SpeedControlWidget::updateRate( int sliderValue )
int rate = INPUT_RATE_DEFAULT / speed; int rate = INPUT_RATE_DEFAULT / speed;
THEMIM->getIM()->setRate(rate); THEMIM->getIM()->setRate(rate);
//spinBox->setValue( var_InheritFloat( THEPL, "rate" ) );
}
void SpeedControlWidget::updateSpinBoxRate( double r )
{
var_SetFloat( THEPL, "rate", r );
} }
void SpeedControlWidget::resetRate() void SpeedControlWidget::resetRate()
......
...@@ -188,8 +188,9 @@ public: ...@@ -188,8 +188,9 @@ public:
SpeedControlWidget( intf_thread_t *, QWidget * ); SpeedControlWidget( intf_thread_t *, QWidget * );
void updateControls( float ); void updateControls( float );
private: private:
intf_thread_t *p_intf; intf_thread_t* p_intf;
QSlider *speedSlider; QSlider* speedSlider;
QDoubleSpinBox* spinBox;
int lastValue; int lastValue;
public slots: public slots:
...@@ -197,6 +198,7 @@ public slots: ...@@ -197,6 +198,7 @@ public slots:
private slots: private slots:
void updateRate( int ); void updateRate( int );
void updateSpinBoxRate( double );
void resetRate(); void resetRate();
}; };
......
...@@ -449,6 +449,10 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) ...@@ -449,6 +449,10 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
widget = new AspectRatioComboBox( p_intf ); widget = new AspectRatioComboBox( p_intf );
widgetItem->setText( qtr("Aspect ratio selector") ); widgetItem->setText( qtr("Aspect ratio selector") );
break; break;
case SPEED_LABEL:
widget = new SpeedLabel( p_intf, this );
widgetItem->setText( qtr("Speed selector") );
break;
default: default:
msg_Warn( p_intf, "This should not happen %i", i ); msg_Warn( p_intf, "This should not happen %i", i );
break; break;
......
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