X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fextended_panels.cpp;h=4ddcb19a47ef61f320c44c15257d66f9b8bc6cb4;hb=0333f05e38b96d47b8a0474c93a6932a456c0cc3;hp=6bb9a7f535bf272a51d8af9bc8b96dc133b7ec1c;hpb=083b7bcd69006ebc15bbde1c59dfca459128b93d;p=vlc diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp index 6bb9a7f535..4ddcb19a47 100644 --- a/modules/gui/qt4/components/extended_panels.cpp +++ b/modules/gui/qt4/components/extended_panels.cpp @@ -45,7 +45,7 @@ #include "util/qt_dirs.hpp" #include "../../audio_filter/equalizer_presets.h" -#include +#include #include #include #include @@ -109,23 +109,24 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : { \ vlc_object_t *p_obj = ( vlc_object_t * ) \ vlc_object_find_name( p_intf->p_libvlc, \ - #widget, \ - FIND_CHILD ); \ + #widget ); \ QCheckBox *checkbox = qobject_cast( ui.widget##Enable ); \ QGroupBox *groupbox = qobject_cast( ui.widget##Enable ); \ if( p_obj ) \ { \ vlc_object_release( p_obj ); \ if( checkbox ) checkbox->setChecked( true ); \ - else groupbox->setChecked( true ); \ + else if (groupbox) groupbox->setChecked( true ); \ } \ else \ { \ if( checkbox ) checkbox->setChecked( false ); \ - else groupbox->setChecked( false ); \ + else if (groupbox) groupbox->setChecked( false ); \ } \ } \ CONNECT( ui.widget##Enable, clicked(), this, updateFilters() ); + + #define SETUP_VFILTER_OPTION( widget, signal ) \ initComboBoxItems( ui.widget ); \ setWidgetValue( ui.widget ); \ @@ -143,7 +144,6 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : SETUP_VFILTER_OPTION( extractComponentText, textChanged( const QString& ) ) SETUP_VFILTER( posterize ) - SETUP_VFILTER_OPTION( posterizeLevelSpin, valueChanged( int ) ) SETUP_VFILTER( colorthres ) SETUP_VFILTER_OPTION( colorthresColorText, textChanged( const QString& ) ) @@ -165,8 +165,6 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : SETUP_VFILTER( motiondetect ) -// SETUP_VFILTER( noise ) - SETUP_VFILTER( psychedelic ) SETUP_VFILTER( sharpen ) @@ -198,10 +196,6 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) ) SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) ) - SETUP_VFILTER( panoramix ) - SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) ) - SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) ) - SETUP_VFILTER( erase ) SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() ) @@ -226,6 +220,15 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : SETUP_VFILTER( grain ) SETUP_VFILTER_OPTION( grainVarianceSlider, valueChanged( int ) ) + SETUP_VFILTER( mirror ) + + SETUP_VFILTER( gaussianblur ) + SETUP_VFILTER_OPTION( gaussianbluSigmaSlider, valueChanged( int ) ) + + SETUP_VFILTER( antiflicker ) + SETUP_VFILTER_OPTION( antiflickerSofteningSizeSlider, valueChanged( int ) ) + + if( module_exists( "atmo" ) ) { SETUP_VFILTER( atmo ) @@ -314,11 +317,9 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_ } else { - module_release (p_obj); msg_Err( p_intf, "Unknown video filter type." ); return; } - module_release (p_obj); psz_string = config_GetPsz( p_intf, psz_filter_type ); @@ -341,6 +342,7 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_ } else { + free( psz_string ); return; } } @@ -429,7 +431,7 @@ void ExtVideo::initComboBoxItems( QObject *widget ) qtu( option ) ); if( p_item ) { - int i_type = p_item->i_type & CONFIG_ITEM; + int i_type = p_item->i_type; for( int i_index = 0; i_index < p_item->i_list; i_index++ ) { if( i_type == CONFIG_ITEM_INTEGER @@ -456,9 +458,7 @@ void ExtVideo::setWidgetValue( QObject *widget ) //std::cout << "Option name: " << option.toStdString() << std::endl; vlc_object_t *p_obj = ( vlc_object_t * ) - vlc_object_find_name( p_intf->p_libvlc, - qtu( module ), - FIND_CHILD ); + vlc_object_find_name( p_intf->p_libvlc, qtu( module ) ); int i_type; vlc_value_t val; @@ -549,9 +549,7 @@ void ExtVideo::updateFilterOptions() //std::cout << "Option name: " << option.toStdString() << std::endl; vlc_object_t *p_obj = ( vlc_object_t * ) - vlc_object_find_name( p_intf->p_libvlc, - qtu( module ), - FIND_CHILD ); + vlc_object_find_name( p_intf->p_libvlc, qtu( module ) ); int i_type; bool b_is_command; if( !p_obj ) @@ -568,14 +566,6 @@ void ExtVideo::updateFilterOptions() b_is_command = ( i_type & VLC_VAR_ISCOMMAND ); } - if( !b_is_command ) - { - msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.", - qtu( module ), - qtu( option ) ); - /* FIXME: restart automatically somewhere near the end of this function */ - } - /* Try to cast to all the widgets we're likely to encounter. Only * one of the casts is expected to work. */ QSlider *slider = qobject_cast ( sender() ); @@ -620,15 +610,16 @@ void ExtVideo::updateFilterOptions() } else if( i_type == VLC_VAR_STRING ) { - char *psz_string = NULL; - if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) ); - else if( combobox ) psz_string = strdup( qtu( combobox->itemData( - combobox->currentIndex() ).toString() ) ); - else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); - config_PutPsz( p_intf, qtu( option ), psz_string ); + QString val; + if( lineedit ) + val = lineedit->text(); + else if( combobox ) + val = combobox->itemData( combobox->currentIndex() ).toString(); + else + msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ ); + config_PutPsz( p_intf, qtu( option ), qtu( val ) ); if( b_is_command ) - var_SetString( p_obj, qtu( option ), psz_string ); - free( psz_string ); + var_SetString( p_obj, qtu( option ), qtu( val ) ); } else msg_Err( p_intf, @@ -637,6 +628,15 @@ void ExtVideo::updateFilterOptions() qtu( option ), i_type ); + if( !b_is_command ) + { + msg_Warn( p_intf, "Module %s's %s variable isn't a command. Brute-restarting the filter.", + qtu( module ), + qtu( option ) ); + ChangeVFiltersString( p_intf, qtu( module ), false ); + ChangeVFiltersString( p_intf, qtu( module ), true ); + } + if( p_obj ) vlc_object_release( p_obj ); } @@ -686,7 +686,7 @@ void ExtV4l2::showEvent( QShowEvent *event ) void ExtV4l2::Refresh( void ) { - vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE ); + vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" ); help->hide(); if( box ) { @@ -830,11 +830,11 @@ void ExtV4l2::ValueChange( bool value ) void ExtV4l2::ValueChange( int value ) { QObject *s = sender(); - vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE ); + vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" ); if( p_obj ) { - char *psz_var = strdup( qtu( s->objectName() ) ); - int i_type = var_Type( p_obj, psz_var ); + QString var = s->objectName(); + int i_type = var_Type( p_obj, qtu( var ) ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_INTEGER: @@ -843,16 +843,15 @@ void ExtV4l2::ValueChange( int value ) QComboBox *combobox = qobject_cast( s ); value = combobox->itemData( value ).toInt(); } - var_SetInteger( p_obj, psz_var, value ); + var_SetInteger( p_obj, qtu( var ), value ); break; case VLC_VAR_BOOL: - var_SetBool( p_obj, psz_var, value ); + var_SetBool( p_obj, qtu( var ), value ); break; case VLC_VAR_VOID: - var_TriggerCallback( p_obj, psz_var ); + var_TriggerCallback( p_obj, qtu( var ) ); break; } - free( psz_var ); vlc_object_release( p_obj ); } else @@ -925,7 +924,7 @@ void Equalizer::updateUIFromCore() float f_preamp; int i_preset; - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); if( p_aout ) { psz_af = var_GetNonEmptyString( p_aout, "audio-filter" ); @@ -1004,7 +1003,7 @@ void Equalizer::enable( bool en ) /* Function called when the set2Pass button is activated */ void Equalizer::set2Pass() { - aout_instance_t *p_aout= THEMIM->getAout(); + vlc_object_t *p_aout= (vlc_object_t *)THEMIM->getAout(); bool b_2p = ui.eq2PassCheck->isChecked(); if( p_aout ) @@ -1019,7 +1018,7 @@ void Equalizer::set2Pass() void Equalizer::setPreamp() { const float f = ( float )( ui.preampSlider->value() ) /10 - 20; - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 ) + qtr( "dB" ) ); @@ -1046,13 +1045,12 @@ void Equalizer::setCoreBands() band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" ); values += " " + val; } - const char *psz_values = values.toAscii().constData(); - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); if( p_aout ) { //delCallbacks( p_aout ); - var_SetString( p_aout, "equalizer-bands", psz_values ); + var_SetString( p_aout, "equalizer-bands", qtu( values ) ); //addCallbacks( p_aout ); vlc_object_release( p_aout ); } @@ -1064,7 +1062,7 @@ char * Equalizer::createValuesFromPreset( int i_preset ) /* Create the QString in Qt */ for( int i = 0 ; i< BANDS ;i++ ) - values += QString( " %1" ).arg( eqz_preset_10b[i_preset]->f_amp[i] ); + values += QString( " %1" ).arg( eqz_preset_10b[i_preset].f_amp[i], 5, 'f', 1 ); /* Convert it to char * */ return strdup( values.toAscii().constData() ); @@ -1076,7 +1074,7 @@ void Equalizer::setCorePreset( int i_preset ) return; /* Update pre-amplification in the UI */ - float f_preamp = eqz_preset_10b[i_preset]->f_preamp; + float f_preamp = eqz_preset_10b[i_preset].f_preamp; ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) ); ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) ); @@ -1097,20 +1095,20 @@ void Equalizer::setCorePreset( int i_preset ) } /* Apply presets to audio output */ - aout_instance_t *p_aout= THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); if( p_aout ) { var_SetString( p_aout , "equalizer-preset" , preset_list[i_preset] ); var_SetString( p_aout, "equalizer-bands", psz_values ); var_SetFloat( p_aout, "equalizer-preamp", - eqz_preset_10b[i_preset]->f_preamp ); + eqz_preset_10b[i_preset].f_preamp ); vlc_object_release( p_aout ); } config_PutPsz( p_intf, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] ); config_PutFloat( p_intf, "equalizer-preamp", - eqz_preset_10b[i_preset]->f_preamp ); + eqz_preset_10b[i_preset].f_preamp ); free( psz_values ); } @@ -1126,14 +1124,14 @@ static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd, return VLC_SUCCESS; } -void Equalizer::delCallbacks( aout_instance_t *p_aout ) +void Equalizer::delCallbacks( vlc_object_t *p_aout ) { //var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this ); //var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this ); var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this ); } -void Equalizer::addCallbacks( aout_instance_t *p_aout ) +void Equalizer::addCallbacks( vlc_object_t *p_aout ) { //var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this ); //var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this ); @@ -1215,7 +1213,7 @@ Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent ) BUTTONACT( enableCheck, enable() ); /* Write down initial values */ - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); char *psz_af; if( p_aout ) @@ -1283,7 +1281,7 @@ void Compressor::setInitValues() void Compressor::setValues() { - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); for( int i = 0 ; i < NUM_CP_CTRL ; i++ ) { @@ -1368,7 +1366,7 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) BUTTONACT( enableCheck, enable() ); /* Write down initial values */ - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); char *psz_af; if( p_aout ) @@ -1418,7 +1416,7 @@ void Spatializer::setInitValues() void Spatializer::setValues() { - aout_instance_t *p_aout = THEMIM->getAout(); + vlc_object_t *p_aout = (vlc_object_t *)THEMIM->getAout(); for( int i = 0 ; i < NUM_SP_CTRL ; i++ ) { @@ -1442,14 +1440,14 @@ void Spatializer::setValues() } } -void Spatializer::delCallbacks( aout_instance_t *p_aout ) +void Spatializer::delCallbacks( vlc_object_t *p_aout ) { VLC_UNUSED( p_aout ); // var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this ); // var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this ); } -void Spatializer::addCallbacks( aout_instance_t *p_aout ) +void Spatializer::addCallbacks( vlc_object_t *p_aout ) { VLC_UNUSED( p_aout ); // var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this ); @@ -1498,7 +1496,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : AVLayout->addWidget( plusAV, 0, 3, 1, 1 ); QLabel *AVLabel = new QLabel; - AVLabel->setText( qtr( "Advance of audio over video:" ) ); + AVLabel->setText( qtr( "Add a delay to the audio track:" ) ); AVLayout->addWidget( AVLabel, 0, 0, 1, 1 ); AVSpin = new QDoubleSpinBox; @@ -1507,8 +1505,8 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : AVSpin->setMinimum( -600.0 ); AVSpin->setMaximum( 600.0 ); AVSpin->setSingleStep( 0.1 ); - AVSpin->setToolTip( qtr( "A positive value means that\n" - "the audio is ahead of the video" ) ); + AVSpin->setToolTip( qtr( "A positive value will delay\n" + "the audio, when it was ahead of the video" ) ); AVSpin->setSuffix( " s" ); AVLayout->addWidget( AVSpin, 0, 2, 1, 1 ); mainLayout->addWidget( AVBox, 1, 0, 1, 5 ); @@ -1531,7 +1529,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : subsLayout->addWidget( plussubs, 0, 3, 1, 1 ); QLabel *subsLabel = new QLabel; - subsLabel->setText( qtr( "Advance of subtitles over video:" ) ); + subsLabel->setText( qtr( "Add a delay to the subtitle track:" ) ); subsLayout->addWidget( subsLabel, 0, 0, 1, 1 ); subsSpin = new QDoubleSpinBox; @@ -1540,8 +1538,8 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : subsSpin->setMinimum( -600.0 ); subsSpin->setMaximum( 600.0 ); subsSpin->setSingleStep( 0.1 ); - subsSpin->setToolTip( qtr( "A positive value means that\n" - "the subtitles are ahead of the video" ) ); + subsSpin->setToolTip( qtr( "A positive value will delay the\n" + "subtitles, when they were ahead of the video" ) ); subsSpin->setSuffix( " s" ); subsLayout->addWidget( subsSpin, 0, 2, 1, 1 ); @@ -1622,9 +1620,10 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) : BUTTON_SET_ACT_I( updateButton, "", update, qtr( "Force update of this dialog's values" ), update() ); + initSubsDuration(); + /* Set it */ update(); - updateSubsDuration(); } SyncControls::~SyncControls() @@ -1639,7 +1638,6 @@ void SyncControls::clean() subsSpin->setValue( 0.0 ); subSpeedSpin->setValue( 1.0 ); subsdelayClean(); - updateSubsDuration(); b_userAction = true; } @@ -1655,6 +1653,7 @@ void SyncControls::update() i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" ); subsSpin->setValue( ( (double)i_delay ) / 1000000 ); subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) ); + subDurationSpin->setValue( var_InheritFloat( p_intf, SUBSDELAY_CFG_FACTOR ) ); } b_userAction = true; } @@ -1694,7 +1693,7 @@ void SyncControls::adjustSubsDuration( double f_factor ) } } -void SyncControls::updateSubsDuration() +void SyncControls::initSubsDuration() { int i_mode = var_InheritInteger( p_intf, SUBSDELAY_CFG_MODE ); @@ -1718,8 +1717,6 @@ void SyncControls::updateSubsDuration() subDurationSpin->setSuffix( "" ); break; } - - subDurationSpin->setValue( var_InheritFloat( p_intf, SUBSDELAY_CFG_FACTOR ) ); } void SyncControls::subsdelayClean() @@ -1734,7 +1731,7 @@ void SyncControls::subsdelaySetFactor( double f_factor ) 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 ); + vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_find_name( p_intf->p_libvlc, "subsdelay" ); if( p_obj ) { var_SetFloat( p_obj, SUBSDELAY_CFG_FACTOR, f_factor );