]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/extended_panels.cpp
Start of the work for the audio/video/subs synchronisation
[vlc] / modules / gui / qt4 / components / extended_panels.cpp
1 /*****************************************************************************
2  * extended_panels.cpp : Extended controls panels
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Antoine Cellerier <dionoea .t videolan d@t org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27
28 #include <QLabel>
29 #include <QVariant>
30 #include <QString>
31 #include <QFont>
32 #include <QGridLayout>
33 #include <QSignalMapper>
34 #include <QComboBox>
35
36 #include "components/extended_panels.hpp"
37 #include "dialogs/preferences.hpp"
38 #include "dialogs_provider.hpp"
39 #include "qt4.hpp"
40
41 #include "../../audio_filter/equalizer_presets.h"
42 #include <vlc_aout.h>
43 #include <vlc_intf_strings.h>
44 #include <vlc_vout.h>
45 #include <vlc_osd.h>
46
47 #include <iostream>
48 #include <string.h>
49
50 #if 0
51 class ConfClickHandler : public QObject
52 {
53 public:
54     ConfClickHandler( intf_thread_t *_p_intf, ExtVideo *_e ) : QObject ( _e ) {
55         e = _e; p_intf = _p_intf;
56     }
57     virtual ~ConfClickHandler() {}
58     bool eventFilter( QObject *obj, QEvent *evt )
59     {
60         if( evt->type() == QEvent::MouseButtonPress )
61         {
62             e->gotoConf( obj );
63             return true;
64         }
65         return false;
66     }
67 private:
68     ExtVideo* e;
69     intf_thread_t *p_intf;
70 };
71 #endif
72
73 QString ModuleFromWidgetName( QObject *obj )
74 {
75     return obj->objectName().replace( "Enable","" );
76 }
77
78 QString OptionFromWidgetName( QObject *obj )
79 {
80     /* Gruik ? ... nah */
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++ )
88     {
89         option = option.replace( QString( a ),
90                                  QString( '-' ) + QString( a + 'a' - 'A' ) );
91     }
92     return option;
93 }
94
95 ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
96                            p_intf( _p_intf )
97 {
98     ui.setupUi( _parent );
99
100 #define SETUP_VFILTER( widget ) \
101     { \
102         vlc_object_t *p_obj = ( vlc_object_t * ) \
103             vlc_object_find_name( p_intf->p_libvlc, \
104                                   #widget, \
105                                   FIND_CHILD ); \
106         QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
107         QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
108         if( p_obj ) \
109         { \
110             vlc_object_release( p_obj ); \
111             if( checkbox ) checkbox->setChecked( true ); \
112             else groupbox->setChecked( true ); \
113         } \
114         else \
115         { \
116             if( checkbox ) checkbox->setChecked( false ); \
117             else groupbox->setChecked( false ); \
118         } \
119     } \
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() );
125
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 ) )
133
134     SETUP_VFILTER( extract )
135     SETUP_VFILTER_OPTION( extractComponentText, textChanged( QString ) )
136
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 ) )
141
142     SETUP_VFILTER( invert )
143
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 ) )
148
149     SETUP_VFILTER( motionblur )
150     SETUP_VFILTER_OPTION( blurFactorSlider, valueChanged( int ) )
151
152     SETUP_VFILTER( motiondetect )
153
154     SETUP_VFILTER( noise )
155
156     SETUP_VFILTER( psychedelic )
157
158     SETUP_VFILTER( sharpen )
159     SETUP_VFILTER_OPTION( sharpenSigmaSlider, valueChanged( int ) )
160
161     SETUP_VFILTER( ripple )
162
163     SETUP_VFILTER( wave )
164
165     SETUP_VFILTER( transform )
166     SETUP_VFILTER_OPTION( transformTypeCombo, currentIndexChanged( QString ) )
167
168     SETUP_VFILTER( rotate )
169     SETUP_VFILTER_OPTION( rotateAngleDial, valueChanged( int ) )
170     ui.rotateAngleDial->setWrapping( true );
171     ui.rotateAngleDial->setNotchesVisible( true );
172
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 ) )
177
178     SETUP_VFILTER( magnify )
179
180     SETUP_VFILTER( clone )
181     SETUP_VFILTER_OPTION( cloneCountSpin, valueChanged( int ) )
182
183     SETUP_VFILTER( wall )
184     SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
185     SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
186
187     SETUP_VFILTER( erase )
188     SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
189     SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
190     SETUP_VFILTER_OPTION( eraseXSpin, valueChanged( int ) )
191
192     SETUP_VFILTER( marq )
193     SETUP_VFILTER_OPTION( marqMarqueeText, textChanged( QString ) )
194     SETUP_VFILTER_OPTION( marqPositionCombo, currentIndexChanged( QString ) )
195
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 ) )
201
202 #undef SETUP_VFILTER
203 #undef SETUP_VFILTER_OPTION
204 }
205
206 ExtVideo::~ExtVideo()
207 {
208 }
209
210 void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
211 {
212     vout_thread_t *p_vout;
213     char *psz_parser, *psz_string;
214     const char *psz_filter_type;
215
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 );
219     if( !p_obj )
220     {
221         msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name );
222         return;
223     }
224
225     if( module_IsCapable( p_obj, "video filter2" ) )
226     {
227         psz_filter_type = "video-filter";
228     }
229     else if( module_IsCapable( p_obj, "video filter" ) )
230     {
231         psz_filter_type = "vout-filter";
232     }
233     else if( module_IsCapable( p_obj, "sub filter" ) )
234     {
235         psz_filter_type = "sub-filter";
236     }
237     else
238     {
239         module_Put( p_obj );
240         msg_Err( p_intf, "Unknown video filter type." );
241         return;
242     }
243     module_Put( p_obj );
244
245     psz_string = config_GetPsz( p_intf, psz_filter_type );
246
247     if( !psz_string ) psz_string = strdup( "" );
248
249     psz_parser = strstr( psz_string, psz_name );
250
251     if( b_add )
252     {
253         if( !psz_parser )
254         {
255             psz_parser = psz_string;
256             if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
257                             psz_string, psz_name ) == -1 )
258                 return;
259             free( psz_parser );
260         }
261         else
262         {
263             return;
264         }
265     }
266     else
267     {
268         if( psz_parser )
269         {
270             if( *( psz_parser + strlen( psz_name ) ) == ':' )
271             {
272                 memmove( psz_parser, psz_parser + strlen( psz_name ) + 1,
273                          strlen( psz_parser + strlen( psz_name ) + 1 ) + 1 );
274             }
275             else
276             {
277                 *psz_parser = '\0';
278             }
279
280             /* Remove trailing : : */
281             if( strlen( psz_string ) > 0 &&
282                 *( psz_string + strlen( psz_string ) -1 ) == ':' )
283             {
284                 *( psz_string + strlen( psz_string ) -1 ) = '\0';
285             }
286         }
287         else
288         {
289             free( psz_string );
290             return;
291         }
292     }
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 );
301
302     /* Try to set on the fly */
303     p_vout = ( vout_thread_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT,
304                                               FIND_ANYWHERE );
305     if( p_vout )
306     {
307         if( !strcmp( psz_filter_type, "sub-filter" ) )
308             var_SetString( p_vout->p_spu, psz_filter_type, psz_string );
309         else
310             var_SetString( p_vout, psz_filter_type, psz_string );
311         vlc_object_release( p_vout );
312     }
313
314     free( psz_string );
315 }
316
317 void ExtVideo::updateFilters()
318 {
319     QString module = ModuleFromWidgetName( sender() );
320     //std::cout << "Module name: " << module.toStdString() << std::endl;
321
322     QCheckBox *checkbox = qobject_cast<QCheckBox*>( sender() );
323     QGroupBox *groupbox = qobject_cast<QGroupBox*>( sender() );
324
325     ChangeVFiltersString( qtu( module ),
326                           checkbox ? checkbox->isChecked()
327                                    : groupbox->isChecked() );
328 }
329
330 void ExtVideo::initComboBoxItems( QObject *widget )
331 {
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 ),
336                                                  qtu( option ) );
337     if( p_item )
338     {
339         int i_type = p_item->i_type & CONFIG_ITEM;
340         for( int i_index = 0; i_index < p_item->i_list; i_index++ )
341         {
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] );
349         }
350     }
351     else
352     {
353         msg_Err( p_intf, "Couldn't find option \"%s\".",
354                  qtu( option ) );
355     }
356 }
357
358 void ExtVideo::setWidgetValue( QObject *widget )
359 {
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;
364
365     vlc_object_t *p_obj = ( vlc_object_t * )
366         vlc_object_find_name( p_intf->p_libvlc,
367                               qtu( module ),
368                               FIND_CHILD );
369     int i_type;
370     vlc_value_t val;
371
372     if( !p_obj )
373     {
374 #if 0
375         msg_Dbg( p_intf,
376                  "Module instance %s not found, looking in config values.",
377                  qtu( module ) );
378 #endif
379         i_type = config_GetType( p_intf, qtu( option ) ) & 0xf0;
380         switch( i_type )
381         {
382             case VLC_VAR_INTEGER:
383             case VLC_VAR_BOOL:
384                 val.i_int = config_GetInt( p_intf, qtu( option ) );
385                 break;
386             case VLC_VAR_FLOAT:
387                 val.f_float = config_GetFloat( p_intf, qtu( option ) );
388                 break;
389             case VLC_VAR_STRING:
390                 val.psz_string = config_GetPsz( p_intf, qtu( option ) );
391                 break;
392         }
393     }
394     else
395     {
396         i_type = var_Type( p_obj, qtu( option ) ) & 0xf0;
397         var_Get( p_obj, qtu( option ), &val );
398         vlc_object_release( p_obj );
399     }
400
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 );
410
411     if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
412     {
413         int i_int = 0;
414         if( slider )        slider->setValue( val.i_int );
415         else if( checkbox ) checkbox->setCheckState( val.i_int? Qt::Checked
416                                                               : Qt::Unchecked );
417         else if( spinbox )  spinbox->setValue( val.i_int );
418         else if( dial )     dial->setValue( ( 540-val.i_int )%360 );
419         else if( lineedit )
420         {
421             char str[30];
422             sprintf( str, "%06X", val.i_int );
423             lineedit->setText( str );
424         }
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__ );
428     }
429     else if( i_type == VLC_VAR_FLOAT )
430     {
431         double f_float = 0;
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__ );
435     }
436     else if( i_type == VLC_VAR_STRING )
437     {
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 );
443     }
444     else
445         msg_Err( p_intf,
446                  "Module %s's %s variable is of an unsupported type ( %d )",
447                  qtu( module ),
448                  qtu( option ),
449                  i_type );
450 }
451
452 void ExtVideo::updateFilterOptions()
453 {
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;
458
459     vlc_object_t *p_obj = ( vlc_object_t * )
460         vlc_object_find_name( p_intf->p_libvlc,
461                               qtu( module ),
462                               FIND_CHILD );
463     if( !p_obj )
464     {
465         msg_Err( p_intf, "Module %s not found.", qtu( module ) );
466         return;
467     }
468
469     int i_type = var_Type( p_obj, qtu( option ) );
470     bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
471     if( !b_is_command )
472     {
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.",
474                  qtu( module ),
475                  qtu( option ) );
476         /* FIXME: restart automatically somewhere near the end of this function */
477     }
478
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() );
488
489     i_type &= 0xf0;
490     if( i_type == VLC_VAR_INTEGER || i_type == VLC_VAR_BOOL )
491     {
492         int i_int = 0;
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 );
501         if( b_is_command )
502         {
503             if( i_type == VLC_VAR_INTEGER )
504                 var_SetInteger( p_obj, qtu( option ), i_int );
505             else
506                 var_SetBool( p_obj, qtu( option ), i_int );
507         }
508     }
509     else if( i_type == VLC_VAR_FLOAT )
510     {
511         double f_float = 0;
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 );
518         if( b_is_command )
519             var_SetFloat( p_obj, qtu( option ), f_float );
520     }
521     else if( i_type == VLC_VAR_STRING )
522     {
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 );
529         if( b_is_command )
530             var_SetString( p_obj, qtu( option ), psz_string );
531         free( psz_string );
532     }
533     else
534         msg_Err( p_intf,
535                  "Module %s's %s variable is of an unsupported type ( %d )",
536                  qtu( module ),
537                  qtu( option ),
538                  i_type );
539
540     vlc_object_release( p_obj );
541 }
542
543 #if 0
544 void ExtVideo::gotoConf( QObject* src )
545 {
546 #define SHOWCONF( module ) \
547     if( src->objectName().contains( module ) ) \
548     { \
549         PrefsDialog::getInstance( p_intf )->showModulePrefs( module ); \
550         return; \
551     }
552     SHOWCONF( "clone" );
553     SHOWCONF( "magnify" );
554     SHOWCONF( "wave" );
555     SHOWCONF( "ripple" );
556     SHOWCONF( "invert" );
557     SHOWCONF( "puzzle" );
558     SHOWCONF( "wall" );
559     SHOWCONF( "gradient" );
560     SHOWCONF( "colorthres" )
561 }
562 #endif
563
564 /**********************************************************************
565  * v4l2 controls
566  **********************************************************************/
567
568 ExtV4l2::ExtV4l2( intf_thread_t *_p_intf, QWidget *_parent )
569     : QWidget( _parent ), p_intf( _p_intf )
570 {
571     ui.setupUi( this );
572
573     BUTTONACT( ui.refresh, Refresh() );
574
575     box = NULL;
576 }
577
578 ExtV4l2::~ExtV4l2()
579 {
580     if( box )
581         delete box;
582 }
583
584 void ExtV4l2::showEvent( QShowEvent *event )
585 {
586     QWidget::showEvent( event );
587     Refresh();
588 }
589
590 void ExtV4l2::Refresh( void )
591 {
592     vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
593     ui.help->hide();
594     if( box )
595     {
596         ui.vboxLayout->removeWidget( box );
597         delete box;
598         box = NULL;
599     }
600     if( p_obj )
601     {
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,
605                                 &val, &text );
606         if( i_ret < 0 )
607         {
608             msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
609             ui.help->show();
610             vlc_object_release( p_obj );
611             return;
612         }
613
614         box = new QGroupBox( this );
615         ui.vboxLayout->addWidget( box );
616         QVBoxLayout *layout = new QVBoxLayout( box );
617         box->setLayout( layout );
618
619         for( int i = 0; i < val.p_list->i_count; i++ )
620         {
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 );
626
627             int i_type = var_Type( p_obj, psz_var );
628             switch( i_type & VLC_VAR_TYPE )
629             {
630                 case VLC_VAR_INTEGER:
631                 {
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 )
637                     {
638                         QComboBox *combobox = new QComboBox( box );
639                         combobox->setObjectName( psz_var );
640
641                         vlc_value_t val2, text2;
642                         var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
643                                     &val2, &text2 );
644                         for( int j = 0; j < val2.p_list->i_count; j++ )
645                         {
646                             combobox->addItem(
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 );
651                         }
652                         var_Change( p_obj, psz_var, VLC_VAR_FREELIST,
653                                     &val2, &text2 );
654
655                         CONNECT( combobox, currentIndexChanged( int ), this,
656                                  ValueChange( int ) );
657                         hlayout->addWidget( combobox );
658                     }
659                     else
660                     {
661                         QSlider *slider = new QSlider( box );
662                         slider->setObjectName( psz_var );
663                         slider->setOrientation( Qt::Horizontal );
664                         vlc_value_t val2;
665                         var_Change( p_obj, psz_var, VLC_VAR_GETMIN,
666                                     &val2, NULL );
667                         slider->setMinimum( val2.i_int );
668                         var_Change( p_obj, psz_var, VLC_VAR_GETMAX,
669                                     &val2, NULL );
670                         slider->setMaximum( val2.i_int );
671                         var_Change( p_obj, psz_var, VLC_VAR_GETSTEP,
672                                     &val2, NULL );
673                         slider->setSingleStep( val2.i_int );
674                         slider->setValue( i_val );
675
676                         CONNECT( slider, valueChanged( int ), this,
677                                  ValueChange( int ) );
678                         hlayout->addWidget( slider );
679                     }
680                     layout->addLayout( hlayout );
681                     break;
682                 }
683                 case VLC_VAR_BOOL:
684                 {
685                     QCheckBox *button = new QCheckBox( psz_label, box );
686                     button->setObjectName( psz_var );
687                     button->setChecked( var_GetBool( p_obj, psz_var ) );
688
689                     CONNECT( button, clicked( bool ), this,
690                              ValueChange( bool ) );
691                     layout->addWidget( button );
692                     break;
693                 }
694                 case VLC_VAR_VOID:
695                 {
696                     if( i_type & VLC_VAR_ISCOMMAND )
697                     {
698                         QPushButton *button = new QPushButton( psz_label, box );
699                         button->setObjectName( psz_var );
700
701                         CONNECT( button, clicked( bool ), this,
702                                  ValueChange( bool ) );
703                         layout->addWidget( button );
704                     }
705                     else
706                     {
707                         QLabel *label = new QLabel( psz_label, box );
708                         layout->addWidget( label );
709                     }
710                     break;
711                 }
712                 default:
713                     msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
714                     break;
715             }
716             free( name.psz_string );
717         }
718         var_Change( p_obj, "controls", VLC_VAR_FREELIST, &val, &text );
719         vlc_object_release( p_obj );
720     }
721     else
722     {
723         msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
724         ui.help->show();
725     }
726
727 }
728
729 void ExtV4l2::ValueChange( bool value )
730 {
731     ValueChange( (int)value );
732 }
733
734 void ExtV4l2::ValueChange( int value )
735 {
736     QObject *s = sender();
737     vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
738     if( p_obj )
739     {
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 )
743         {
744             case VLC_VAR_INTEGER:
745                 if( i_type & VLC_VAR_HASCHOICE )
746                 {
747                     QComboBox *combobox = qobject_cast<QComboBox*>( s );
748                     value = combobox->itemData( value ).toInt();
749                 }
750                 var_SetInteger( p_obj, psz_var, value );
751                 break;
752             case VLC_VAR_BOOL:
753                 var_SetBool( p_obj, psz_var, value );
754                 break;
755             case VLC_VAR_VOID:
756                 var_SetVoid( p_obj, psz_var );
757                 break;
758         }
759         free( psz_var );
760         vlc_object_release( p_obj );
761     }
762     else
763     {
764         msg_Warn( p_intf, "Oops, v4l2 object isn't available anymore" );
765         Refresh();
766     }
767 }
768
769 /**********************************************************************
770  * Equalizer
771  **********************************************************************/
772
773 static const QString band_frequencies[] =
774 {
775     "  60 Hz  ", " 170 Hz ", " 310 Hz ", " 600 Hz ", "  1 kHz ",
776     "  3 kHz  ", "  6 kHz ", " 12 kHz ", " 14 kHz ", " 16 kHz "
777 };
778
779 Equalizer::Equalizer( intf_thread_t *_p_intf, QWidget *_parent ) :
780                             QWidget( _parent ) , p_intf( _p_intf )
781 {
782     QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
783     smallFont.setPointSize( smallFont.pointSize() - 3 );
784
785     ui.setupUi( this );
786     presetsComboBox = ui.presetsCombo;
787
788     ui.preampLabel->setFont( smallFont );
789     ui.preampSlider->setMaximum( 400 );
790     for( int i = 0 ; i < NB_PRESETS ; i ++ )
791     {
792         ui.presetsCombo->addItem( qtr( preset_list_text[i] ),
793                                   QVariant( i ) );
794     }
795     CONNECT( ui.presetsCombo, activated( int ), this, setPreset( int ) );
796
797     BUTTONACT( ui.enableCheck, enable() );
798     BUTTONACT( ui.eq2PassCheck, set2Pass() );
799
800     CONNECT( ui.preampSlider, valueChanged( int ), this, setPreamp() );
801
802     QGridLayout *grid = new QGridLayout( ui.frame );
803     grid->setMargin( 0 );
804     for( int i = 0 ; i < BANDS ; i++ )
805     {
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 );
814     }
815
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 );
819     char *psz_af;
820     char *psz_bands;
821     float f_preamp;
822     if( p_aout )
823     {
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 );
830     }
831     else
832     {
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" );
838     }
839     if( psz_af && strstr( psz_af, "equalizer" ) != NULL )
840         ui.enableCheck->setChecked( true );
841     free( psz_af );
842     enable( ui.enableCheck->isChecked() );
843
844     setValues( psz_bands, f_preamp );
845 }
846
847 Equalizer::~Equalizer()
848 {
849 }
850
851 void Equalizer::enable()
852 {
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 );
860      enable( en );
861 }
862
863 void Equalizer::enable( bool en )
864 {
865     ui.eq2PassCheck->setEnabled( en );
866     ui.preampLabel->setEnabled( en );
867     ui.preampSlider->setEnabled( en  );
868     for( int i = 0 ; i< BANDS; i++ )
869     {
870         bands[i]->setEnabled( en ); band_texts[i]->setEnabled( en );
871     }
872 }
873
874 void Equalizer::set2Pass()
875 {
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();
879
880     if( p_aout == NULL )
881         config_PutInt( p_intf, "equalizer-2pass", b_2p );
882     else
883     {
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++ )
887         {
888             p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
889         }
890         vlc_object_release( p_aout );
891     }
892 }
893
894 void Equalizer::setPreamp()
895 {
896     float f= ( float )(  ui.preampSlider->value() ) /10 - 20;
897     char psz_val[5];
898     aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
899                                        VLC_OBJECT_AOUT, FIND_ANYWHERE );
900
901     sprintf( psz_val, "%.1f", f );
902     ui.preampLabel->setText( qtr( "Preamp\n" ) + psz_val + qtr( "dB" ) );
903     if( p_aout )
904     {
905         delCallbacks( p_aout );
906         var_SetFloat( p_aout, "equalizer-preamp", f );
907         addCallbacks( p_aout );
908         vlc_object_release( p_aout );
909     }
910     config_PutFloat( p_intf, "equalizer-preamp", f );
911 }
912
913 void Equalizer::setBand()
914 {
915     char psz_values[102]; memset( psz_values, 0, 102 );
916
917     /**\todo smoothing */
918
919     for( int i = 0 ; i< BANDS ; i++ )
920     {
921         char psz_val[5];
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" );
926     }
927     aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
928                                           VLC_OBJECT_AOUT, FIND_ANYWHERE );
929     if( p_aout )
930     {
931         delCallbacks( p_aout );
932         var_SetString( p_aout, "equalizer-bands", psz_values );
933         addCallbacks( p_aout );
934         vlc_object_release( p_aout );
935     }
936 }
937 void Equalizer::setValues( char *psz_bands, float f_preamp )
938 {
939     char *p = psz_bands;
940     if ( p )
941     {
942         for( int i = 0; i < 10; i++ )
943         {
944             char psz_val[5];
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 +
950                                     "dB" );
951             if( p == NULL || *p == '\0' ) break;
952             p++;
953             if( *p == '\0' )  break;
954         }
955     }
956     char psz_val[5];
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" ) );
961 }
962
963 void Equalizer::setPreset( int preset )
964 {
965     aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
966                                                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
967
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] );
972
973     if( p_aout )
974     {
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 );
981     }
982     config_PutPsz( p_intf, "equalizer-bands", psz_values );
983     config_PutFloat( p_intf, "equalizer-preamp",
984                     eqz_preset_10b[preset]->f_preamp );
985
986     setValues( psz_values, eqz_preset_10b[preset]->f_preamp );
987 }
988
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 )
991 {
992     char *psz_preset = newval.psz_string;
993     Equalizer *eq = ( Equalizer * )p_data;
994     eq->presetsComboBox->setCurrentIndex( eq->presetsComboBox->findText( qfu( psz_preset ) ) );
995     return VLC_SUCCESS;
996 }
997
998 void Equalizer::delCallbacks( aout_instance_t *p_aout )
999 {
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 );
1003 }
1004
1005 void Equalizer::addCallbacks( aout_instance_t *p_aout )
1006 {
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 );
1010 }
1011
1012 /**********************************************************************
1013  * Audio filters
1014  **********************************************************************/
1015
1016 /**********************************************************************
1017  * Spatializer
1018  **********************************************************************/
1019 static const char *psz_control_names[] =
1020 {
1021     "Roomsize", "Width" , "Wet", "Dry", "Damp"
1022 };
1023
1024 Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
1025     QWidget( _parent ) , p_intf( _p_intf )
1026 {
1027     QFont smallFont = QApplication::font( static_cast<QWidget*>( 0 ) );
1028     smallFont.setPointSize( smallFont.pointSize() - 3 );
1029
1030     QGridLayout *layout = new QGridLayout( this );
1031     layout->setMargin( 0 );
1032
1033     enableCheck = new QCheckBox( qfu( "Enable spatializer" ) );
1034     layout->addWidget( enableCheck, 0, 0, 1, NUM_SP_CTRL );
1035
1036     for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1037     {
1038         spatCtrl[i] = new QSlider( Qt::Vertical );
1039         if( i < 2 )
1040         {
1041             spatCtrl[i]->setMaximum( 10 );
1042             spatCtrl[i]->setValue( 2 );
1043         }
1044         else
1045         {
1046             spatCtrl[i]->setMaximum( 10 );
1047             spatCtrl[i]->setValue( 0 );
1048             spatCtrl[i]->setMinimum( -10 );
1049         }
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 );
1059     }
1060
1061     BUTTONACT( enableCheck, enable() );
1062
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 );
1066     char *psz_af;
1067
1068     if( p_aout )
1069     {
1070         psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
1071         for( int i = 0; i < NUM_SP_CTRL ; i++ )
1072         {
1073             controlVars[i] = var_GetFloat( p_aout, psz_control_names[i] );
1074         }
1075         vlc_object_release( p_aout );
1076     }
1077     else
1078     {
1079         psz_af = config_GetPsz( p_intf, "audio-filter" );
1080         for( int i = 0; i < NUM_SP_CTRL ; i++ )
1081         {
1082             controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
1083         }
1084     }
1085     if( psz_af && strstr( psz_af, "spatializer" ) != NULL )
1086         enableCheck->setChecked( true );
1087     free( psz_af );
1088     enable( enableCheck->isChecked() );
1089     setValues( controlVars );
1090 }
1091
1092 Spatializer::~Spatializer()
1093 {
1094 }
1095
1096 void Spatializer::enable()
1097 {
1098     bool en = enableCheck->isChecked();
1099     aout_EnableFilter( VLC_OBJECT( p_intf ), "spatializer",
1100             en ? VLC_TRUE : VLC_FALSE );
1101     enable( en );
1102 }
1103
1104 void Spatializer::enable( bool en )
1105 {
1106     for( int i = 0 ; i< NUM_SP_CTRL; i++ )
1107     {
1108         spatCtrl[i]->setEnabled( en );
1109         ctrl_texts[i]->setEnabled( en );
1110         ctrl_readout[i]->setEnabled( en );
1111     }
1112 }
1113 void Spatializer::setInitValues()
1114 {
1115     setValues( controlVars );
1116 }
1117
1118 void Spatializer::setValues( float *controlVars )
1119 {
1120     char psz_val[5];
1121     char var_name[5];
1122     aout_instance_t *p_aout= ( aout_instance_t * )
1123         vlc_object_find( p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE );
1124
1125     for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1126     {
1127         float f= ( float )(  spatCtrl[i]->value() );
1128         sprintf( psz_val, "%.1f", f );
1129         ctrl_readout[i]->setText( psz_val );
1130     }
1131     if( p_aout )
1132     {
1133         for( int i = 0 ; i < NUM_SP_CTRL ; i++ )
1134         {
1135             if( oldControlVars[i] != spatCtrl[i]->value() )
1136             {
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();
1142             }
1143         }
1144         vlc_object_release( p_aout );
1145     }
1146
1147 }
1148 void Spatializer::delCallbacks( aout_instance_t *p_aout )
1149 {
1150     //    var_DelCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1151     //    var_DelCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1152 }
1153
1154 void Spatializer::addCallbacks( aout_instance_t *p_aout )
1155 {
1156     //    var_AddCallback( p_aout, "Spatializer-bands", EqzCallback, this );
1157     //    var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
1158 }
1159
1160 #include <QToolButton>
1161 #include <QGridLayout>
1162
1163 SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
1164                             QWidget( _parent ) , p_intf( _p_intf )
1165 {
1166     QGroupBox *AVBox, *subsBox;
1167     QToolButton *moinsAV, *plusAV;
1168
1169     QToolButton *moinssubs, *plussubs;
1170
1171     QVBoxLayout *vboxLayout = new QVBoxLayout( this );
1172
1173     AVBox = new QGroupBox( qtr( "Audio/Video" ) );
1174     QGridLayout *gridLayout = new QGridLayout( AVBox );
1175
1176     moinsAV = new QToolButton;
1177     moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1178     moinsAV->setAutoRaise( true );
1179     moinsAV->setText( "-" );
1180     gridLayout->addWidget( moinsAV, 1, 0, 1, 1 );
1181
1182     plusAV = new QToolButton;
1183     plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
1184     plusAV->setAutoRaise( true );
1185     plusAV->setText( "+" );
1186     gridLayout->addWidget( plusAV, 1, 2, 1, 1 );
1187
1188     QLabel *AVLabel = new QLabel;
1189     AVLabel->setText( qtr( "Advance of audio over video" ) );
1190     gridLayout->addWidget( AVLabel, 0, 0, 1, 3 );
1191
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 );
1203
1204
1205     subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
1206     QGridLayout *subsLayout = new QGridLayout( subsBox );
1207
1208     moinssubs = new QToolButton;
1209     moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1210     moinssubs->setAutoRaise( true );
1211     moinssubs->setText( "-" );
1212     subsLayout->addWidget( moinssubs, 1, 0, 1, 1 );
1213
1214     plussubs = new QToolButton;
1215     plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
1216     plussubs->setAutoRaise( true );
1217     plussubs->setText( "+" );
1218     subsLayout->addWidget( plussubs, 1, 2, 1, 1 );
1219
1220     QLabel *subsLabel = new QLabel;
1221     subsLabel->setText( qtr( "Advance of subtitles over video" ) );
1222     subsLayout->addWidget( subsLabel, 0, 0, 1, 3 );
1223
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 );
1235 }
1236
1237 /**********************************************************************
1238  * Video filters / Adjust
1239  **********************************************************************/
1240
1241 /**********************************************************************
1242  * Extended playbak controls
1243  **********************************************************************/