Commit 083b7bcd authored by Yuval Tze's avatar Yuval Tze Committed by Jean-Baptiste Kempf

Qt: synchronization: subtitles duration parameter

new spin box that enables subsdelay filter and disables it when the value is set to 0
the spin box tooltip and suffix are updated according to the subsdelay mode
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 3434ee9c
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
#include <vlc_charset.h> /* us_strtod */ #include <vlc_charset.h> /* us_strtod */
static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add );
#if 0 #if 0
class ConfClickHandler : public QObject class ConfClickHandler : public QObject
{ {
...@@ -102,7 +104,6 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : ...@@ -102,7 +104,6 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
QObject( _parent ), p_intf( _p_intf ) QObject( _parent ), p_intf( _p_intf )
{ {
ui.setupUi( _parent ); ui.setupUi( _parent );
p_vout = NULL;
#define SETUP_VFILTER( widget ) \ #define SETUP_VFILTER( widget ) \
{ \ { \
...@@ -264,7 +265,7 @@ void ExtVideo::cropChange() ...@@ -264,7 +265,7 @@ void ExtVideo::cropChange()
if( ui.leftRightCropSync->isChecked() ) if( ui.leftRightCropSync->isChecked() )
ui.cropRightPx->setValue( ui.cropLeftPx->value() ); ui.cropRightPx->setValue( ui.cropLeftPx->value() );
p_vout = THEMIM->getVout(); vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout ) if( p_vout )
{ {
var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() ); var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
...@@ -283,7 +284,7 @@ void ExtVideo::clean() ...@@ -283,7 +284,7 @@ void ExtVideo::clean()
ui.cropRightPx->setValue( 0 ); ui.cropRightPx->setValue( 0 );
} }
void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add ) static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_name, bool b_add )
{ {
char *psz_parser, *psz_string; char *psz_parser, *psz_string;
const char *psz_filter_type; const char *psz_filter_type;
...@@ -381,7 +382,7 @@ void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add ) ...@@ -381,7 +382,7 @@ void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add )
} }
else else
{ {
p_vout = THEMIM->getVout(); vout_thread_t *p_vout = THEMIM->getVout();
if( p_vout ) if( p_vout )
{ {
var_SetString( p_vout, psz_filter_type, psz_string ); var_SetString( p_vout, psz_filter_type, psz_string );
...@@ -399,7 +400,7 @@ void ExtVideo::updateFilters() ...@@ -399,7 +400,7 @@ void ExtVideo::updateFilters()
QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() ); QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() ); QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
ChangeVFiltersString( qtu( module ), ChangeVFiltersString( p_intf, qtu( module ),
checkbox ? checkbox->isChecked() checkbox ? checkbox->isChecked()
: groupbox->isChecked() ); : groupbox->isChecked() );
} }
...@@ -1458,6 +1459,12 @@ void Spatializer::addCallbacks( aout_instance_t *p_aout ) ...@@ -1458,6 +1459,12 @@ void Spatializer::addCallbacks( aout_instance_t *p_aout )
#include <QToolButton> #include <QToolButton>
#include <QGridLayout> #include <QGridLayout>
#define SUBSDELAY_CFG_MODE "subsdelay-mode"
#define SUBSDELAY_CFG_FACTOR "subsdelay-factor"
#define SUBSDELAY_MODE_ABSOLUTE 0
#define SUBSDELAY_MODE_RELATIVE_SOURCE_DELAY 1
#define SUBSDELAY_MODE_RELATIVE_SOURCE_CONTENT 2
SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
QWidget( _parent ) , p_intf( _p_intf ) QWidget( _parent ) , p_intf( _p_intf )
{ {
...@@ -1466,6 +1473,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -1466,6 +1473,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
QToolButton *moinsAV, *plusAV; QToolButton *moinsAV, *plusAV;
QToolButton *moinssubs, *plussubs; QToolButton *moinssubs, *plussubs;
QToolButton *moinssubSpeed, *plussubSpeed; QToolButton *moinssubSpeed, *plussubSpeed;
QToolButton *moinssubDuration, *plussubDuration;
QToolButton *updateButton; QToolButton *updateButton;
...@@ -1563,6 +1571,30 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -1563,6 +1571,30 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
subSpeedSpin->setSuffix( " fps" ); subSpeedSpin->setSuffix( " fps" );
subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 ); subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
moinssubDuration = new QToolButton;
moinssubDuration->setToolButtonStyle( Qt::ToolButtonTextOnly );
moinssubDuration->setAutoRaise( true );
moinssubDuration->setText( "-" );
subsLayout->addWidget( moinssubDuration, 2, 1, 1, 1 );
plussubDuration = new QToolButton;
plussubDuration->setToolButtonStyle( Qt::ToolButtonTextOnly );
plussubDuration->setAutoRaise( true );
plussubDuration->setText( "+" );
subsLayout->addWidget( plussubDuration, 2, 3, 1, 1 );
QLabel *subDurationLabel = new QLabel;
subDurationLabel->setText( qtr( "Subtitles duration factor:" ) );
subsLayout->addWidget( subDurationLabel, 2, 0, 1, 1 );
subDurationSpin = new QDoubleSpinBox;
subDurationSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
subDurationSpin->setDecimals( 3 );
subDurationSpin->setMinimum( 0 );
subDurationSpin->setMaximum( 20 );
subDurationSpin->setSingleStep( 0.2 );
subsLayout->addWidget( subDurationSpin, 2, 2, 1, 1 );
mainLayout->addWidget( subsBox, 2, 0, 2, 5 ); mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
updateButton = new QToolButton; updateButton = new QToolButton;
...@@ -1577,10 +1609,14 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -1577,10 +1609,14 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
CONNECT( plussubs, clicked(), subsSpin, stepUp () ); CONNECT( plussubs, clicked(), subsSpin, stepUp () );
CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () ); CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () ); CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
CONNECT( moinssubDuration, clicked(), subDurationSpin, stepDown () );
CONNECT( plussubDuration, clicked(), subDurationSpin, stepUp () );
CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ; CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ; CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
CONNECT( subSpeedSpin, valueChanged ( double ), CONNECT( subSpeedSpin, valueChanged ( double ),
this, adjustSubsSpeed( double ) ); this, adjustSubsSpeed( double ) );
CONNECT( subDurationSpin, valueChanged ( double ),
this, adjustSubsDuration( double ) );
CONNECT( THEMIM->getIM(), synchroChanged(), this, update() ); CONNECT( THEMIM->getIM(), synchroChanged(), this, update() );
BUTTON_SET_ACT_I( updateButton, "", update, BUTTON_SET_ACT_I( updateButton, "", update,
...@@ -1588,6 +1624,12 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -1588,6 +1624,12 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
/* Set it */ /* Set it */
update(); update();
updateSubsDuration();
}
SyncControls::~SyncControls()
{
subsdelayClean();
} }
void SyncControls::clean() void SyncControls::clean()
...@@ -1596,6 +1638,8 @@ void SyncControls::clean() ...@@ -1596,6 +1638,8 @@ void SyncControls::clean()
AVSpin->setValue( 0.0 ); AVSpin->setValue( 0.0 );
subsSpin->setValue( 0.0 ); subsSpin->setValue( 0.0 );
subSpeedSpin->setValue( 1.0 ); subSpeedSpin->setValue( 1.0 );
subsdelayClean();
updateSubsDuration();
b_userAction = true; b_userAction = true;
} }
...@@ -1641,6 +1685,64 @@ void SyncControls::adjustSubsSpeed( double f_fps ) ...@@ -1641,6 +1685,64 @@ void SyncControls::adjustSubsSpeed( double f_fps )
} }
} }
void SyncControls::adjustSubsDuration( double f_factor )
{
if( THEMIM->getInput() && b_userAction )
{
subsdelaySetFactor( f_factor );
ChangeVFiltersString( p_intf, "subsdelay", f_factor > 0 );
}
}
void SyncControls::updateSubsDuration()
{
int i_mode = var_InheritInteger( p_intf, SUBSDELAY_CFG_MODE );
switch (i_mode)
{
default:
case SUBSDELAY_MODE_ABSOLUTE:
subDurationSpin->setToolTip( qtr( "Extend subtitles duration by this value.\n"
"Set 0 to disable." ) );
subDurationSpin->setSuffix( " s" );
break;
case SUBSDELAY_MODE_RELATIVE_SOURCE_DELAY:
subDurationSpin->setToolTip( qtr( "Multiply subtitles duration by this value.\n"
"Set 0 to disable." ) );
subDurationSpin->setSuffix( "" );
break;
case SUBSDELAY_MODE_RELATIVE_SOURCE_CONTENT:
subDurationSpin->setToolTip( qtr( "Recalculate subtitles duration according\n"
"to their content and this value.\n"
"Set 0 to disable." ) );
subDurationSpin->setSuffix( "" );
break;
}
subDurationSpin->setValue( var_InheritFloat( p_intf, SUBSDELAY_CFG_FACTOR ) );
}
void SyncControls::subsdelayClean()
{
/* Remove subsdelay filter */
ChangeVFiltersString( p_intf, "subsdelay", false );
}
void SyncControls::subsdelaySetFactor( double f_factor )
{
/* Set the factor in the preferences */
config_PutFloat( p_intf, SUBSDELAY_CFG_FACTOR, f_factor );
/* Try to find an instance of subsdelay, and set its factor */
vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_find_name( p_intf->p_libvlc, "subsdelay", FIND_CHILD );
if( p_obj )
{
var_SetFloat( p_obj, SUBSDELAY_CFG_FACTOR, f_factor );
vlc_object_release( p_obj );
}
}
/********************************************************************** /**********************************************************************
* Video filters / Adjust * Video filters / Adjust
**********************************************************************/ **********************************************************************/
......
...@@ -53,10 +53,8 @@ private: ...@@ -53,10 +53,8 @@ private:
Ui::ExtVideoWidget ui; Ui::ExtVideoWidget ui;
QSignalMapper* filterMapper; QSignalMapper* filterMapper;
intf_thread_t *p_intf; intf_thread_t *p_intf;
vout_thread_t *p_vout;
void initComboBoxItems( QObject* ); void initComboBoxItems( QObject* );
void setWidgetValue( QObject* ); void setWidgetValue( QObject* );
void ChangeVFiltersString( const char *psz_name, bool b_add );
void clean(); void clean();
private slots: private slots:
void updateFilters(); void updateFilters();
...@@ -176,22 +174,28 @@ class SyncControls : public QWidget ...@@ -176,22 +174,28 @@ class SyncControls : public QWidget
friend class ExtendedDialog; friend class ExtendedDialog;
public: public:
SyncControls( intf_thread_t *, QWidget * ); SyncControls( intf_thread_t *, QWidget * );
virtual ~SyncControls() {}; virtual ~SyncControls();
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
QDoubleSpinBox *AVSpin; QDoubleSpinBox *AVSpin;
QDoubleSpinBox *subsSpin; QDoubleSpinBox *subsSpin;
QDoubleSpinBox *subSpeedSpin; QDoubleSpinBox *subSpeedSpin;
QDoubleSpinBox *subDurationSpin;
bool b_userAction; bool b_userAction;
void clean(); void clean();
void updateSubsDuration();
void subsdelayClean();
void subsdelaySetFactor( double );
public slots: public slots:
void update(); void update();
private slots: private slots:
void advanceAudio( double ); void advanceAudio( double );
void advanceSubs( double ); void advanceSubs( double );
void adjustSubsSpeed( double ); void adjustSubsSpeed( double );
void adjustSubsDuration( double );
}; };
#endif #endif
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