1 /*****************************************************************************
2 * extended_panels.cpp : Extended controls panels
3 ****************************************************************************
4 * Copyright (C) 2006-2007 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 *****************************************************************************/
32 #include <QGridLayout>
33 #include <QSignalMapper>
36 #include "components/extended_panels.hpp"
37 #include "dialogs/preferences.hpp"
38 #include "dialogs_provider.hpp"
41 #include "../../audio_filter/equalizer_presets.h"
43 #include <vlc_intf_strings.h>
51 class ConfClickHandler : public QObject
54 ConfClickHandler( intf_thread_t *_p_intf, ExtVideo *_e ) : QObject ( _e ) {
55 e = _e; p_intf = _p_intf;
57 virtual ~ConfClickHandler() {}
58 bool eventFilter( QObject *obj, QEvent *evt )
60 if( evt->type() == QEvent::MouseButtonPress )
69 intf_thread_t *p_intf;
73 QString ModuleFromWidgetName( QObject *obj )
75 return obj->objectName().replace( "Enable","" );
78 QString OptionFromWidgetName( QObject *obj )
81 QString option = obj->objectName().replace( "Slider", "" )
82 .replace( "Combo" , "" )
83 .replace( "Dial" , "" )
84 .replace( "Check" , "" )
85 .replace( "Spin" , "" )
86 .replace( "Text" , "" );
87 for( char a = 'A'; a <= 'Z'; a++ )
89 option = option.replace( QString( a ),
90 QString( '-' ) + QString( a + 'a' - 'A' ) );
95 ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
98 ui.setupUi( _parent );
100 #define SETUP_VFILTER( widget ) \
102 vlc_object_t *p_obj = ( vlc_object_t * ) \
103 vlc_object_find_name( p_intf->p_libvlc, \
106 QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
107 QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
110 vlc_object_release( p_obj ); \
111 if( checkbox ) checkbox->setChecked( true ); \
112 else groupbox->setChecked( true ); \
116 if( checkbox ) checkbox->setChecked( false ); \
117 else groupbox->setChecked( false ); \
120 CONNECT( ui.widget##Enable, clicked(), this, updateFilters() );
121 #define SETUP_VFILTER_OPTION( widget, signal ) \
122 initComboBoxItems( ui.widget ); \
123 setWidgetValue( ui.widget ); \
124 CONNECT( ui.widget, signal, this, updateFilterOptions() );
126 SETUP_VFILTER( adjust )
127 SETUP_VFILTER_OPTION( hueSlider, valueChanged( int ) )
128 SETUP_VFILTER_OPTION( contrastSlider, valueChanged( int ) )
129 SETUP_VFILTER_OPTION( brightnessSlider, valueChanged( int ) )
130 SETUP_VFILTER_OPTION( saturationSlider, valueChanged( int ) )
131 SETUP_VFILTER_OPTION( gammaSlider, valueChanged( int ) )
132 SETUP_VFILTER_OPTION( brightnessThresholdCheck, stateChanged( int ) )
134 SETUP_VFILTER( extract )
135 SETUP_VFILTER_OPTION( extractComponentText, textChanged( QString ) )
137 SETUP_VFILTER( colorthres )
138 SETUP_VFILTER_OPTION( colorthresColorText, textChanged( QString ) )
139 SETUP_VFILTER_OPTION( colorthresSaturationthresSlider, valueChanged( int ) )
140 SETUP_VFILTER_OPTION( colorthresSimilaritythresSlider, valueChanged( int ) )
142 SETUP_VFILTER( invert )
144 SETUP_VFILTER( gradient )
145 SETUP_VFILTER_OPTION( gradientModeCombo, currentIndexChanged( QString ) )
146 SETUP_VFILTER_OPTION( gradientTypeCheck, stateChanged( int ) )
147 SETUP_VFILTER_OPTION( gradientCartoonCheck, stateChanged( int ) )
149 SETUP_VFILTER( motionblur )
150 SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged( int ) )
152 SETUP_VFILTER( motiondetect )
154 SETUP_VFILTER( noise )
156 SETUP_VFILTER( psychedelic )
158 SETUP_VFILTER( sharpen )
159 SETUP_VFILTER_OPTION( sharpenSigmaSlider, valueChanged( int ) )
161 SETUP_VFILTER( ripple )
163 SETUP_VFILTER( wave )
165 SETUP_VFILTER( transform )
166 SETUP_VFILTER_OPTION( transformTypeCombo, currentIndexChanged( QString ) )
168 SETUP_VFILTER( rotate )
169 SETUP_VFILTER_OPTION( rotateAngleDial, valueChanged( int ) )
170 ui.rotateAngleDial->setWrapping( true );
171 ui.rotateAngleDial->setNotchesVisible( true );
173 SETUP_VFILTER( puzzle )
174 SETUP_VFILTER_OPTION( puzzleRowsSpin, valueChanged( int ) )
175 SETUP_VFILTER_OPTION( puzzleColsSpin, valueChanged( int ) )
176 SETUP_VFILTER_OPTION( puzzleBlackSlotCheck, stateChanged( int ) )
178 SETUP_VFILTER( magnify )
180 SETUP_VFILTER( clone )
181 SETUP_VFILTER_OPTION( cloneCountSpin, valueChanged( int ) )
183 SETUP_VFILTER( wall )
184 SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
185 SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
187 SETUP_VFILTER( erase )
188 SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
189 SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
190 SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) )
192 SETUP_VFILTER( marq )
193 SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( QString ) )
194 SETUP_VFILTER_OPTION( marqPositionCombo, currentIndexChanged( QString ) )
196 SETUP_VFILTER( logo )
197 SETUP_VFILTER_OPTION( logoFileText, editingFinished() )
198 SETUP_VFILTER_OPTION( logoYSpin, valueChanged( int ) )
199 SETUP_VFILTER_OPTION( logoXSpin, valueChanged( int ) )
200 SETUP_VFILTER_OPTION( logoTransparencySlider, valueChanged( int ) )
203 #undef SETUP_VFILTER_OPTION
206 ExtVideo::~ExtVideo()
210 void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
212 vout_thread_t *p_vout;
213 char *psz_parser, *psz_string;
214 const char *psz_filter_type;
216 /* Please leave p_libvlc_global. This is where cached modules are
217 * stored. We're not trying to find a module instance. */
218 module_t *p_obj = module_Find( p_intf, psz_name );
221 msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name );
225 if( module_IsCapable( p_obj, "video filter2" ) )
227 psz_filter_type = "video-filter";
229 else if( module_IsCapable( p_obj, "video filter" ) )
231 psz_filter_type = "vout-filter";
233 else if( module_IsCapable( p_obj, "sub filter" ) )
235 psz_filter_type = "sub-filter";
240 msg_Err( p_intf, "Unknown video filter type." );
245 psz_string = config_GetPsz( p_intf, psz_filter_type );
247 if( !psz_string ) psz_string = strdup( "" );
249 psz_parser = strstr( psz_string, psz_name );
255 psz_parser = psz_string;
256 if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
257 psz_string, psz_name ) == -1 )
270 if( *( psz_parser + strlen( psz_name ) ) == ':' )
272 memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
273 strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
280 /* Remove trailing : : */
281 if( strlen( psz_string ) > 0 &&
282 *( psz_string + strlen( psz_string ) -1 ) == ':' )
284 *( psz_string + strlen( psz_string ) -1 ) = '\0';
293 /* Vout is not kept, so put that in the config */
294 config_PutPsz( p_intf, psz_filter_type, psz_string );
295 if( !strcmp( psz_filter_type, "video-filter" ) )
296 ui.videoFilterText->setText( psz_string );
297 else if( !strcmp( psz_filter_type, "vout-filter" ) )
298 ui.voutFilterText->setText( psz_string );
299 else if( !strcmp( psz_filter_type, "sub-filter" ) )
300 ui.subpictureFilterText->setText( psz_string );
302 /* Try to set on the fly */
303 p_vout = ( vout_thread_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT,
307 if( !strcmp( psz_filter_type, "sub-filter" ) )
308 var_SetString( p_vout->p_spu, psz_filter_type, psz_string );
310 var_SetString( p_vout, psz_filter_type, psz_string );
311 vlc_object_release( p_vout );
317 void ExtVideo::updateFilters()
319 QString module = ModuleFromWidgetName( sender() );
320 //std::cout << "Module name: " << module.toStdString() << std::endl;
322 QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
323 QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
325 ChangeVFiltersString( qtu( module ),
326 checkbox ? checkbox->isChecked()
327 : groupbox->isChecked() );
330 void ExtVideo::initComboBoxItems( QObject *widget )
332 QComboBox *combobox = qobject_cast<QComboBox*>( widget );
333 if( !combobox ) return;
334 QString option = OptionFromWidgetName( widget );
335 module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
339 int i_type = p_item->i_type & CONFIG_ITEM;
340 for( int i_index = 0; i_index < p_item->i_list; i_index++ )
342 if( i_type == CONFIG_ITEM_INTEGER
343 || i_type == CONFIG_ITEM_BOOL )
344 combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ),
345 p_item->pi_list[i_index] );
346 else if( i_type == CONFIG_ITEM_STRING )
347 combobox->addItem( qfu( p_item->ppsz_list_text[i_index] ),
348 p_item->ppsz_list[i_index] );
353 msg_Err( p_intf, "Couldn't find option \"%s\".",
358 void ExtVideo::setWidgetValue( QObject *widget )
360 QString module = ModuleFromWidgetName( widget->parent() );
361 //std::cout << "Module name: " << module.toStdString() << std::endl;
362 QString option = OptionFromWidgetName( widget );
363 //std::cout << "Option name: " << option.toStdString() << std::endl;
365 vlc_object_t *p_obj = ( vlc_object_t * )
366 vlc_object_find_name( p_intf->p_libvlc,
376 "Module instance %s not found, looking in config values.",
379 i_type = config_GetType( p_intf, qtu( option ) ) & 0xf0;
382 case VLC_VAR_INTEGER:
384 val.i_int = config_GetInt( p_intf, qtu( option ) );
387 val.f_float = config_GetFloat( p_intf, qtu( option ) );
390 val.psz_string = config_GetPsz( p_intf, qtu( option ) );
396 i_type = var_Type( p_obj, qtu( option ) ) & 0xf0;
397 var_Get( p_obj, qtu( option ), &val );
398 vlc_object_release( p_obj );
401 /* Try to cast to all the widgets we're likely to encounter. Only
402 * one of the casts is expected to work. */
403 QSlider *slider = qobject_cast<QSlider*> ( widget );
404 QCheckBox *checkbox = qobject_cast<QCheckBox*> ( widget );
405 QSpinBox *spinbox = qobject_cast<QSpinBox*> ( widget );
406 QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( widget );
407 QDial *dial = qobject_cast<QDial*> ( widget );
408 QLineEdit *lineedit = qobject_cast<QLineEdit*> ( widget );
409 QComboBox *combobox = qobject_cast<QComboBox*> ( widget );
411 if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
414 if( slider ) slider->setValue( val.i_int );
415 else if( checkbox ) checkbox->setCheckState( val.i_int? Qt::Checked
417 else if( spinbox ) spinbox->setValue( val.i_int );
418 else if( dial ) dial->setValue( ( 540-val.i_int )%360 );
422 sprintf( str, "%06X", val.i_int );
423 lineedit->setText( str );
425 else if( combobox ) combobox->setCurrentIndex(
426 combobox->findData( val.i_int ) );
427 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
429 else if( i_type == VLC_VAR_FLOAT )
432 if( slider ) slider->setValue( ( int )( val.f_float*( double )slider->tickInterval() ) ); /* hack alert! */
433 else if( doublespinbox ) doublespinbox->setValue( val.f_float );
434 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
436 else if( i_type == VLC_VAR_STRING )
438 if( lineedit ) lineedit->setText( qfu( val.psz_string ) );
439 else if( combobox ) combobox->setCurrentIndex(
440 combobox->findData( qfu( val.psz_string ) ) );
441 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
442 free( val.psz_string );
446 "Module %s's %s variable is of an unsupported type ( %d )",
452 void ExtVideo::updateFilterOptions()
454 QString module = ModuleFromWidgetName( sender()->parent() );
455 //std::cout << "Module name: " << module.toStdString() << std::endl;
456 QString option = OptionFromWidgetName( sender() );
457 //std::cout << "Option name: " << option.toStdString() << std::endl;
459 vlc_object_t *p_obj = ( vlc_object_t * )
460 vlc_object_find_name( p_intf->p_libvlc,
465 msg_Err( p_intf, "Module %s not found.", qtu( module ) );
469 int i_type = var_Type( p_obj, qtu( option ) );
470 bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
473 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.",
476 /* FIXME: restart automatically somewhere near the end of this function */
479 /* Try to cast to all the widgets we're likely to encounter. Only
480 * one of the casts is expected to work. */
481 QSlider *slider = qobject_cast<QSlider*> ( sender() );
482 QCheckBox *checkbox = qobject_cast<QCheckBox*> ( sender() );
483 QSpinBox *spinbox = qobject_cast<QSpinBox*> ( sender() );
484 QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox*>( sender() );
485 QDial *dial = qobject_cast<QDial*> ( sender() );
486 QLineEdit *lineedit = qobject_cast<QLineEdit*> ( sender() );
487 QComboBox *combobox = qobject_cast<QComboBox*> ( sender() );
490 if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
493 if( slider ) i_int = slider->value();
494 else if( checkbox ) i_int = checkbox->checkState() == Qt::Checked;
495 else if( spinbox ) i_int = spinbox->value();
496 else if( dial ) i_int = ( 540-dial->value() )%360;
497 else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
498 else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
499 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
500 config_PutInt( p_intf, qtu( option ), i_int );
503 if( i_type == VLC_VAR_INTEGER )
504 var_SetInteger( p_obj, qtu( option ), i_int );
506 var_SetBool( p_obj, qtu( option ), i_int );
509 else if( i_type == VLC_VAR_FLOAT )
512 if( slider ) f_float = ( double )slider->value()
513 / ( double )slider->tickInterval(); /* hack alert! */
514 else if( doublespinbox ) f_float = doublespinbox->value();
515 else if( lineedit ) f_float = lineedit->text().toDouble();
516 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
517 config_PutFloat( p_intf, qtu( option ), f_float );
519 var_SetFloat( p_obj, qtu( option ), f_float );
521 else if( i_type == VLC_VAR_STRING )
523 char *psz_string = NULL;
524 if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
525 else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
526 combobox->currentIndex() ).toString() ) );
527 else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
528 config_PutPsz( p_intf, qtu( option ), psz_string );
530 var_SetString( p_obj, qtu( option ), psz_string );
535 "Module %s's %s variable is of an unsupported type ( %d )",
540 vlc_object_release( p_obj );
544 void ExtVideo::gotoConf( QObject* src )
546 #define SHOWCONF( module ) \
547 if( src->objectName().contains( module ) ) \
549 PrefsDialog::getInstance( p_intf )->showModulePrefs( module ); \
553 SHOWCONF( "magnify" );
555 SHOWCONF( "ripple" );
556 SHOWCONF( "invert" );
557 SHOWCONF( "puzzle" );
559 SHOWCONF( "gradient" );
560 SHOWCONF( "colorthres" )
564 /**********************************************************************
566 **********************************************************************/
568 ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
569 : QWidget( _parent ), p_intf( _p_intf )
573 BUTTONACT( ui.refresh, Refresh() );
584 void ExtV4l2::showEvent( QShowEvent *event )
586 QWidget::showEvent( event );
590 void ExtV4l2::Refresh( void )
592 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
596 ui.vboxLayout->removeWidget( box );
602 msg_Dbg( p_intf, "Found v4l2 instance" );
603 vlc_value_t val, text, name;
604 int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
608 msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
610 vlc_object_release( p_obj );
614 box = new QGroupBox( this );
615 ui.vboxLayout->addWidget( box );
616 QVBoxLayout *layout = new QVBoxLayout( box );
617 box->setLayout( layout );
619 for( int i = 0; i < val.p_list->i_count; i++ )
621 const char *psz_var = text.p_list->p_values[i].psz_string;
622 var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &name, NULL );
623 const char *psz_label = name.psz_string;
624 msg_Dbg( p_intf, "v4l2 control \"%x\": %s (%s)",
625 val.p_list->p_values[i].i_int, psz_var, name.psz_string );
627 int i_type = var_Type( p_obj, psz_var );
628 switch( i_type & VLC_VAR_TYPE )
630 case VLC_VAR_INTEGER:
632 QLabel *label = new QLabel( psz_label, box );
633 QHBoxLayout *hlayout = new QHBoxLayout();
634 hlayout->addWidget( label );
635 int i_val = var_GetInteger( p_obj, psz_var );
636 if( i_type & VLC_VAR_HASCHOICE )
638 QComboBox *combobox = new QComboBox( box );
639 combobox->setObjectName( psz_var );
641 vlc_value_t val2, text2;
642 var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
644 for( int j = 0; j < val2.p_list->i_count; j++ )
647 text2.p_list->p_values[j].psz_string,
648 val2.p_list->p_values[j].i_int );
649 if( i_val == val2.p_list->p_values[j].i_int )
650 combobox->setCurrentIndex( j );
652 var_Change( p_obj, psz_var, VLC_VAR_FREELIST,
655 CONNECT( combobox, currentIndexChanged( int ), this,
656 ValueChange( int ) );
657 hlayout->addWidget( combobox );
661 QSlider *slider = new QSlider( box );
662 slider->setObjectName( psz_var );
663 slider->setOrientation( Qt::Horizontal );
665 var_Change( p_obj, psz_var, VLC_VAR_GETMIN,
667 slider->setMinimum( val2.i_int );
668 var_Change( p_obj, psz_var, VLC_VAR_GETMAX,
670 slider->setMaximum( val2.i_int );
671 var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
673 slider->setSingleStep( val2.i_int );
674 slider->setValue( i_val );
676 CONNECT( slider, valueChanged( int ), this,
677 ValueChange( int ) );
678 hlayout->addWidget( slider );
680 layout->addLayout( hlayout );
685 QCheckBox *button = new QCheckBox( psz_label, box );
686 button->setObjectName( psz_var );
687 button->setChecked( var_GetBool( p_obj, psz_var ) );
689 CONNECT( button, clicked( bool ), this,
690 ValueChange( bool ) );
691 layout->addWidget( button );
696 if( i_type & VLC_VAR_ISCOMMAND )
698 QPushButton *button = new QPushButton( psz_label, box );
699 button->setObjectName( psz_var );
701 CONNECT( button, clicked( bool ), this,
702 ValueChange( bool ) );
703 layout->addWidget( button );
707 QLabel *label = new QLabel( psz_label, box );
708 layout->addWidget( label );
713 msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
716 free( name.psz_string );
718 var_Change( p_obj, "controls", VLC_VAR_FREELIST, &val, &text );
719 vlc_object_release( p_obj );
723 msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
729 void ExtV4l2::ValueChange( bool value )
731 ValueChange( (int)value );
734 void ExtV4l2::ValueChange( int value )
736 QObject *s = sender();
737 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
740 char *psz_var = strdup( qtu( s->objectName() ) );
741 int i_type = var_Type( p_obj, psz_var );
742 switch( i_type & VLC_VAR_TYPE )
744 case VLC_VAR_INTEGER:
745 if( i_type & VLC_VAR_HASCHOICE )
747 QComboBox *combobox = qobject_cast<QComboBox*>( s );
748 value = combobox->itemData( value ).toInt();
750 var_SetInteger( p_obj, psz_var, value );
753 var_SetBool( p_obj, psz_var, value );
756 var_SetVoid( p_obj, psz_var );
760 vlc_object_release( p_obj );
764 msg_Warn( p_intf, "Oops, v4l2 object isn't available anymore" );
769 /**********************************************************************
771 **********************************************************************/
773 static const QString band_frequencies[] =
775 " 60 Hz ", " 170 Hz ", " 310 Hz ", " 600 Hz ", " 1 kHz ",
776 " 3 kHz ", " 6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
779 Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
780 QWidget( _parent ) , p_intf( _p_intf )
782 QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
783 smallFont.setPointSize( smallFont.pointSize() - 3 );
786 presetsComboBox = ui.presetsCombo;
788 ui.preampLabel->setFont( smallFont );
789 ui.preampSlider->setMaximum( 400 );
790 for( int i = 0 ; i < NB_PRESETS ; i ++ )
792 ui.presetsCombo->addItem( qtr( preset_list_text[i] ),
795 CONNECT( ui.presetsCombo, activated( int ), this, setPreset( int ) );
797 BUTTONACT( ui.enableCheck, enable() );
798 BUTTONACT( ui.eq2PassCheck, set2Pass() );
800 CONNECT( ui.preampSlider, valueChanged( int ), this, setPreamp() );
802 QGridLayout *grid = new QGridLayout( ui.frame );
803 grid->setMargin( 0 );
804 for( int i = 0 ; i < BANDS ; i++ )
806 bands[i] = new QSlider( Qt::Vertical );
807 bands[i]->setMaximum( 400 );
808 bands[i]->setValue( 200 );
809 CONNECT( bands[i], valueChanged( int ), this, setBand() );
810 band_texts[i] = new QLabel( band_frequencies[i] + "\n0.0dB" );
811 band_texts[i]->setFont( smallFont );
812 grid->addWidget( bands[i], 0, i );
813 grid->addWidget( band_texts[i], 1, i );
816 /* Write down initial values */
817 aout_instance_t *p_aout = ( aout_instance_t * )vlc_object_find( p_intf,
818 VLC_OBJECT_AOUT, FIND_ANYWHERE );
824 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
825 if( var_GetBool( p_aout, "equalizer-2pass" ) )
826 ui.eq2PassCheck->setChecked( true );
827 psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
828 f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
829 vlc_object_release( p_aout );
833 psz_af = config_GetPsz( p_intf, "audio-filter" );
834 if( config_GetInt( p_intf, "equalizer-2pass" ) )
835 ui.eq2PassCheck->setChecked( true );
836 psz_bands = config_GetPsz( p_intf, "equalizer-bands" );
837 f_preamp = config_GetFloat( p_intf, "equalizer-preamp" );
839 if( psz_af && strstr( psz_af, "equalizer" ) != NULL )
840 ui.enableCheck->setChecked( true );
842 enable( ui.enableCheck->isChecked() );
844 setValues( psz_bands, f_preamp );
847 Equalizer::~Equalizer()
851 void Equalizer::enable()
853 bool en = ui.enableCheck->isChecked();
854 aout_EnableFilter( VLC_OBJECT( p_intf ), "equalizer",
855 en ? VLC_TRUE : VLC_FALSE );
856 // aout_EnableFilter( VLC_OBJECT( p_intf ), "upmixer",
857 // en ? VLC_TRUE : VLC_FALSE );
858 // aout_EnableFilter( VLC_OBJECT( p_intf ), "vsurround",
859 // en ? VLC_TRUE : VLC_FALSE );
863 void Equalizer::enable( bool en )
865 ui.eq2PassCheck->setEnabled( en );
866 ui.preampLabel->setEnabled( en );
867 ui.preampSlider->setEnabled( en );
868 for( int i = 0 ; i< BANDS; i++ )
870 bands[i]->setEnabled( en ); band_texts[i]->setEnabled( en );
874 void Equalizer::set2Pass()
876 aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
877 VLC_OBJECT_AOUT, FIND_ANYWHERE );
878 vlc_bool_t b_2p = ui.eq2PassCheck->isChecked();
881 config_PutInt( p_intf, "equalizer-2pass", b_2p );
884 var_SetBool( p_aout, "equalizer-2pass", b_2p );
885 config_PutInt( p_intf, "equalizer-2pass", b_2p );
886 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
888 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
890 vlc_object_release( p_aout );
894 void Equalizer::setPreamp()
896 float f= ( float )( ui.preampSlider->value() ) /10 - 20;
898 aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
899 VLC_OBJECT_AOUT, FIND_ANYWHERE );
901 sprintf( psz_val, "%.1f", f );
902 ui.preampLabel->setText( qtr( "Preamp\n" ) + psz_val + qtr( "dB" ) );
905 delCallbacks( p_aout );
906 var_SetFloat( p_aout, "equalizer-preamp", f );
907 addCallbacks( p_aout );
908 vlc_object_release( p_aout );
910 config_PutFloat( p_intf, "equalizer-preamp", f );
913 void Equalizer::setBand()
915 char psz_values[102]; memset( psz_values, 0, 102 );
917 /**\todo smoothing */
919 for( int i = 0 ; i< BANDS ; i++ )
922 float f_val = ( float )( bands[i]->value() ) / 10 - 20 ;
923 sprintf( psz_values, "%s %f", psz_values, f_val );
924 sprintf( psz_val, "% 5.1f", f_val );
925 band_texts[i]->setText( band_frequencies[i] + "\n" + psz_val + "dB" );
927 aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
928 VLC_OBJECT_AOUT, FIND_ANYWHERE );
931 delCallbacks( p_aout );
932 var_SetString( p_aout, "equalizer-bands", psz_values );
933 addCallbacks( p_aout );
934 vlc_object_release( p_aout );
937 void Equalizer::setValues( char *psz_bands, float f_preamp )
942 for( int i = 0; i < 10; i++ )
945 float f = strtof( p, &p );
946 int i_val= ( int )( ( f + 20 ) * 10 );
947 bands[i]->setValue( i_val );
948 sprintf( psz_val, "% 5.1f", f );
949 band_texts[i]->setText( band_frequencies[i] + "\n" + psz_val +
951 if( p == NULL || *p == '\0' ) break;
953 if( *p == '\0' ) break;
957 int i_val = ( int )( ( f_preamp + 20 ) * 10 );
958 sprintf( psz_val, "%.1f", f_preamp );
959 ui.preampSlider->setValue( i_val );
960 ui.preampLabel->setText( qtr( "Preamp\n" ) + psz_val + qtr( "dB" ) );
963 void Equalizer::setPreset( int preset )
965 aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
966 VLC_OBJECT_AOUT, FIND_ANYWHERE );
968 char psz_values[102]; memset( psz_values, 0, 102 );
969 for( int i = 0 ; i< 10 ;i++ )
970 sprintf( psz_values, "%s %.1f", psz_values,
971 eqz_preset_10b[preset]->f_amp[i] );
975 delCallbacks( p_aout );
976 var_SetString( p_aout, "equalizer-bands", psz_values );
977 var_SetFloat( p_aout, "equalizer-preamp",
978 eqz_preset_10b[preset]->f_preamp );
979 addCallbacks( p_aout );
980 vlc_object_release( p_aout );
982 config_PutPsz( p_intf, "equalizer-bands", psz_values );
983 config_PutFloat( p_intf, "equalizer-preamp",
984 eqz_preset_10b[preset]->f_preamp );
986 setValues( psz_values, eqz_preset_10b[preset]->f_preamp );
989 static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
990 vlc_value_t oldval, vlc_value_t newval, void *p_data )
992 char *psz_preset = newval.psz_string;
993 Equalizer *eq = ( Equalizer * )p_data;
994 eq->presetsComboBox->setCurrentIndex( eq->presetsComboBox->findText( qfu( psz_preset ) ) );
998 void Equalizer::delCallbacks( aout_instance_t *p_aout )
1000 //var_DelCallback( p_aout, "equalizer-bands", EqzCallback, this );
1001 //var_DelCallback( p_aout, "equalizer-preamp", EqzCallback, this );
1002 var_DelCallback( p_aout, "equalizer-preset", PresetCallback, this );
1005 void Equalizer::addCallbacks( aout_instance_t *p_aout )
1007 //var_AddCallback( p_aout, "equalizer-bands", EqzCallback, this );
1008 //var_AddCallback( p_aout, "equalizer-preamp", EqzCallback, this );
1009 var_AddCallback( p_aout, "equalizer-preset", PresetCallback, this );
1012 /**********************************************************************
1014 **********************************************************************/
1016 /**********************************************************************
1018 **********************************************************************/
1019 static const char *psz_control_names[] =
1021 "Roomsize", "Width" , "Wet", "Dry", "Damp"
1024 Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
1025 QWidget( _parent ) , p_intf( _p_intf )
1027 QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
1028 smallFont.setPointSize( smallFont.pointSize() - 3 );
1030 QGridLayout *layout = new QGridLayout( this );
1031 layout->setMargin( 0 );
1033 enableCheck = new QCheckBox( qfu( "Enable spatializer" ) );
1034 layout->addWidget( enableCheck, 0, 0, 1, NUM_SP_CTRL );
1036 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1038 spatCtrl[i] = new QSlider( Qt::Vertical );
1041 spatCtrl[i]->setMaximum( 10 );
1042 spatCtrl[i]->setValue( 2 );
1046 spatCtrl[i]->setMaximum( 10 );
1047 spatCtrl[i]->setValue( 0 );
1048 spatCtrl[i]->setMinimum( -10 );
1050 oldControlVars[i] = spatCtrl[i]->value();
1051 CONNECT( spatCtrl[i], valueChanged( int ), this, setInitValues() );
1052 ctrl_texts[i] = new QLabel( qfu( psz_control_names[i] ) + "\n" );
1053 ctrl_texts[i]->setFont( smallFont );
1054 ctrl_readout[i] = new QLabel( "" );
1055 ctrl_readout[i]->setFont( smallFont );
1056 layout->addWidget( spatCtrl[i], 1, i );
1057 layout->addWidget( ctrl_readout[i], 2, i );
1058 layout->addWidget( ctrl_texts[i], 3, i );
1061 BUTTONACT( enableCheck, enable() );
1063 /* Write down initial values */
1064 aout_instance_t *p_aout = ( aout_instance_t * )
1065 vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
1070 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
1071 for( int i = 0; i < NUM_SP_CTRL ; i++ )
1073 controlVars[i] = var_GetFloat( p_aout, psz_control_names[i] );
1075 vlc_object_release( p_aout );
1079 psz_af = config_GetPsz( p_intf, "audio-filter" );
1080 for( int i = 0; i < NUM_SP_CTRL ; i++ )
1082 controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
1085 if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
1086 enableCheck->setChecked( true );
1088 enable( enableCheck->isChecked() );
1089 setValues( controlVars );
1092 Spatializer::~Spatializer()
1096 void Spatializer::enable()
1098 bool en = enableCheck->isChecked();
1099 aout_EnableFilter( VLC_OBJECT( p_intf ), "spatializer",
1100 en ? VLC_TRUE : VLC_FALSE );
1104 void Spatializer::enable( bool en )
1106 for( int i = 0 ; i< NUM_SP_CTRL; i++ )
1108 spatCtrl[i]->setEnabled( en );
1109 ctrl_texts[i]->setEnabled( en );
1110 ctrl_readout[i]->setEnabled( en );
1113 void Spatializer::setInitValues()
1115 setValues( controlVars );
1118 void Spatializer::setValues( float *controlVars )
1122 aout_instance_t *p_aout= ( aout_instance_t * )
1123 vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
1125 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1127 float f= ( float )( spatCtrl[i]->value() );
1128 sprintf( psz_val, "%.1f", f );
1129 ctrl_readout[i]->setText( psz_val );
1133 for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1135 if( oldControlVars[i] != spatCtrl[i]->value() )
1137 var_SetFloat( p_aout, psz_control_names[i],
1138 ( float )spatCtrl[i]->value() );
1139 config_PutFloat( p_intf, psz_control_names[i],
1140 ( float ) spatCtrl[i]->value() );
1141 oldControlVars[i] = ( float ) spatCtrl[i]->value();
1144 vlc_object_release( p_aout );
1148 void Spatializer::delCallbacks( aout_instance_t *p_aout )
1150 // var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1151 // var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1154 void Spatializer::addCallbacks( aout_instance_t *p_aout )
1156 // var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1157 // var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1160 #include <QToolButton>
1161 #include <QGridLayout>
1163 SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
1164 QWidget( _parent ) , p_intf( _p_intf )
1166 QGroupBox *AVBox, *subsBox;
1167 QToolButton *moinsAV, *plusAV;
1169 QToolButton *moinssubs, *plussubs;
1171 QVBoxLayout *vboxLayout = new QVBoxLayout( this );
1173 AVBox = new QGroupBox( qtr( "Audio/Video" ) );
1174 QGridLayout *gridLayout = new QGridLayout( AVBox );
1176 moinsAV = new QToolButton;
1177 moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1178 moinsAV->setAutoRaise( true );
1179 moinsAV->setText( "-" );
1180 gridLayout->addWidget( moinsAV, 1, 0, 1, 1 );
1182 plusAV = new QToolButton;
1183 plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1184 plusAV->setAutoRaise( true );
1185 plusAV->setText( "+" );
1186 gridLayout->addWidget( plusAV, 1, 2, 1, 1 );
1188 QLabel *AVLabel = new QLabel;
1189 AVLabel->setText( qtr( "Advance of audio over video" ) );
1190 gridLayout->addWidget( AVLabel, 0, 0, 1, 3 );
1192 AVSpin = new QDoubleSpinBox;
1193 AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
1194 AVSpin->setDecimals( 3 );
1195 AVSpin->setMinimum( -100 );
1196 AVSpin->setMaximum( 100 );
1197 AVSpin->setSingleStep( 0.1 );
1198 AVSpin->setToolTip( qtr( "A positive value means that\n"
1199 "the audio is ahead of the video" ) );
1200 AVSpin->setSuffix( "ms" );
1201 gridLayout->addWidget( AVSpin, 1, 1, 1, 1 );
1202 vboxLayout->addWidget( AVBox );
1205 subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
1206 QGridLayout *subsLayout = new QGridLayout( subsBox );
1208 moinssubs = new QToolButton;
1209 moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1210 moinssubs->setAutoRaise( true );
1211 moinssubs->setText( "-" );
1212 subsLayout->addWidget( moinssubs, 1, 0, 1, 1 );
1214 plussubs = new QToolButton;
1215 plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1216 plussubs->setAutoRaise( true );
1217 plussubs->setText( "+" );
1218 subsLayout->addWidget( plussubs, 1, 2, 1, 1 );
1220 QLabel *subsLabel = new QLabel;
1221 subsLabel->setText( qtr( "Advance of subtitles over video" ) );
1222 subsLayout->addWidget( subsLabel, 0, 0, 1, 3 );
1224 subsSpin = new QDoubleSpinBox;
1225 subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
1226 subsSpin->setDecimals( 3 );
1227 subsSpin->setMinimum( -100 );
1228 subsSpin->setMaximum( 100 );
1229 subsSpin->setSingleStep( 0.1 );
1230 subsSpin->setToolTip( qtr( "A positive value means that\n"
1231 "the subtitles are ahead of the video" ) );
1232 subsSpin->setSuffix( "ms" );
1233 subsLayout->addWidget( subsSpin, 1, 1, 1, 1 );
1234 vboxLayout->addWidget( subsBox );
1237 /**********************************************************************
1238 * Video filters / Adjust
1239 **********************************************************************/
1241 /**********************************************************************
1242 * Extended playbak controls
1243 **********************************************************************/