1 /*****************************************************************************
2 * extended_panels.cpp : Extended controls panels
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Antoine Cellerier <dionoea .t videolan d@t org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * ( at your option ) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #define __STDC_FORMAT_MACROS 1
35 #include <QGridLayout>
36 #include <QSignalMapper>
40 #include "components/extended_panels.hpp"
41 #include "dialogs/preferences.hpp"
43 #include "input_manager.hpp"
45 #include "../../audio_filter/equalizer_presets.h"
47 #include <vlc_intf_strings.h>
50 #include <vlc_modules.h>
52 #include <vlc_charset.h> /* us_strtod */
55 class ConfClickHandler : public QObject
58 ConfClickHandler( intf_thread_t *_p_intf, ExtVideo *_e ) : QObject ( _e ) {
59 e = _e; p_intf = _p_intf;
61 virtual ~ConfClickHandler() {}
62 bool eventFilter( QObject *obj, QEvent *evt )
64 if( evt->type() == QEvent::MouseButtonPress )
73 intf_thread_t *p_intf;
77 const QString ModuleFromWidgetName( QObject *obj )
79 return obj->objectName().replace( "Enable","" );
82 QString OptionFromWidgetName( QObject *obj )
85 QString option = obj->objectName().replace( "Slider", "" )
86 .replace( "Combo" , "" )
87 .replace( "Dial" , "" )
88 .replace( "Check" , "" )
89 .replace( "Spin" , "" )
90 .replace( "Text" , "" );
91 for( char a = 'A'; a <= 'Z'; a++ )
93 option = option.replace( QString( a ),
94 QString( '-' ) + QString( a + 'a' - 'A' ) );
99 ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
100 QObject( _parent ), p_intf( _p_intf )
102 ui.setupUi( _parent );
105 #define SETUP_VFILTER( widget ) \
107 vlc_object_t *p_obj = ( vlc_object_t * ) \
108 vlc_object_find_name( p_intf->p_libvlc, \
111 QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
112 QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
115 vlc_object_release( p_obj ); \
116 if( checkbox ) checkbox->setChecked( true ); \
117 else groupbox->setChecked( true ); \
121 if( checkbox ) checkbox->setChecked( false ); \
122 else groupbox->setChecked( false ); \
125 CONNECT( ui.widget##Enable, clicked(), this, updateFilters() );
126 #define SETUP_VFILTER_OPTION( widget, signal ) \
127 initComboBoxItems( ui.widget ); \
128 setWidgetValue( ui.widget ); \
129 CONNECT( ui.widget, signal, this, updateFilterOptions() );
131 SETUP_VFILTER( adjust )
132 SETUP_VFILTER_OPTION( hueSlider, valueChanged( int ) )
133 SETUP_VFILTER_OPTION( contrastSlider, valueChanged( int ) )
134 SETUP_VFILTER_OPTION( brightnessSlider, valueChanged( int ) )
135 SETUP_VFILTER_OPTION( saturationSlider, valueChanged( int ) )
136 SETUP_VFILTER_OPTION( gammaSlider, valueChanged( int ) )
137 SETUP_VFILTER_OPTION( brightnessThresholdCheck, stateChanged( int ) )
139 SETUP_VFILTER( extract )
140 SETUP_VFILTER_OPTION( extractComponentText, textChanged( const QString& ) )
142 SETUP_VFILTER( posterize )
143 SETUP_VFILTER_OPTION( posterizeLevelSpin, valueChanged( int ) )
145 SETUP_VFILTER( colorthres )
146 SETUP_VFILTER_OPTION( colorthresColorText, textChanged( const QString& ) )
147 SETUP_VFILTER_OPTION( colorthresSaturationthresSlider, valueChanged( int ) )
148 SETUP_VFILTER_OPTION( colorthresSimilaritythresSlider, valueChanged( int ) )
150 SETUP_VFILTER( sepia )
151 SETUP_VFILTER_OPTION( sepiaIntensitySpin, valueChanged( int ) )
153 SETUP_VFILTER( invert )
155 SETUP_VFILTER( gradient )
156 SETUP_VFILTER_OPTION( gradientModeCombo, currentIndexChanged( QString ) )
157 SETUP_VFILTER_OPTION( gradientTypeCheck, stateChanged( int ) )
158 SETUP_VFILTER_OPTION( gradientCartoonCheck, stateChanged( int ) )
160 SETUP_VFILTER( motionblur )
161 SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged( int ) )
163 SETUP_VFILTER( motiondetect )
165 // SETUP_VFILTER( noise )
167 SETUP_VFILTER( psychedelic )
169 SETUP_VFILTER( sharpen )
170 SETUP_VFILTER_OPTION( sharpenSigmaSlider, valueChanged( int ) )
172 SETUP_VFILTER( ripple )
174 SETUP_VFILTER( wave )
176 SETUP_VFILTER( transform )
177 SETUP_VFILTER_OPTION( transformTypeCombo, currentIndexChanged( QString ) )
179 SETUP_VFILTER( rotate )
180 SETUP_VFILTER_OPTION( rotateAngleDial, valueChanged( int ) )
181 ui.rotateAngleDial->setWrapping( true );
182 ui.rotateAngleDial->setNotchesVisible( true );
184 SETUP_VFILTER( puzzle )
185 SETUP_VFILTER_OPTION( puzzleRowsSpin, valueChanged( int ) )
186 SETUP_VFILTER_OPTION( puzzleColsSpin, valueChanged( int ) )
187 SETUP_VFILTER_OPTION( puzzleBlackSlotCheck, stateChanged( int ) )
189 SETUP_VFILTER( magnify )
191 SETUP_VFILTER( clone )
192 SETUP_VFILTER_OPTION( cloneCountSpin, valueChanged( int ) )
194 SETUP_VFILTER( wall )
195 SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
196 SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
198 SETUP_VFILTER( panoramix )
199 SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) )
200 SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) )
203 SETUP_VFILTER( erase )
204 SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
205 SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
206 SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) )
208 SETUP_VFILTER( marq )
209 SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( const QString& ) )
210 SETUP_VFILTER_OPTION( marqPositionCombo, currentIndexChanged( QString ) )
212 SETUP_VFILTER( logo )
213 SETUP_VFILTER_OPTION( logoFileText, editingFinished() )
214 SETUP_VFILTER_OPTION( logoYSpin, valueChanged( int ) )
215 SETUP_VFILTER_OPTION( logoXSpin, valueChanged( int ) )
216 SETUP_VFILTER_OPTION( logoOpacitySlider, valueChanged( int ) )
218 SETUP_VFILTER( gradfun )
219 SETUP_VFILTER_OPTION( gradfunRadiusSlider, valueChanged( int ) )
221 SETUP_VFILTER( grain )
222 SETUP_VFILTER_OPTION( grainVarianceSlider, valueChanged( int ) )
224 if( module_exists( "atmo" ) )
226 SETUP_VFILTER( atmo )
227 SETUP_VFILTER_OPTION( atmoEdgeweightningSlider, valueChanged( int ) )
228 SETUP_VFILTER_OPTION( atmoBrightnessSlider, valueChanged( int ) )
229 SETUP_VFILTER_OPTION( atmoDarknesslimitSlider, valueChanged( int ) )
230 SETUP_VFILTER_OPTION( atmoMeanlengthSlider, valueChanged( int ) )
231 SETUP_VFILTER_OPTION( atmoMeanthresholdSlider, valueChanged( int ) )
232 SETUP_VFILTER_OPTION( atmoPercentnewSlider, valueChanged( int ) )
233 SETUP_VFILTER_OPTION( atmoFiltermodeCombo, currentIndexChanged( int ) )
234 SETUP_VFILTER_OPTION( atmoShowdotsCheck, stateChanged( int ) )
238 _parent->removeTab( _parent->indexOf( ui.tab_atmo ) );
242 #undef SETUP_VFILTER_OPTION
244 CONNECT( ui.cropTopPx, valueChanged( int ), this, cropChange() );
245 CONNECT( ui.cropBotPx, valueChanged( int ), this, cropChange() );
246 CONNECT( ui.cropLeftPx, valueChanged( int ), this, cropChange() );
247 CONNECT( ui.cropRightPx, valueChanged( int ), this, cropChange() );
248 CONNECT( ui.leftRightCropSync, toggled ( bool ), this, cropChange() );
249 CONNECT( ui.topBotCropSync, toggled ( bool ), this, cropChange() );
250 CONNECT( ui.topBotCropSync, toggled( bool ),
251 ui.cropBotPx, setDisabled( bool ) );
252 CONNECT( ui.leftRightCropSync, toggled( bool ),
253 ui.cropRightPx, setDisabled( bool ) );
256 void ExtVideo::cropChange()
258 if( ui.topBotCropSync->isChecked() )
259 ui.cropBotPx->setValue( ui.cropTopPx->value() );
260 if( ui.leftRightCropSync->isChecked() )
261 ui.cropRightPx->setValue( ui.cropLeftPx->value() );
263 p_vout = THEMIM->getVout();
266 var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
267 var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() );
268 var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() );
269 var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() );
270 vlc_object_release( p_vout );
274 void ExtVideo::clean()
276 ui.cropTopPx->setValue( 0 );
277 ui.cropBotPx->setValue( 0 );
278 ui.cropLeftPx->setValue( 0 );
279 ui.cropRightPx->setValue( 0 );
282 void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add )
284 char *psz_parser, *psz_string;
285 const char *psz_filter_type;
287 module_t *p_obj = module_find( psz_name );
290 msg_Err( p_intf, "Unable to find filter module \"%s\".", psz_name );
294 if( module_provides( p_obj, "video splitter" ) )
296 psz_filter_type = "video-splitter";
298 else if( module_provides( p_obj, "video filter2" ) )
300 psz_filter_type = "video-filter";
302 else if( module_provides( p_obj, "sub filter" ) )
304 psz_filter_type = "sub-filter";
308 module_release (p_obj);
309 msg_Err( p_intf, "Unknown video filter type." );
312 module_release (p_obj);
314 psz_string = config_GetPsz( p_intf, psz_filter_type );
316 if( !psz_string ) psz_string = strdup( "" );
318 psz_parser = strstr( psz_string, psz_name );
324 psz_parser = psz_string;
325 if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
326 psz_string, psz_name ) == -1 )
342 if( *( psz_parser + strlen( psz_name ) ) == ':' )
344 memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
345 strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
352 /* Remove trailing : : */
353 if( strlen( psz_string ) > 0 &&
354 *( psz_string + strlen( psz_string ) -1 ) == ':' )
356 *( psz_string + strlen( psz_string ) -1 ) = '\0';
365 /* Vout is not kept, so put that in the config */
366 config_PutPsz( p_intf, psz_filter_type, psz_string );
368 /* Try to set on the fly */
369 if( !strcmp( psz_filter_type, "video-splitter" ) )
371 playlist_t *p_playlist = pl_Get( p_intf );
372 var_SetString( p_playlist, psz_filter_type, psz_string );
376 p_vout = THEMIM->getVout();
379 var_SetString( p_vout, psz_filter_type, psz_string );
380 vlc_object_release( p_vout );
387 void ExtVideo::updateFilters()
389 QString module = ModuleFromWidgetName( sender() );
391 QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
392 QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
394 ChangeVFiltersString( qtu( module ),
395 checkbox ? checkbox->isChecked()
396 : groupbox->isChecked() );
399 void ExtVideo::initComboBoxItems( QObject *widget )
401 QComboBox *combobox = qobject_cast<QComboBox*>( widget );
402 if( !combobox ) return;
404 QString option = OptionFromWidgetName( widget );
405 module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
409 int i_type = p_item->i_type & CONFIG_ITEM;
410 for( int i_index = 0; i_index < p_item->i_list; i_index++ )
412 if( i_type == CONFIG_ITEM_INTEGER
413 || i_type == CONFIG_ITEM_BOOL )
414 combobox->addItem( qtr( p_item->ppsz_list_text[i_index] ),
415 p_item->pi_list[i_index] );
416 else if( i_type == CONFIG_ITEM_STRING )
417 combobox->addItem( qtr( p_item->ppsz_list_text[i_index] ),
418 p_item->ppsz_list[i_index] );
423 msg_Err( p_intf, "Couldn't find option \"%s\".",
428 void ExtVideo::setWidgetValue( QObject *widget )
430 QString module = ModuleFromWidgetName( widget->parent() );
431 //std::cout << "Module name: " << module.toStdString() << std::endl;
432 QString option = OptionFromWidgetName( widget );
433 //std::cout << "Option name: " << option.toStdString() << std::endl;
435 vlc_object_t *p_obj = ( vlc_object_t * )
436 vlc_object_find_name( p_intf->p_libvlc,
446 "Module instance %s not found, looking in config values.",
449 i_type = config_GetType( p_intf, qtu( option ) ) & VLC_VAR_CLASS;
452 case VLC_VAR_INTEGER:
454 val.i_int = config_GetInt( p_intf, qtu( option ) );
457 val.f_float = config_GetFloat( p_intf, qtu( option ) );
460 val.psz_string = config_GetPsz( p_intf, qtu( option ) );
466 i_type = var_Type( p_obj, qtu( option ) ) & VLC_VAR_CLASS;
467 var_Get( p_obj, qtu( option ), &val );
468 vlc_object_release( p_obj );
471 /* Try to cast to all the widgets we're likely to encounter. Only
472 * one of the casts is expected to work. */
473 QSlider *slider = qobject_cast<QSlider*> ( widget );
474 QCheckBox *checkbox = qobject_cast<QCheckBox*> ( widget );
475 QSpinBox *spinbox = qobject_cast<QSpinBox*> ( widget );
476 QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( widget );
477 QDial *dial = qobject_cast<QDial*> ( widget );
478 QLineEdit *lineedit = qobject_cast<QLineEdit*> ( widget );
479 QComboBox *combobox = qobject_cast<QComboBox*> ( widget );
481 if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
483 if( slider ) slider->setValue( val.i_int );
484 else if( checkbox ) checkbox->setCheckState( val.i_int? Qt::Checked
486 else if( spinbox ) spinbox->setValue( val.i_int );
487 else if( dial ) dial->setValue( ( 540-val.i_int )%360 );
491 snprintf( str, sizeof(str), "%06"PRIX64, val.i_int );
492 lineedit->setText( str );
494 else if( combobox ) combobox->setCurrentIndex(
495 combobox->findData( qlonglong(val.i_int) ) );
496 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
498 else if( i_type == VLC_VAR_FLOAT )
500 if( slider ) slider->setValue( ( int )( val.f_float*( double )slider->tickInterval() ) ); /* hack alert! */
501 else if( doublespinbox ) doublespinbox->setValue( val.f_float );
502 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
504 else if( i_type == VLC_VAR_STRING )
506 if( lineedit ) lineedit->setText( qfu( val.psz_string ) );
507 else if( combobox ) combobox->setCurrentIndex(
508 combobox->findData( qfu( val.psz_string ) ) );
509 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
510 free( val.psz_string );
515 "Module %s's %s variable is of an unsupported type ( %d )",
521 void ExtVideo::updateFilterOptions()
523 QString module = ModuleFromWidgetName( sender()->parent() );
524 //std::cout << "Module name: " << module.toStdString() << std::endl;
525 QString option = OptionFromWidgetName( sender() );
526 //std::cout << "Option name: " << option.toStdString() << std::endl;
528 vlc_object_t *p_obj = ( vlc_object_t * )
529 vlc_object_find_name( p_intf->p_libvlc,
536 msg_Warn( p_intf, "Module %s not found. You'll need to restart the filter to take the change into account.", qtu( module ) );
537 i_type = config_GetType( p_intf, qtu( option ) );
538 b_is_command = false;
542 i_type = var_Type( p_obj, qtu( option ) );
544 i_type = config_GetType( p_intf, qtu( option ) );
545 b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
550 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.",
553 /* FIXME: restart automatically somewhere near the end of this function */
556 /* Try to cast to all the widgets we're likely to encounter. Only
557 * one of the casts is expected to work. */
558 QSlider *slider = qobject_cast<QSlider*> ( sender() );
559 QCheckBox *checkbox = qobject_cast<QCheckBox*> ( sender() );
560 QSpinBox *spinbox = qobject_cast<QSpinBox*> ( sender() );
561 QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
562 QDial *dial = qobject_cast<QDial*> ( sender() );
563 QLineEdit *lineedit = qobject_cast<QLineEdit*> ( sender() );
564 QComboBox *combobox = qobject_cast<QComboBox*> ( sender() );
566 i_type &= VLC_VAR_CLASS;
567 if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
570 if( slider ) i_int = slider->value();
571 else if( checkbox ) i_int = checkbox->checkState() == Qt::Checked;
572 else if( spinbox ) i_int = spinbox->value();
573 else if( dial ) i_int = ( 540-dial->value() )%360;
574 else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
575 else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
576 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
577 config_PutInt( p_intf, qtu( option ), i_int );
580 if( i_type == VLC_VAR_INTEGER )
581 var_SetInteger( p_obj, qtu( option ), i_int );
583 var_SetBool( p_obj, qtu( option ), i_int );
586 else if( i_type == VLC_VAR_FLOAT )
589 if( slider ) f_float = ( double )slider->value()
590 / ( double )slider->tickInterval(); /* hack alert! */
591 else if( doublespinbox ) f_float = doublespinbox->value();
592 else if( lineedit ) f_float = lineedit->text().toDouble();
593 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
594 config_PutFloat( p_intf, qtu( option ), f_float );
596 var_SetFloat( p_obj, qtu( option ), f_float );
598 else if( i_type == VLC_VAR_STRING )
600 char *psz_string = NULL;
601 if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
602 else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
603 combobox->currentIndex() ).toString() ) );
604 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
605 config_PutPsz( p_intf, qtu( option ), psz_string );
607 var_SetString( p_obj, qtu( option ), psz_string );
612 "Module %s's %s variable is of an unsupported type ( %d )",
617 if( p_obj ) vlc_object_release( p_obj );
621 void ExtVideo::gotoConf( QObject* src )
623 #define SHOWCONF( module ) \
624 if( src->objectName().contains( module ) ) \
626 PrefsDialog::getInstance( p_intf )->showModulePrefs( module ); \
630 SHOWCONF( "magnify" );
632 SHOWCONF( "ripple" );
633 SHOWCONF( "invert" );
634 SHOWCONF( "puzzle" );
636 SHOWCONF( "gradient" );
637 SHOWCONF( "colorthres" )
641 /**********************************************************************
643 **********************************************************************/
645 ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
646 : QWidget( _parent ), p_intf( _p_intf ), box( NULL )
648 QVBoxLayout *layout = new QVBoxLayout( this );
649 help = new QLabel( qtr("No v4l2 instance found.\n"
650 "Please check that the device has been opened with VLC and is playing.\n\n"
651 "Controls will automatically appear here.")
653 help->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
654 layout->addWidget( help );
658 void ExtV4l2::showEvent( QShowEvent *event )
660 QWidget::showEvent( event );
664 void ExtV4l2::Refresh( void )
666 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
670 layout()->removeWidget( box );
676 vlc_value_t val, text, name;
677 int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
681 msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
683 vlc_object_release( p_obj );
687 box = new QGroupBox( this );
688 layout()->addWidget( box );
689 QVBoxLayout *layout = new QVBoxLayout( box );
690 box->setLayout( layout );
692 for( int i = 0; i < val.p_list->i_count; i++ )
694 const char *psz_var = text.p_list->p_values[i].psz_string;
695 var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &name, NULL );
696 const char *psz_label = name.psz_string;
697 msg_Dbg( p_intf, "v4l2 control \"%"PRIx64"\": %s (%s)",
698 val.p_list->p_values[i].i_int, psz_var, name.psz_string );
700 int i_type = var_Type( p_obj, psz_var );
701 switch( i_type & VLC_VAR_TYPE )
703 case VLC_VAR_INTEGER:
705 QLabel *label = new QLabel( qtr( psz_label ), box );
706 QHBoxLayout *hlayout = new QHBoxLayout();
707 hlayout->addWidget( label );
708 int i_val = var_GetInteger( p_obj, psz_var );
709 if( i_type & VLC_VAR_HASCHOICE )
711 QComboBox *combobox = new QComboBox( box );
712 combobox->setObjectName( qtr( psz_var ) );
714 vlc_value_t val2, text2;
715 var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
717 for( int j = 0; j < val2.p_list->i_count; j++ )
720 text2.p_list->p_values[j].psz_string,
721 qlonglong( val2.p_list->p_values[j].i_int) );
722 if( i_val == val2.p_list->p_values[j].i_int )
723 combobox->setCurrentIndex( j );
725 var_FreeList( &val2, &text2 );
727 CONNECT( combobox, currentIndexChanged( int ), this,
728 ValueChange( int ) );
729 hlayout->addWidget( combobox );
733 QSlider *slider = new QSlider( box );
734 slider->setObjectName( qtr( psz_var ) );
735 slider->setOrientation( Qt::Horizontal );
737 var_Change( p_obj, psz_var, VLC_VAR_GETMIN,
739 slider->setMinimum( val2.i_int );
740 var_Change( p_obj, psz_var, VLC_VAR_GETMAX,
742 slider->setMaximum( val2.i_int );
743 var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
745 slider->setSingleStep( val2.i_int );
746 slider->setValue( i_val );
748 CONNECT( slider, valueChanged( int ), this,
749 ValueChange( int ) );
750 hlayout->addWidget( slider );
752 layout->addLayout( hlayout );
757 QCheckBox *button = new QCheckBox( qtr( psz_label ), box );
758 button->setObjectName( qtr( psz_var ) );
759 button->setChecked( var_GetBool( p_obj, psz_var ) );
761 CONNECT( button, clicked( bool ), this,
762 ValueChange( bool ) );
763 layout->addWidget( button );
768 if( i_type & VLC_VAR_ISCOMMAND )
770 QPushButton *button = new QPushButton( qtr( psz_label ), box );
771 button->setObjectName( qtr( psz_var ) );
773 CONNECT( button, clicked( bool ), this,
774 ValueChange( bool ) );
775 layout->addWidget( button );
779 QLabel *label = new QLabel( qtr( psz_label ), box );
780 layout->addWidget( label );
785 msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
788 free( name.psz_string );
790 var_FreeList( &val, &text );
791 vlc_object_release( p_obj );
795 msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
798 QTimer::singleShot( 2000, this, SLOT(Refresh()) );
802 void ExtV4l2::ValueChange( bool value )
804 ValueChange( (int)value );
807 void ExtV4l2::ValueChange( int value )
809 QObject *s = sender();
810 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
813 char *psz_var = strdup( qtu( s->objectName() ) );
814 int i_type = var_Type( p_obj, psz_var );
815 switch( i_type & VLC_VAR_TYPE )
817 case VLC_VAR_INTEGER:
818 if( i_type & VLC_VAR_HASCHOICE )
820 QComboBox *combobox = qobject_cast<QComboBox*>( s );
821 value = combobox->itemData( value ).toInt();
823 var_SetInteger( p_obj, psz_var, value );
826 var_SetBool( p_obj, psz_var, value );
829 var_TriggerCallback( p_obj, psz_var );
833 vlc_object_release( p_obj );
837 msg_Warn( p_intf, "Oops, v4l2 object isn't available anymore" );
842 /**********************************************************************
844 **********************************************************************/
846 static const QString band_frequencies[] =
848 " 60 Hz ", " 170 Hz ", " 310 Hz ", " 600 Hz ", " 1 kHz ",
849 " 3 kHz ", " 6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
852 Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
853 QWidget( _parent ) , p_intf( _p_intf )
855 QFont smallFont = QApplication::font();
856 smallFont.setPointSize( smallFont.pointSize() - 3 );
859 ui.preampLabel->setFont( smallFont );
861 /* Setup of presetsComboBox */
862 presetsComboBox = ui.presetsCombo;
863 CONNECT( presetsComboBox, activated( int ), this, setCorePreset( int ) );
865 /* Add the sliders for the Bands */
866 QGridLayout *grid = new QGridLayout( ui.frame );
867 grid->setMargin( 0 );
868 for( int i = 0 ; i < BANDS ; i++ )
870 bands[i] = new QSlider( Qt::Vertical );
871 bands[i]->setMaximum( 400 );
872 bands[i]->setValue( 200 );
873 CONNECT( bands[i], valueChanged( int ), this, setCoreBands() );
875 band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" );
876 band_texts[i]->setFont( smallFont );
878 grid->addWidget( bands[i], 0, i );
879 grid->addWidget( band_texts[i], 1, i );
882 /* Add the listed presets */
883 for( int i = 0 ; i < NB_PRESETS ; i ++ )
885 presetsComboBox->addItem( qtr( preset_list_text[i] ),
886 QVariant( preset_list[i] ) );
890 BUTTONACT( ui.enableCheck, enable() );
891 BUTTONACT( ui.eq2PassCheck, set2Pass() );
892 CONNECT( ui.preampSlider, valueChanged( int ), this, setPreamp() );
894 /* Do the update from the value of the core */
898 /* Write down initial values */
899 void Equalizer::updateUIFromCore()
901 char *psz_af, *psz_pres, *psz_bands;
905 aout_instance_t *p_aout = THEMIM->getAout();
908 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
909 psz_pres = var_GetString( p_aout, "equalizer-preset" );
910 if( var_GetBool( p_aout, "equalizer-2pass" ) )
911 ui.eq2PassCheck->setChecked( true );
912 f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
913 psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
914 i_preset = presetsComboBox->findData( QVariant( psz_pres ) );
915 vlc_object_release( p_aout );
919 psz_af = config_GetPsz( p_intf, "audio-filter" );
920 psz_pres = config_GetPsz( p_intf, "equalizer-preset" );
921 if( config_GetInt( p_intf, "equalizer-2pass" ) )
922 ui.eq2PassCheck->setChecked( true );
923 f_preamp = config_GetFloat( p_intf, "equalizer-preamp" );
924 psz_bands = config_GetPsz( p_intf, "equalizer-bands" );
925 i_preset = presetsComboBox->findData( QVariant( psz_pres ) );
927 if( psz_af && strstr( psz_af, "equalizer" ) != NULL )
928 ui.enableCheck->setChecked( true );
929 enable( ui.enableCheck->isChecked() );
931 presetsComboBox->setCurrentIndex( i_preset );
933 ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
935 if( psz_bands && strlen( psz_bands ) > 1 )
937 char *psz_bands_orig = psz_bands;
938 for( int i = 0; i < BANDS; i++ )
940 const float f = us_strtod(psz_bands, &psz_bands );
941 bands[i]->setValue( (int)( ( f + 20 ) * 10 ) );
942 if( psz_bands == NULL || *psz_bands == '\0' ) break;
944 if( *psz_bands == '\0' ) break;
946 free( psz_bands_orig );
948 else free( psz_bands );
954 /* Functin called when enableButton is toggled */
955 void Equalizer::enable()
957 bool en = ui.enableCheck->isChecked();
958 aout_EnableFilter( THEPL, "equalizer", en );
959 // aout_EnableFilter( THEPL, "upmixer", en );
960 // aout_EnableFilter( THEPL, "vsurround", en );
963 if( presetsComboBox->currentIndex() < 0 )
964 presetsComboBox->setCurrentIndex( 0 );
968 void Equalizer::enable( bool en )
970 ui.eq2PassCheck->setEnabled( en );
971 presetsComboBox->setEnabled( en );
972 ui.presetLabel->setEnabled( en );
973 ui.preampLabel->setEnabled( en );
974 ui.preampSlider->setEnabled( en );
975 for( int i = 0 ; i< BANDS; i++ )
977 bands[i]->setEnabled( en ); band_texts[i]->setEnabled( en );
981 /* Function called when the set2Pass button is activated */
982 void Equalizer::set2Pass()
984 aout_instance_t *p_aout= THEMIM->getAout();
985 bool b_2p = ui.eq2PassCheck->isChecked();
989 var_SetBool( p_aout, "equalizer-2pass", b_2p );
990 vlc_object_release( p_aout );
992 config_PutInt( p_intf, "equalizer-2pass", b_2p );
995 /* Function called when the preamp slider is moved */
996 void Equalizer::setPreamp()
998 const float f = ( float )( ui.preampSlider->value() ) /10 - 20;
999 aout_instance_t *p_aout = THEMIM->getAout();
1001 ui.preampLabel->setText( qtr( "Preamp\n" ) + QString::number( f, 'f', 1 )
1005 //delCallbacks( p_aout );
1006 var_SetFloat( p_aout, "equalizer-preamp", f );
1007 //addCallbacks( p_aout );
1008 vlc_object_release( p_aout );
1010 config_PutFloat( p_intf, "equalizer-preamp", f );
1013 void Equalizer::setCoreBands()
1015 /**\todo smoothing */
1018 for( int i = 0; i < BANDS; i++ )
1020 const float f_val = (float)( bands[i]->value() ) / 10 - 20;
1021 QString val = QString("%1").arg( f_val, 5, 'f', 1 );
1023 band_texts[i]->setText( band_frequencies[i] + "\n" + val + "dB" );
1024 values += " " + val;
1026 const char *psz_values = values.toAscii().constData();
1028 aout_instance_t *p_aout = THEMIM->getAout();
1031 //delCallbacks( p_aout );
1032 var_SetString( p_aout, "equalizer-bands", psz_values );
1033 //addCallbacks( p_aout );
1034 vlc_object_release( p_aout );
1038 char * Equalizer::createValuesFromPreset( int i_preset )
1042 /* Create the QString in Qt */
1043 for( int i = 0 ; i< BANDS ;i++ )
1044 values += QString( " %1" ).arg( eqz_preset_10b[i_preset]->f_amp[i] );
1046 /* Convert it to char * */
1047 return strdup( values.toAscii().constData() );
1050 void Equalizer::setCorePreset( int i_preset )
1055 /* Update pre-amplification in the UI */
1056 float f_preamp = eqz_preset_10b[i_preset]->f_preamp;
1057 ui.preampSlider->setValue( (int)( ( f_preamp + 20 ) * 10 ) );
1058 ui.preampLabel->setText( qtr( "Preamp\n" )
1059 + QString::number( f_preamp, 'f', 1 ) + qtr( "dB" ) );
1061 char *psz_values = createValuesFromPreset( i_preset );
1062 if( !psz_values ) return ;
1064 char *p = psz_values;
1065 for( int i = 0; i < BANDS && *p; i++ )
1067 const float f = us_strtod( p, &p );
1069 bands[i]->setValue( (int)( ( f + 20 ) * 10 ) );
1070 band_texts[i]->setText( band_frequencies[i] + "\n"
1071 + QString("%1").arg( f, 5, 'f', 1 ) + "dB" );
1073 p++; /* skip separator */
1076 /* Apply presets to audio output */
1077 aout_instance_t *p_aout= THEMIM->getAout();
1080 var_SetString( p_aout , "equalizer-preset" , preset_list[i_preset] );
1082 var_SetString( p_aout, "equalizer-bands", psz_values );
1083 var_SetFloat( p_aout, "equalizer-preamp",
1084 eqz_preset_10b[i_preset]->f_preamp );
1085 vlc_object_release( p_aout );
1087 config_PutPsz( p_intf, "equalizer-bands", psz_values );
1088 config_PutPsz( p_intf, "equalizer-preset", preset_list[i_preset] );
1089 config_PutFloat( p_intf, "equalizer-preamp",
1090 eqz_preset_10b[i_preset]->f_preamp );
1094 static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
1095 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1097 char *psz_preset = newval.psz_string;
1098 Equalizer *eq = ( Equalizer * )p_data;
1099 int i_preset = eq->presetsComboBox->findData( QVariant( psz_preset ) );
1100 eq->presetsComboBox->setCurrentIndex( i_preset );
1104 void Equalizer::delCallbacks( aout_instance_t *p_aout )
1106 //var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this );
1107 //var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this );
1108 var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this );
1111 void Equalizer::addCallbacks( aout_instance_t *p_aout )
1113 //var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this );
1114 //var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this );
1115 var_AddCallback( p_aout, "equalizer-preset", PresetCallback, this );
1118 /**********************************************************************
1120 **********************************************************************/
1122 /**********************************************************************
1123 * Dynamic range compressor
1124 **********************************************************************/
1128 const char *psz_name;
1129 const char *psz_descs;
1130 const char *psz_units;
1131 const float f_min; // min
1132 const float f_max; // max
1133 const float f_value; // value
1134 const float f_resolution; // resolution
1137 static const comp_controls_t comp_controls[] =
1139 { "compressor-rms-peak", _("RMS/peak"), "", 0.0f, 1.0f, 0.00f, 0.001f },
1140 { "compressor-attack", _("Attack"), _(" ms"), 1.5f, 400.0f, 25.00f, 0.100f },
1141 { "compressor-release", _("Release"), _(" ms"), 2.0f, 800.0f, 100.00f, 0.100f },
1142 { "compressor-threshold", _("Threshold"), _(" dB"), -30.0f, 0.0f, -11.00f, 0.010f },
1143 { "compressor-ratio", _("Ratio"), ":1", 1.0f, 20.0f, 8.00f, 0.010f },
1144 { "compressor-knee", _("Knee\nradius"), _(" dB"), 1.0f, 10.0f, 2.50f, 0.010f },
1145 { "compressor-makeup-gain", _("Makeup\ngain"), _(" dB"), 0.0f, 24.0f, 7.00f, 0.010f },
1148 Compressor::Compressor( intf_thread_t *_p_intf, QWidget *_parent )
1149 : QWidget( _parent ) , p_intf( _p_intf )
1151 QFont smallFont = QApplication::font();
1152 smallFont.setPointSize( smallFont.pointSize() - 3 );
1154 QGridLayout *layout = new QGridLayout( this );
1156 enableCheck = new QCheckBox( qtr( "Enable dynamic range compressor" ) );
1157 layout->addWidget( enableCheck, 0, 0, 1, NUM_CP_CTRL );
1159 for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
1161 const int i_min = (int)( comp_controls[i].f_min
1162 / comp_controls[i].f_resolution );
1163 const int i_max = (int)( comp_controls[i].f_max
1164 / comp_controls[i].f_resolution );
1165 const int i_val = (int)( comp_controls[i].f_value
1166 / comp_controls[i].f_resolution );
1168 compCtrl[i] = new QSlider( Qt::Vertical );
1169 compCtrl[i]->setMinimum( i_min );
1170 compCtrl[i]->setMaximum( i_max );
1171 compCtrl[i]->setValue( i_val );
1173 oldControlVars[i] = comp_controls[i].f_value;
1175 CONNECT( compCtrl[i], valueChanged( int ), this, setInitValues() );
1177 ctrl_texts[i] = new QLabel( qtr( comp_controls[i].psz_descs ) + "\n" );
1178 ctrl_texts[i]->setFont( smallFont );
1179 ctrl_texts[i]->setAlignment( Qt::AlignHCenter );
1181 ctrl_readout[i] = new QLabel;
1182 ctrl_readout[i]->setFont( smallFont );
1183 ctrl_readout[i]->setAlignment( Qt::AlignHCenter );
1185 layout->addWidget( compCtrl[i], 1, i, Qt::AlignHCenter );
1186 layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
1187 layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
1190 BUTTONACT( enableCheck, enable() );
1192 /* Write down initial values */
1193 aout_instance_t *p_aout = THEMIM->getAout();
1198 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
1199 for( int i = 0; i < NUM_CP_CTRL; i++ )
1201 controlVars[i] = var_GetFloat( p_aout,
1202 comp_controls[i].psz_name );
1204 vlc_object_release( p_aout );
1208 psz_af = config_GetPsz( p_intf, "audio-filter" );
1209 for( int i = 0; i < NUM_CP_CTRL; i++ )
1211 controlVars[i] = config_GetFloat( p_intf,
1212 comp_controls[i].psz_name );
1215 if( psz_af && strstr( psz_af, "compressor" ) != NULL )
1217 enableCheck->setChecked( true );
1220 enable( enableCheck->isChecked() );
1221 updateSliders( controlVars );
1222 setValues( controlVars );
1225 void Compressor::enable()
1227 bool en = enableCheck->isChecked();
1228 aout_EnableFilter( THEPL, "compressor", en );
1232 void Compressor::enable( bool en )
1234 for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
1236 compCtrl[i]->setEnabled( en );
1237 ctrl_texts[i]->setEnabled( en );
1238 ctrl_readout[i]->setEnabled( en );
1242 void Compressor::updateSliders( float * controlVars )
1244 for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
1246 if( oldControlVars[i] != controlVars[i] )
1248 compCtrl[i]->setValue(
1249 (int)( controlVars[i] / comp_controls[i].f_resolution ) );
1254 void Compressor::setInitValues()
1256 setValues( controlVars );
1259 void Compressor::setValues( float * controlVars )
1261 aout_instance_t *p_aout = THEMIM->getAout();
1263 for( int i = 0 ; i < NUM_CP_CTRL ; i++ )
1265 float f = (float)( compCtrl[i]->value() ) * ( comp_controls[i].f_resolution );
1266 ctrl_readout[i]->setText( QString::number( f, 'f', 1 )
1267 + qtr( comp_controls[i].psz_units ) );
1268 if( oldControlVars[i] != f )
1272 var_SetFloat( p_aout, comp_controls[i].psz_name, f );
1274 config_PutFloat( p_intf, comp_controls[i].psz_name, f );
1275 oldControlVars[i] = f;
1280 vlc_object_release( p_aout );
1284 /**********************************************************************
1286 **********************************************************************/
1289 const char *psz_name;
1290 const char *psz_desc;
1293 static const spat_controls_t spat_controls[] =
1295 { "spatializer-roomsize", _("Size") },
1296 { "spatializer-width", _("Width") },
1297 { "spatializer-wet", _("Wet") },
1298 { "spatializer-dry", _("Dry") },
1299 { "spatializer-damp", _("Damp") },
1302 Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent )
1303 : QWidget( _parent ) , p_intf( _p_intf )
1305 QFont smallFont = QApplication::font();
1306 smallFont.setPointSize( smallFont.pointSize() - 3 );
1308 QGridLayout *layout = new QGridLayout( this );
1310 enableCheck = new QCheckBox( qtr( "Enable spatializer" ) );
1311 layout->addWidget( enableCheck, 0, 0, 1, NUM_SP_CTRL );
1313 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1315 spatCtrl[i] = new QSlider( Qt::Vertical );
1318 spatCtrl[i]->setMaximum( 10 );
1319 spatCtrl[i]->setValue( 2 );
1323 spatCtrl[i]->setMaximum( 10 );
1324 spatCtrl[i]->setValue( 0 );
1325 spatCtrl[i]->setMinimum( -10 );
1328 oldControlVars[i] = spatCtrl[i]->value();
1330 CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
1332 ctrl_texts[i] = new QLabel( qtr( spat_controls[i].psz_desc ) + "\n" );
1333 ctrl_texts[i]->setFont( smallFont );
1335 ctrl_readout[i] = new QLabel;
1336 ctrl_readout[i]->setFont( smallFont );
1338 layout->addWidget( spatCtrl[i], 1, i, Qt::AlignHCenter );
1339 layout->addWidget( ctrl_readout[i], 2, i, Qt::AlignHCenter );
1340 layout->addWidget( ctrl_texts[i], 3, i, Qt::AlignHCenter );
1343 BUTTONACT( enableCheck, enable() );
1345 /* Write down initial values */
1346 aout_instance_t *p_aout = THEMIM->getAout();
1351 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
1352 for( int i = 0; i < NUM_SP_CTRL ; i++ )
1354 controlVars[i] = var_GetFloat( p_aout, spat_controls[i].psz_name );
1356 vlc_object_release( p_aout );
1360 psz_af = config_GetPsz( p_intf, "audio-filter" );
1361 for( int i = 0; i < NUM_SP_CTRL ; i++ )
1363 controlVars[i] = config_GetFloat( p_intf, spat_controls[i].psz_name );
1366 if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
1367 enableCheck->setChecked( true );
1369 enable( enableCheck->isChecked() );
1370 setValues( controlVars );
1373 void Spatializer::enable()
1375 bool en = enableCheck->isChecked();
1376 aout_EnableFilter( THEPL, "spatializer", en );
1380 void Spatializer::enable( bool en )
1382 for( int i = 0 ; i< NUM_SP_CTRL; i++ )
1384 spatCtrl[i]->setEnabled( en );
1385 ctrl_texts[i]->setEnabled( en );
1386 ctrl_readout[i]->setEnabled( en );
1389 void Spatializer::setInitValues()
1391 setValues( controlVars );
1394 void Spatializer::setValues( float *controlVars )
1396 aout_instance_t *p_aout = THEMIM->getAout();
1398 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1400 float f = (float)( spatCtrl[i]->value() );
1401 ctrl_readout[i]->setText( QString::number( f, 'f', 1 ) );
1405 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1407 if( oldControlVars[i] != spatCtrl[i]->value() )
1409 var_SetFloat( p_aout, spat_controls[i].psz_name,
1410 ( float )spatCtrl[i]->value() );
1411 config_PutFloat( p_intf, spat_controls[i].psz_name,
1412 ( float ) spatCtrl[i]->value() );
1413 oldControlVars[i] = ( float ) spatCtrl[i]->value();
1416 vlc_object_release( p_aout );
1420 void Spatializer::delCallbacks( aout_instance_t *p_aout )
1422 // var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1423 // var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1426 void Spatializer::addCallbacks( aout_instance_t *p_aout )
1428 // var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1429 // var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1432 #include <QToolButton>
1433 #include <QGridLayout>
1435 SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
1436 QWidget( _parent ) , p_intf( _p_intf )
1438 QGroupBox *AVBox, *subsBox;
1440 QToolButton *moinsAV, *plusAV;
1441 QToolButton *moinssubs, *plussubs;
1442 QToolButton *moinssubSpeed, *plussubSpeed;
1444 QToolButton *updateButton;
1446 b_userAction = true;
1448 QGridLayout *mainLayout = new QGridLayout( this );
1451 AVBox = new QGroupBox( qtr( "Audio/Video" ) );
1452 QGridLayout *AVLayout = new QGridLayout( AVBox );
1454 moinsAV = new QToolButton;
1455 moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1456 moinsAV->setAutoRaise( true );
1457 moinsAV->setText( "-" );
1458 AVLayout->addWidget( moinsAV, 0, 1, 1, 1 );
1460 plusAV = new QToolButton;
1461 plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1462 plusAV->setAutoRaise( true );
1463 plusAV->setText( "+" );
1464 AVLayout->addWidget( plusAV, 0, 3, 1, 1 );
1466 QLabel *AVLabel = new QLabel;
1467 AVLabel->setText( qtr( "Advance of audio over video:" ) );
1468 AVLayout->addWidget( AVLabel, 0, 0, 1, 1 );
1470 AVSpin = new QDoubleSpinBox;
1471 AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
1472 AVSpin->setDecimals( 3 );
1473 AVSpin->setMinimum( -600.0 );
1474 AVSpin->setMaximum( 600.0 );
1475 AVSpin->setSingleStep( 0.1 );
1476 AVSpin->setToolTip( qtr( "A positive value means that\n"
1477 "the audio is ahead of the video" ) );
1478 AVSpin->setSuffix( " s" );
1479 AVLayout->addWidget( AVSpin, 0, 2, 1, 1 );
1480 mainLayout->addWidget( AVBox, 1, 0, 1, 5 );
1484 subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
1485 QGridLayout *subsLayout = new QGridLayout( subsBox );
1487 moinssubs = new QToolButton;
1488 moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1489 moinssubs->setAutoRaise( true );
1490 moinssubs->setText( "-" );
1491 subsLayout->addWidget( moinssubs, 0, 1, 1, 1 );
1493 plussubs = new QToolButton;
1494 plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1495 plussubs->setAutoRaise( true );
1496 plussubs->setText( "+" );
1497 subsLayout->addWidget( plussubs, 0, 3, 1, 1 );
1499 QLabel *subsLabel = new QLabel;
1500 subsLabel->setText( qtr( "Advance of subtitles over video:" ) );
1501 subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
1503 subsSpin = new QDoubleSpinBox;
1504 subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
1505 subsSpin->setDecimals( 3 );
1506 subsSpin->setMinimum( -600.0 );
1507 subsSpin->setMaximum( 600.0 );
1508 subsSpin->setSingleStep( 0.1 );
1509 subsSpin->setToolTip( qtr( "A positive value means that\n"
1510 "the subtitles are ahead of the video" ) );
1511 subsSpin->setSuffix( " s" );
1512 subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
1515 moinssubSpeed = new QToolButton;
1516 moinssubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
1517 moinssubSpeed->setAutoRaise( true );
1518 moinssubSpeed->setText( "-" );
1519 subsLayout->addWidget( moinssubSpeed, 1, 1, 1, 1 );
1521 plussubSpeed = new QToolButton;
1522 plussubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
1523 plussubSpeed->setAutoRaise( true );
1524 plussubSpeed->setText( "+" );
1525 subsLayout->addWidget( plussubSpeed, 1, 3, 1, 1 );
1527 QLabel *subSpeedLabel = new QLabel;
1528 subSpeedLabel->setText( qtr( "Speed of the subtitles:" ) );
1529 subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 1 );
1531 subSpeedSpin = new QDoubleSpinBox;
1532 subSpeedSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
1533 subSpeedSpin->setDecimals( 3 );
1534 subSpeedSpin->setMinimum( 1 );
1535 subSpeedSpin->setMaximum( 100 );
1536 subSpeedSpin->setSingleStep( 0.2 );
1537 subSpeedSpin->setSuffix( " fps" );
1538 subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
1540 mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
1542 updateButton = new QToolButton;
1543 updateButton->setAutoRaise( true );
1544 mainLayout->addWidget( updateButton, 0, 4, 1, 1 );
1547 /* Various Connects */
1548 CONNECT( moinsAV, clicked(), AVSpin, stepDown () );
1549 CONNECT( plusAV, clicked(), AVSpin, stepUp () );
1550 CONNECT( moinssubs, clicked(), subsSpin, stepDown () );
1551 CONNECT( plussubs, clicked(), subsSpin, stepUp () );
1552 CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
1553 CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
1554 CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
1555 CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
1556 CONNECT( subSpeedSpin, valueChanged ( double ),
1557 this, adjustSubsSpeed( double ) );
1559 CONNECT( THEMIM->getIM(), synchroChanged(), this, update() );
1560 BUTTON_SET_ACT_I( updateButton, "", update,
1561 qtr( "Force update of this dialog's values" ), update() );
1567 void SyncControls::clean()
1569 b_userAction = false;
1570 AVSpin->setValue( 0.0 );
1571 subsSpin->setValue( 0.0 );
1572 subSpeedSpin->setValue( 1.0 );
1573 b_userAction = true;
1576 void SyncControls::update()
1578 b_userAction = false;
1581 if( THEMIM->getInput() )
1583 i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
1584 AVSpin->setValue( ( (double)i_delay ) / 1000000 );
1585 i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
1586 subsSpin->setValue( ( (double)i_delay ) / 1000000 );
1587 subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
1589 b_userAction = true;
1592 void SyncControls::advanceAudio( double f_advance )
1594 if( THEMIM->getInput() && b_userAction )
1596 int64_t i_delay = f_advance * 1000000;
1597 var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
1601 void SyncControls::advanceSubs( double f_advance )
1603 if( THEMIM->getInput() && b_userAction )
1605 int64_t i_delay = f_advance * 1000000;
1606 var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
1610 void SyncControls::adjustSubsSpeed( double f_fps )
1612 if( THEMIM->getInput() && b_userAction )
1614 var_SetFloat( THEMIM->getInput(), "sub-fps", f_fps );
1618 /**********************************************************************
1619 * Video filters / Adjust
1620 **********************************************************************/
1622 /**********************************************************************
1623 * Extended playbak controls
1624 **********************************************************************/