]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.cpp
Qt: respect font sizes
[vlc] / modules / gui / qt4 / components / open_panels.cpp
1 /*****************************************************************************
2  * open.cpp : Panels for the open dialogs
3  ****************************************************************************
4  * Copyright (C) 2006-2009 the VideoLAN team
5  * Copyright (C) 2007 Société des arts technologiques
6  * Copyright (C) 2007 Savoir-faire Linux
7  *
8  * $Id$
9  *
10  * Authors: Clément Stenac <zorglub@videolan.org>
11  *          Jean-Baptiste Kempf <jb@videolan.org>
12  *          Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27  *****************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "qt4.hpp"
34 #include "components/open_panels.hpp"
35 #include "dialogs/open.hpp"
36 #include "dialogs_provider.hpp" /* Open Subtitle file */
37 #include "util/qt_dirs.hpp"
38
39 #include <QFileDialog>
40 #include <QDialogButtonBox>
41 #include <QLineEdit>
42 #include <QStackedLayout>
43 #include <QListView>
44 #include <QCompleter>
45 #include <QDirModel>
46 #include <QScrollArea>
47 #include <QUrl>
48 #include <QStringListModel>
49
50 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
51
52 static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
53                                        "dshow", "screen", "jack" };
54
55 /**************************************************************************
56  * Open Files and subtitles                                               *
57  **************************************************************************/
58 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
59                                 OpenPanel( _parent, _p_intf ), dialogBox( NULL )
60 {
61     /* Classic UI Setup */
62     ui.setupUi( this );
63
64     /* Set Filters for file selection */
65 /*    QString fileTypes = "";
66     ADD_FILTER_MEDIA( fileTypes );
67     ADD_FILTER_VIDEO( fileTypes );
68     ADD_FILTER_AUDIO( fileTypes );
69     ADD_FILTER_PLAYLIST( fileTypes );
70     ADD_FILTER_ALL( fileTypes );
71     fileTypes.replace( QString(";*"), QString(" *")); */
72
73
74 /*    lineFileEdit = ui.fileEdit;
75     //TODO later: fill the fileCompleteList with previous items played.
76     QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
77     fileCompleter->setModel( new QDirModel( fileCompleter ) );
78     lineFileEdit->setCompleter( fileCompleter );*/
79     if( var_InheritBool( p_intf, "qt-embedded-open" ) )
80     {
81         ui.tempWidget->hide();
82         BuildOldPanel();
83     }
84
85     /* Subtitles */
86     /* Deactivate the subtitles control by default. */
87     ui.subFrame->setEnabled( false );
88     /* Build the subs size combo box */
89     setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
90                             ui.sizeSubComboBox );
91     /* Build the subs align combo box */
92     setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
93
94     /* Connects  */
95     BUTTONACT( ui.fileBrowseButton, browseFile() );
96     BUTTONACT( ui.removeFileButton, removeFile() );
97
98     BUTTONACT( ui.subBrowseButton, browseFileSub() );
99     CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
100
101     CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
102     CONNECT( ui.subInput, textChanged( const QString& ), this, updateMRL() );
103     CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
104     CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
105     updateButtons();
106 }
107
108 inline void FileOpenPanel::BuildOldPanel()
109 {
110     /** BEGIN QFileDialog tweaking **/
111     /* Use a QFileDialog and customize it because we don't want to
112        rewrite it all. Be careful to your eyes cause there are a few hacks.
113        Be very careful and test correctly when you modify this. */
114
115     /* Make this QFileDialog a child of tempWidget from the ui. */
116     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
117                                  p_intf->p_sys->filepath, "" );
118
119     dialogBox->setFileMode( QFileDialog::ExistingFiles );
120     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
121     dialogBox->restoreState(
122             getSettings()->value( "file-dialog-state" ).toByteArray() );
123
124     /* We don't want to see a grip in the middle of the window, do we? */
125     dialogBox->setSizeGripEnabled( false );
126
127     /* Add a tooltip */
128     dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
129     dialogBox->setMinimumHeight( 250 );
130
131     // But hide the two OK/Cancel buttons. Enable them for debug.
132     QDialogButtonBox *fileDialogAcceptBox =
133                       dialogBox->findChildren<QDialogButtonBox*>()[0];
134     fileDialogAcceptBox->hide();
135
136     /* Ugly hacks to get the good Widget */
137     //This lineEdit is the normal line in the fileDialog.
138     QLineEdit *lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
139     /* Make a list of QLabel inside the QFileDialog to access the good ones */
140     QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
141
142     /* Hide the FileNames one. Enable it for debug */
143     listLabel[1]->setText( qtr( "File names:" ) );
144     /* Change the text that was uncool in the usual box */
145     listLabel[2]->setText( qtr( "Filter:" ) );
146
147     dialogBox->layout()->setMargin( 0 );
148     dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
149
150     /** END of QFileDialog tweaking **/
151
152     // Add the DialogBox to the layout
153     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
154
155     CONNECT( lineFileEdit, textChanged( const QString& ), this, updateMRL() );
156     dialogBox->installEventFilter( this );
157 }
158
159 FileOpenPanel::~FileOpenPanel()
160 {
161     if( dialogBox )
162         getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
163 }
164
165 void FileOpenPanel::browseFile()
166 {
167     QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ;
168     foreach( const QString &file, files )
169     {
170         QListWidgetItem *item =
171             new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg );
172         item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
173         ui.fileListWidg->addItem( item );
174         savedirpathFromFile( file );
175     }
176     updateButtons();
177     updateMRL();
178 }
179
180 void FileOpenPanel::removeFile()
181 {
182     int i = ui.fileListWidg->currentRow();
183     if( i != -1 )
184     {
185         QListWidgetItem *temp = ui.fileListWidg->takeItem( i );
186         delete temp;
187     }
188
189     updateMRL();
190     updateButtons();
191 }
192
193 /* Show a fileBrowser to select a subtitle */
194 void FileOpenPanel::browseFileSub()
195 {
196     // TODO Handle selection of more than one subtitles file
197     QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
198                            EXT_FILTER_SUBTITLE, p_intf->p_sys->filepath );
199
200     if( files.isEmpty() ) return;
201     ui.subInput->setText( toNativeSeparators( files.join(" ") ) );
202     updateMRL();
203 }
204
205 void FileOpenPanel::toggleSubtitleFrame( bool b )
206 {
207     ui.subFrame->setEnabled( b );
208
209     /* Update the MRL */
210     updateMRL();
211 }
212
213
214 /* Update the current MRL */
215 void FileOpenPanel::updateMRL()
216 {
217     QStringList fileList;
218     QString mrl;
219
220     /* File Listing */
221     if( dialogBox == NULL )
222         for( int i = 0; i < ui.fileListWidg->count(); i++ )
223         {
224             if( !ui.fileListWidg->item( i )->text().isEmpty() )
225                 fileList << ui.fileListWidg->item( i )->text();
226         }
227     else
228         fileList = dialogBox->selectedFiles();
229
230     /* Options */
231     if( ui.subCheckBox->isChecked() &&  !ui.subInput->text().isEmpty() ) {
232         mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
233         int align = ui.alignSubComboBox->itemData(
234                     ui.alignSubComboBox->currentIndex() ).toInt();
235         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
236         int size = ui.sizeSubComboBox->itemData(
237                    ui.sizeSubComboBox->currentIndex() ).toInt();
238         mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
239     }
240
241     emit mrlUpdated( fileList, mrl );
242     emit methodChanged( "file-caching" );
243 }
244
245 /* Function called by Open Dialog when clicke on Play/Enqueue */
246 void FileOpenPanel::accept()
247 {
248     if( dialogBox )
249         p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
250     ui.fileListWidg->clear();
251 }
252
253 /* Function called by Open Dialog when clicked on cancel */
254 void FileOpenPanel::clear()
255 {
256     ui.fileListWidg->clear();
257     ui.subInput->clear();
258 }
259
260 /* Update buttons depending on current selection */
261 void FileOpenPanel::updateButtons()
262 {
263     bool b_has_files = ( ui.fileListWidg->count() > 0 );
264     ui.removeFileButton->setEnabled( b_has_files );
265     ui.subCheckBox->setEnabled( b_has_files );
266 }
267
268 /**************************************************************************
269  * Open Discs ( DVD, CD, VCD and similar devices )                        *
270  **************************************************************************/
271 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
272                                 OpenPanel( _parent, _p_intf )
273 {
274     ui.setupUi( this );
275
276     /* Get the default configuration path for the devices */
277     psz_dvddiscpath = var_InheritString( p_intf, "dvd" );
278     psz_vcddiscpath = var_InheritString( p_intf, "vcd" );
279     psz_cddadiscpath = var_InheritString( p_intf, "cd-audio" );
280
281     /* State to avoid overwritting the users changes with the configuration */
282     b_firstdvd = true;
283     b_firstvcd = true;
284     b_firstcdda = true;
285
286     ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
287     ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
288
289 #ifdef WIN32 /* Disc drives probing for Windows */
290     char szDrives[512];
291     szDrives[0] = '\0';
292     if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
293     {
294         char *drive = szDrives;
295         UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
296         while( *drive )
297         {
298             if( GetDriveTypeA(drive) == DRIVE_CDROM )
299                 ui.deviceCombo->addItem( drive );
300
301             /* go to next drive */
302             while( *(drive++) );
303         }
304         SetErrorMode(oldMode);
305     }
306 #else /* Use a Completer under Linux */
307     QCompleter *discCompleter = new QCompleter( this );
308     discCompleter->setModel( new QDirModel( discCompleter ) );
309     ui.deviceCombo->setCompleter( discCompleter );
310 #endif
311
312     /* CONNECTs */
313     BUTTONACT( ui.dvdRadioButton, updateButtons() );
314     BUTTONACT( ui.vcdRadioButton, updateButtons() );
315     BUTTONACT( ui.audioCDRadioButton, updateButtons() );
316     BUTTONACT( ui.dvdsimple, updateButtons() );
317     BUTTONACT( ui.browseDiscButton, browseDevice() );
318     BUTTON_SET_ACT_I( ui.ejectButton, "", toolbar/eject, qtr( "Eject the disc" ),
319             eject() );
320
321     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
322     CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
323     CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
324     CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
325     CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
326
327     /* Run once the updateButtons function in order to fill correctly the comboBoxes */
328     updateButtons();
329 }
330
331 DiscOpenPanel::~DiscOpenPanel()
332 {
333     free( psz_dvddiscpath );
334     free( psz_vcddiscpath );
335     free( psz_cddadiscpath );
336 }
337
338 void DiscOpenPanel::clear()
339 {
340     ui.titleSpin->setValue( 0 );
341     ui.chapterSpin->setValue( 0 );
342     ui.subtitlesSpin->setValue( -1 );
343     ui.audioSpin->setValue( -1 );
344     b_firstcdda = true;
345     b_firstdvd = true;
346     b_firstvcd = true;
347 }
348
349 #ifdef WIN32
350     #define setDrive( psz_name ) {\
351     int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
352     if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
353 #else
354     #define setDrive( psz_name ) {\
355     ui.deviceCombo->setEditText( qfu( psz_name ) ); }
356 #endif
357
358 /* update the buttons according the type of device */
359 void DiscOpenPanel::updateButtons()
360 {
361     if ( ui.dvdRadioButton->isChecked() )
362     {
363         if( b_firstdvd )
364         {
365             setDrive( psz_dvddiscpath );
366             b_firstdvd = false;
367         }
368         ui.titleLabel->setText( qtr("Title") );
369         ui.chapterLabel->show();
370         ui.chapterSpin->show();
371         ui.diskOptionBox_2->show();
372         ui.dvdsimple->setEnabled( true );
373     }
374     else if ( ui.vcdRadioButton->isChecked() )
375     {
376         if( b_firstvcd )
377         {
378             setDrive( psz_vcddiscpath );
379             b_firstvcd = false;
380         }
381         ui.titleLabel->setText( qtr("Entry") );
382         ui.chapterLabel->hide();
383         ui.chapterSpin->hide();
384         ui.diskOptionBox_2->show();
385         ui.dvdsimple->setEnabled( false );
386     }
387     else /* CDDA */
388     {
389         if( b_firstcdda )
390         {
391             setDrive( psz_cddadiscpath );
392             b_firstcdda = false;
393         }
394         ui.titleLabel->setText( qtr("Track") );
395         ui.chapterLabel->hide();
396         ui.chapterSpin->hide();
397         ui.diskOptionBox_2->hide();
398         ui.dvdsimple->setEnabled( false );
399     }
400
401     updateMRL();
402 }
403
404 #undef setDrive
405
406 /* Update the current MRL */
407 void DiscOpenPanel::updateMRL()
408 {
409     QString mrl = "";
410     QStringList fileList;
411
412     /* CDDAX and VCDX not implemented. TODO ? No. */
413     /* DVD */
414     if( ui.dvdRadioButton->isChecked() ) {
415         if( !ui.dvdsimple->isChecked() )
416             mrl = "dvd://";
417         else
418             mrl = "dvdsimple://";
419         mrl += ui.deviceCombo->currentText();
420         if( !ui.dvdsimple->isChecked() )
421             emit methodChanged( "dvdnav-caching" );
422         else
423             emit methodChanged( "dvdread-caching" );
424
425         if ( ui.titleSpin->value() > 0 ) {
426             mrl += QString("@%1").arg( ui.titleSpin->value() );
427             if ( ui.chapterSpin->value() > 0 ) {
428                 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
429             }
430         }
431
432     /* VCD */
433     } else if ( ui.vcdRadioButton->isChecked() ) {
434         mrl = "vcd://" + ui.deviceCombo->currentText();
435         emit methodChanged( "vcd-caching" );
436
437         if( ui.titleSpin->value() > 0 ) {
438             mrl += QString("@E%1").arg( ui.titleSpin->value() );
439         }
440
441     /* CDDA */
442     } else {
443         mrl = "cdda://" + ui.deviceCombo->currentText();
444         emit methodChanged( "cdda-caching" );
445     }
446
447     fileList << mrl; mrl = "";
448
449     if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
450     {
451         if ( ui.audioSpin->value() >= 0 ) {
452             mrl += " :audio-track=" +
453                 QString("%1").arg( ui.audioSpin->value() );
454         }
455         if ( ui.subtitlesSpin->value() >= 0 ) {
456             mrl += " :sub-track=" +
457                 QString("%1").arg( ui.subtitlesSpin->value() );
458         }
459     }
460     else
461     {
462         if( ui.titleSpin->value() > 0 )
463             mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
464     }
465     emit mrlUpdated( fileList, mrl );
466 }
467
468 void DiscOpenPanel::browseDevice()
469 {
470     QString dir = QFileDialog::getExistingDirectory( this,
471             qtr( I_DEVICE_TOOLTIP ) );
472     if (!dir.isEmpty())
473         ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
474
475     updateMRL();
476 }
477
478 void DiscOpenPanel::eject()
479 {
480     intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
481 }
482
483 void DiscOpenPanel::accept()
484 {}
485
486 /**************************************************************************
487  * Open Network streams and URL pages                                     *
488  **************************************************************************/
489 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
490                                 OpenPanel( _parent, _p_intf )
491 {
492     ui.setupUi( this );
493
494     /* CONNECTs */
495     CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
496
497     if( var_InheritBool( p_intf, "qt-recentplay" ) )
498     {
499         mrlList = new QStringListModel(
500                 getSettings()->value( "Open/netMRL" ).toStringList() );
501         QCompleter *completer = new QCompleter( mrlList, this );
502         ui.urlText->setCompleter( completer );
503
504         CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
505     }
506     else
507         mrlList = NULL;
508 }
509
510 NetOpenPanel::~NetOpenPanel()
511 {
512     if( !mrlList ) return;
513
514     QStringList tempL = mrlList->stringList();
515     while( tempL.size() > 8 ) tempL.removeFirst();
516
517     getSettings()->setValue( "Open/netMRL", tempL );
518
519     delete mrlList;
520 }
521
522 void NetOpenPanel::clear()
523 {}
524
525 static int strcmp_void( const void *k, const void *e )
526 {
527     return strcmp( (const char *)k, (const char *)e );
528 }
529
530 void NetOpenPanel::updateMRL()
531 {
532     static const struct caching_map
533     {
534         char proto[6];
535         char caching[6];
536     } schemes[] =
537     {   /* KEEP alphabetical order on first column!! */
538         { "dccp",  "rtp"   },
539         { "ftp",   "ftp"   },
540         { "ftps",  "ftp"   },
541         { "http",  "http"  },
542         { "https", "http"  },
543         { "mms",   "mms"   },
544         { "mmsh",  "mms"   },
545         { "mmst",  "mms"   },
546         { "mmsu",  "mms"   },
547         { "sftp",  "sftp"  },
548         { "smb",   "smb"   },
549         { "rtmp",  "rtmp"  },
550         { "rtp",   "rtp"   },
551         { "rtsp",  "rtsp"  },
552         { "udp",   "udp"   },
553     };
554
555     QString url = ui.urlText->text();
556     if( !url.contains( "://") )
557         return; /* nothing to do this far */
558
559     /* Match the correct item in the comboBox */
560     QString proto = url.section( ':', 0, 0 );
561     const struct caching_map *r = (const struct caching_map *)
562         bsearch( qtu(proto), schemes, sizeof(schemes) / sizeof(schemes[0]),
563                  sizeof(schemes[0]), strcmp_void );
564     if( r != NULL && module_exists( r->caching ) )
565         emit methodChanged( qfu( r->caching ) + qfu( "-caching" ) );
566
567     QStringList qsl;
568     qsl << url;
569     emit mrlUpdated( qsl, "" );
570 }
571
572 void NetOpenPanel::updateCompleter()
573 {
574     assert( mrlList );
575     QStringList tempL = mrlList->stringList();
576     if( !tempL.contains( ui.urlText->text() ) )
577         tempL.append( ui.urlText->text() );
578     mrlList->setStringList( tempL );
579 }
580
581 /**************************************************************************
582  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
583  **************************************************************************/
584 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
585                                 OpenPanel( _parent, _p_intf )
586 {
587     isInitialized = false;
588 }
589
590 void CaptureOpenPanel::initialize()
591 {
592     if( isInitialized ) return;
593
594     msg_Dbg( p_intf, "Initialization of Capture device panel" );
595     isInitialized = true;
596
597     ui.setupUi( this );
598
599     BUTTONACT( ui.advancedButton, advancedDialog() );
600
601     /* Create two stacked layouts in the main comboBoxes */
602     QStackedLayout *stackedDevLayout = new QStackedLayout;
603     ui.cardBox->setLayout( stackedDevLayout );
604
605     QStackedLayout *stackedPropLayout = new QStackedLayout;
606     ui.optionsBox->setLayout( stackedPropLayout );
607
608     /* Creation and connections of the WIdgets in the stacked layout */
609 #define addModuleAndLayouts( number, name, label, layout )            \
610     QWidget * name ## DevPage = new QWidget( this );                  \
611     QWidget * name ## PropPage = new QWidget( this );                 \
612     stackedDevLayout->addWidget( name ## DevPage );        \
613     stackedPropLayout->addWidget( name ## PropPage );      \
614     layout * name ## DevLayout = new layout;                \
615     layout * name ## PropLayout = new layout;               \
616     name ## DevPage->setLayout( name ## DevLayout );                  \
617     name ## PropPage->setLayout( name ## PropLayout );                \
618     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
619
620 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
621
622 #ifdef WIN32
623     /*********************
624      * DirectShow Stuffs *
625      *********************/
626     if( module_exists( "dshow" ) ){
627     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow", QGridLayout );
628
629     /* dshow Main */
630     int line = 0;
631     module_config_t *p_config =
632         config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
633     vdevDshowW = new StringListConfigControl(
634         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
635     line++;
636
637     p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
638     adevDshowW = new StringListConfigControl(
639         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
640     line++;
641
642     /* dshow Properties */
643     QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
644     dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
645
646     dshowVSizeLine = new QLineEdit;
647     dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
648     dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
649             1, 0, 3, 1 );
650
651     /* dshow CONNECTs */
652     CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
653     CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
654     CuMRL( dshowVSizeLine, textChanged( const QString& ) );
655     }
656
657     /**************
658      * BDA Stuffs *
659      **************/
660     if( module_exists( "bda" ) ){
661     addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow", QGridLayout );
662
663     /* bda Main */
664     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
665
666     bdas = new QRadioButton( "DVB-S" );
667     bdas->setChecked( true );
668     bdac = new QRadioButton( "DVB-C" );
669     bdat = new QRadioButton( "DVB-T" );
670     bdaa = new QRadioButton( "ATSC" );
671
672     bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
673     bdaDevLayout->addWidget( bdas, 0, 1 );
674     bdaDevLayout->addWidget( bdac, 0, 2 );
675     bdaDevLayout->addWidget( bdat, 0, 3 );
676     bdaDevLayout->addWidget( bdaa, 0, 4 );
677
678     /* bda Props */
679     QLabel *bdaFreqLabel =
680                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
681     bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
682
683     bdaFreq = new QSpinBox;
684     bdaFreq->setAlignment( Qt::AlignRight );
685     bdaFreq->setSuffix(" kHz");
686     bdaFreq->setSingleStep( 1000 );
687     setSpinBoxFreq( bdaFreq )
688     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
689
690     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
691     bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
692
693     bdaSrate = new QSpinBox;
694     bdaSrate->setAlignment( Qt::AlignRight );
695     bdaSrate->setSuffix(" kHz");
696     setSpinBoxFreq( bdaSrate );
697     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
698
699     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
700     bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
701
702     bdaBandBox = new QComboBox;
703     setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
704     bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
705
706     bdaBandLabel->hide();
707     bdaBandBox->hide();
708     bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
709             2, 0, 2, 1 );
710
711     /* bda CONNECTs */
712     CuMRL( bdaFreq, valueChanged ( int ) );
713     CuMRL( bdaSrate, valueChanged ( int ) );
714     CuMRL( bdaBandBox,  currentIndexChanged ( int ) );
715     BUTTONACT( bdas, updateButtons() );
716     BUTTONACT( bdat, updateButtons() );
717     BUTTONACT( bdac, updateButtons() );
718     BUTTONACT( bdaa, updateButtons() );
719     BUTTONACT( bdas, updateMRL() );
720     BUTTONACT( bdat, updateMRL() );
721     BUTTONACT( bdac, updateMRL() );
722     BUTTONACT( bdaa, updateMRL() );
723     }
724
725 #else /* WIN32 */
726     /*******
727      * V4L2*
728      *******/
729     if( module_exists( "v4l2" ) ){
730     addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2", QGridLayout );
731
732     /* V4l Main panel */
733     QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
734     v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
735
736     v4l2VideoDevice = new QLineEdit;
737     v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
738
739     QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
740     v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
741
742     v4l2AudioDevice = new QLineEdit;
743     v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
744
745     /* v4l2 Props panel */
746     QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
747     v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
748
749     v4l2StdBox = new QComboBox;
750     setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
751     v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
752     v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
753             1, 0, 3, 1 );
754
755     /* v4l2 CONNECTs */
756     CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
757     CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
758     CuMRL( v4l2StdBox,  currentIndexChanged ( int ) );
759     }
760
761     /*******
762      * V4L *
763      *******/
764     if( module_exists( "v4l" ) ){
765     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux", QGridLayout );
766
767     /* V4l Main panel */
768     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
769     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
770
771     v4lVideoDevice = new QLineEdit;
772     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
773
774     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
775     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
776
777     v4lAudioDevice = new QLineEdit;
778     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
779
780     /* V4l Props panel */
781     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
782     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
783
784     v4lNormBox = new QComboBox;
785     setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
786     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
787
788     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
789     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
790
791     v4lFreq = new QSpinBox;
792     v4lFreq->setAlignment( Qt::AlignRight );
793     v4lFreq->setSuffix(" kHz");
794     setSpinBoxFreq( v4lFreq );
795     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
796     v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
797             2, 0, 2, 1 );
798
799     /* v4l CONNECTs */
800     CuMRL( v4lVideoDevice, textChanged( const QString& ) );
801     CuMRL( v4lAudioDevice, textChanged( const QString& ) );
802     CuMRL( v4lFreq, valueChanged ( int ) );
803     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
804     }
805
806     /*******
807      * JACK *
808      *******/
809     if( module_exists( "jack" ) ){
810     addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit",
811                          QGridLayout);
812
813     /* Jack Main panel */
814     /* Channels */
815     QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
816     jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
817
818     jackChannels = new QSpinBox;
819     setSpinBoxFreq( jackChannels );
820     jackChannels->setMaximum(255);
821     jackChannels->setValue(2);
822     jackChannels->setAlignment( Qt::AlignRight );
823     jackDevLayout->addWidget( jackChannels, 1, 1 );
824
825     /* Selected ports */
826     QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
827     jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
828
829     jackPortsSelected = new QLineEdit( qtr( ".*") );
830     jackPortsSelected->setAlignment( Qt::AlignRight );
831     jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
832
833     /* Jack Props panel */
834
835     /* Caching */
836     QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
837     jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
838     jackCaching = new QSpinBox;
839     setSpinBoxFreq( jackCaching );
840     jackCaching->setSuffix( " ms" );
841     jackCaching->setValue(1000);
842     jackCaching->setAlignment( Qt::AlignRight );
843     jackPropLayout->addWidget( jackCaching, 1 , 2 );
844
845     /* Pace */
846     jackPace = new QCheckBox(qtr( "Use VLC pace" ));
847     jackPropLayout->addWidget( jackPace, 2, 1 );
848
849     /* Auto Connect */
850     jackConnect = new QCheckBox( qtr( "Auto connnection" ));
851     jackPropLayout->addWidget( jackConnect, 2, 2 );
852
853     /* Jack CONNECTs */
854     CuMRL( jackChannels, valueChanged( int ) );
855     CuMRL( jackCaching, valueChanged( int ) );
856     CuMRL( jackPace, stateChanged( int ) );
857     CuMRL( jackConnect, stateChanged( int ) );
858     CuMRL( jackPortsSelected, textChanged( const QString& ) );
859     }
860
861     /************
862      * PVR      *
863      ************/
864     if( module_exists( "pvr" ) ){
865     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR", QGridLayout );
866
867     /* PVR Main panel */
868     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
869     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
870
871     pvrDevice = new QLineEdit;
872     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
873
874     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
875     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
876
877     pvrRadioDevice = new QLineEdit;
878     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
879
880     /* PVR props panel */
881     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
882     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
883
884     pvrNormBox = new QComboBox;
885     setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
886     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
887
888     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
889     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
890
891     pvrFreq = new QSpinBox;
892     pvrFreq->setAlignment( Qt::AlignRight );
893     pvrFreq->setSuffix(" kHz");
894     setSpinBoxFreq( pvrFreq );
895     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
896
897     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
898     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
899
900     pvrBitr = new QSpinBox;
901     pvrBitr->setAlignment( Qt::AlignRight );
902     pvrBitr->setSuffix(" kHz");
903     setSpinBoxFreq( pvrBitr );
904     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
905     pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
906             3, 0, 1, 1 );
907
908     /* PVR CONNECTs */
909     CuMRL( pvrDevice, textChanged( const QString& ) );
910     CuMRL( pvrRadioDevice, textChanged( const QString& ) );
911
912     CuMRL( pvrFreq, valueChanged ( int ) );
913     CuMRL( pvrBitr, valueChanged ( int ) );
914     CuMRL( pvrNormBox, currentIndexChanged ( int ) );
915     }
916
917     /**************
918      * DVB Stuffs *
919      **************/
920     if( module_exists( "dvb" ) ){
921     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB", QGridLayout );
922
923     /* DVB Main */
924     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
925     QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
926
927     dvbCard = new QSpinBox;
928     dvbCard->setAlignment( Qt::AlignRight );
929     dvbCard->setPrefix( "/dev/dvb/adapter" );
930
931     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
932     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
933
934     dvbs = new QRadioButton( "DVB-S" );
935     dvbs->setChecked( true );
936     dvbc = new QRadioButton( "DVB-C" );
937     dvbt = new QRadioButton( "DVB-T" );
938
939     dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
940     dvbDevLayout->addWidget( dvbs, 1, 1 );
941     dvbDevLayout->addWidget( dvbc, 1, 2 );
942     dvbDevLayout->addWidget( dvbt, 1, 3 );
943
944     /* DVB Props panel */
945     QLabel *dvbFreqLabel =
946                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
947     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
948
949     dvbFreq = new QSpinBox;
950     dvbFreq->setAlignment( Qt::AlignRight );
951     dvbFreq->setSuffix(" kHz");
952     dvbFreq->setSingleStep( 1000 );
953     setSpinBoxFreq( dvbFreq  );
954     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
955
956     dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
957     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
958
959     dvbSrate = new QSpinBox;
960     dvbSrate->setAlignment( Qt::AlignRight );
961     dvbSrate->setSuffix(" kHz");
962     setSpinBoxFreq( dvbSrate );
963     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
964
965     dvbBandLabel = new QLabel( qtr( "Bandwidth" ) );
966     dvbPropLayout->addWidget( dvbBandLabel, 2, 0 );
967
968     dvbBandBox = new QComboBox;
969     /* This doesn't work since dvb-bandwidth doesn't seem to be a
970        list of Integers
971        setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
972      */
973     dvbBandBox->addItem( qtr( "Auto" ), 0 );
974     dvbBandBox->addItem( qtr( "6 MHz" ), 6 );
975     dvbBandBox->addItem( qtr( "7 MHz" ), 7 );
976     dvbBandBox->addItem( qtr( "8 MHz" ), 8 );
977     dvbPropLayout->addWidget( dvbBandBox, 2, 1 );
978
979     dvbBandLabel->hide();
980     dvbBandBox->hide();
981
982     dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
983             2, 0, 2, 1 );
984
985     /* DVB CONNECTs */
986     CuMRL( dvbCard, valueChanged ( int ) );
987     CuMRL( dvbFreq, valueChanged ( int ) );
988     CuMRL( dvbSrate, valueChanged ( int ) );
989     CuMRL( dvbBandBox, currentIndexChanged ( int ) );
990
991     BUTTONACT( dvbs, updateButtons() );
992     BUTTONACT( dvbt, updateButtons() );
993     BUTTONACT( dvbc, updateButtons() );
994     BUTTONACT( dvbs, updateMRL() );
995     BUTTONACT( dvbt, updateMRL() );
996     BUTTONACT( dvbc, updateMRL() );
997     }
998
999 #endif
1000
1001
1002     /**********
1003      * Screen *
1004      **********/
1005     addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop", QGridLayout );
1006     QLabel *screenLabel = new QLabel( qtr( "Your display will be "
1007             "opened and played in order to stream or save it." ) );
1008     screenLabel->setWordWrap( true );
1009     screenDevLayout->addWidget( screenLabel, 0, 0 );
1010
1011     QLabel *screenFPSLabel = new QLabel(
1012             qtr( "Desired frame rate for the capture." ) );
1013     screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1014
1015     screenFPS = new QSpinBox;
1016     screenFPS->setValue( 1 );
1017     screenFPS->setAlignment( Qt::AlignRight );
1018     screenPropLayout->addWidget( screenFPS, 0, 1 );
1019
1020     /* Screen connect */
1021     CuMRL( screenFPS, valueChanged( int ) );
1022
1023     /* General connects */
1024     CONNECT( ui.deviceCombo, activated( int ) ,
1025              stackedDevLayout, setCurrentIndex( int ) );
1026     CONNECT( ui.deviceCombo, activated( int ),
1027              stackedPropLayout, setCurrentIndex( int ) );
1028     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1029     CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1030
1031 #undef CuMRL
1032 #undef addModuleAndLayouts
1033 }
1034
1035 CaptureOpenPanel::~CaptureOpenPanel()
1036 {
1037 }
1038
1039 void CaptureOpenPanel::clear()
1040 {
1041     advMRL.clear();
1042 }
1043
1044 void CaptureOpenPanel::updateMRL()
1045 {
1046     QString mrl = "";
1047     QStringList fileList;
1048     int i_devicetype = ui.deviceCombo->itemData(
1049             ui.deviceCombo->currentIndex() ).toInt();
1050     switch( i_devicetype )
1051     {
1052 #ifdef WIN32
1053     case BDA_DEVICE:
1054         if( bdas->isChecked() ) mrl = "dvb-s://";
1055         else if(  bdat->isChecked() ) mrl = "dvb-t://";
1056         else if(  bdac->isChecked() ) mrl = "dvb-c://";
1057         else if(  bdaa->isChecked() ) mrl = "atsc://";
1058         else return;
1059         mrl += "frequency=" + QString::number( bdaFreq->value() );
1060         if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked() )
1061             mrl +="000";
1062         fileList << mrl; mrl = "";
1063
1064         if( bdas->isChecked() || bdac->isChecked() )
1065             mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1066         else if( bdat->isChecked() || bdaa->isChecked() )
1067             mrl += " :dvb-bandwidth=" +
1068                 QString::number( bdaBandBox->itemData(
1069                     bdaBandBox->currentIndex() ).toInt() );
1070         emit methodChanged( "dvb-caching" );
1071         break;
1072     case DSHOW_DEVICE:
1073         fileList << "dshow://";
1074         mrl+= " :dshow-vdev=" +
1075             colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1076         mrl+= " :dshow-adev=" +
1077             colon_escape( QString("%1").arg( adevDshowW->getValue() ) )+" ";
1078         if( dshowVSizeLine->isModified() )
1079             mrl += ":dshow-size=" + dshowVSizeLine->text();
1080         emit methodChanged( "dshow-caching" );
1081         break;
1082 #else
1083     case V4L_DEVICE:
1084         fileList << "v4l://" + v4lVideoDevice->text();
1085         mrl += " :input-slave=alsa://" + v4lAudioDevice->text();
1086         mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1087         mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1088         break;
1089     case V4L2_DEVICE:
1090         fileList << "v4l2://" + v4l2VideoDevice->text();
1091         mrl += " :input-slave=alsa://" + v4l2AudioDevice->text();
1092         mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1093         break;
1094     case JACK_DEVICE:
1095         mrl = "jack://";
1096         mrl += "channels=" + QString::number( jackChannels->value() );
1097         mrl += ":ports=" + jackPortsSelected->text();
1098         fileList << mrl; mrl = "";
1099
1100         mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1101         if ( jackPace->isChecked() )
1102         {
1103                 mrl += " :jack-input-use-vlc-pace";
1104         }
1105         if ( jackConnect->isChecked() )
1106         {
1107                 mrl += " :jack-input-auto-connect";
1108         }
1109         break;
1110     case PVR_DEVICE:
1111         fileList << "pvr://";
1112         mrl += " :pvr-device=" + pvrDevice->text();
1113         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1114         mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1115         if( pvrFreq->value() )
1116             mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1117         if( pvrBitr->value() )
1118             mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1119         break;
1120     case DVB_DEVICE:
1121         mrl = "dvb://";
1122         mrl += "frequency=" + QString::number( dvbFreq->value() );
1123         if( dvbc->isChecked() || dvbt->isChecked() )
1124             mrl +="000";
1125         fileList << mrl; mrl= "";
1126
1127         mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1128         if( dvbs->isChecked() || dvbc->isChecked() )
1129             mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1130         else if( dvbt->isChecked() )
1131             mrl += " :dvb-bandwidth=" +
1132                 QString::number( dvbBandBox->itemData(
1133                     dvbBandBox->currentIndex() ).toInt() );
1134
1135         break;
1136 #endif
1137     case SCREEN_DEVICE:
1138         fileList << "screen://";
1139         mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1140         emit methodChanged( "screen-caching" );
1141         updateButtons();
1142         break;
1143     }
1144
1145     if( !advMRL.isEmpty() ) mrl += advMRL;
1146
1147     emit mrlUpdated( fileList, mrl );
1148 }
1149
1150 /**
1151  * Update the Buttons (show/hide) for the GUI as all device type don't
1152  * use the same ui. elements.
1153  **/
1154 void CaptureOpenPanel::updateButtons()
1155 {
1156     /*  Be sure to display the ui Elements in case they were hidden by
1157      *  some Device Type (like Screen://) */
1158     ui.optionsBox->show();
1159     ui.advancedButton->show();
1160     /* Get the current Device Number */
1161     int i_devicetype = ui.deviceCombo->itemData(
1162                                 ui.deviceCombo->currentIndex() ).toInt();
1163     switch( i_devicetype )
1164     {
1165 #ifdef WIN32
1166     case BDA_DEVICE:
1167         if( bdas->isChecked() || bdac->isChecked() )
1168         {
1169             bdaSrate->show();
1170             bdaSrateLabel->show();
1171             bdaBandBox->hide();
1172             bdaBandLabel->hide();
1173         }
1174         else if( bdat->isChecked() || bdaa->isChecked() )
1175         {
1176             bdaSrate->hide();
1177             bdaSrateLabel->hide();
1178             bdaBandBox->show();
1179             bdaBandLabel->show();
1180         }
1181         break;
1182 #else
1183     case DVB_DEVICE:
1184         if( dvbs->isChecked() || dvbc->isChecked() )
1185         {
1186             dvbSrate->show();
1187             dvbSrateLabel->show();
1188             dvbBandBox->hide();
1189             dvbBandLabel->hide();
1190         }
1191         else if( dvbt->isChecked() )
1192         {
1193             dvbSrate->hide();
1194             dvbSrateLabel->hide();
1195             dvbBandBox->show();
1196             dvbBandLabel->show();
1197         }
1198         break;
1199 #endif
1200     case SCREEN_DEVICE:
1201         //ui.optionsBox->hide();
1202         ui.advancedButton->hide();
1203         break;
1204     }
1205
1206     advMRL.clear();
1207 }
1208
1209 void CaptureOpenPanel::advancedDialog()
1210 {
1211     /* Get selected device type */
1212     int i_devicetype = ui.deviceCombo->itemData(
1213                                 ui.deviceCombo->currentIndex() ).toInt();
1214
1215     /* Get the corresponding module */
1216     module_t *p_module =
1217         module_find( psz_devModule[i_devicetype] );
1218     if( NULL == p_module ) return;
1219
1220     /* Init */
1221     QList<ConfigControl *> controls;
1222
1223     /* Get the confsize  */
1224     unsigned int i_confsize;
1225     module_config_t *p_config;
1226     p_config = module_config_get( p_module, &i_confsize );
1227
1228     /* New Adv Prop dialog */
1229     adv = new QDialog( this );
1230     adv->setWindowTitle( qtr( "Advanced Options" ) );
1231     adv->setWindowRole( "vlc-advanced-options" );
1232
1233     /* A main Layout with a Frame */
1234     QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1235     QScrollArea *scroll = new QScrollArea;
1236     mainLayout->addWidget( scroll );
1237
1238     QFrame *advFrame = new QFrame;
1239     /* GridLayout inside the Frame */
1240     QGridLayout *gLayout = new QGridLayout( advFrame );
1241
1242     scroll->setWidgetResizable( true );
1243     scroll->setWidget( advFrame );
1244
1245     /* Create the options inside the FrameLayout */
1246     for( int n = 0; n < (int)i_confsize; n++ )
1247     {
1248         module_config_t *p_item = p_config + n;
1249         ConfigControl *config = ConfigControl::createControl(
1250                         VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1251         if ( config )
1252             controls.append( config );
1253     }
1254
1255     /* Button stuffs */
1256     QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1257     QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1258     QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1259
1260     CONNECT( closeButton, clicked(), adv, accept() );
1261     CONNECT( cancelButton, clicked(), adv, reject() );
1262
1263     advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1264     advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1265
1266     mainLayout->addWidget( advButtonBox );
1267
1268     /* Creation of the MRL */
1269     if( adv->exec() )
1270     {
1271         QString tempMRL = "";
1272         for( int i = 0; i < controls.size(); i++ )
1273         {
1274             ConfigControl *control = controls[i];
1275
1276             tempMRL += (i ? " :" : ":");
1277
1278             if( control->getType() == CONFIG_ITEM_BOOL )
1279                 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1280                     tempMRL += "no-";
1281
1282             tempMRL += control->getName();
1283
1284             switch( control->getType() )
1285             {
1286                 case CONFIG_ITEM_STRING:
1287                 case CONFIG_ITEM_FILE:
1288                 case CONFIG_ITEM_DIRECTORY:
1289                 case CONFIG_ITEM_MODULE:
1290                     tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1291                     break;
1292                 case CONFIG_ITEM_INTEGER:
1293                     tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1294                     break;
1295                 case CONFIG_ITEM_FLOAT:
1296                     tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1297                     break;
1298             }
1299         }
1300         advMRL = tempMRL;
1301         updateMRL();
1302         msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1303     }
1304     for( int i = 0; i < controls.size(); i++ )
1305     {
1306         ConfigControl *control = controls[i];
1307         delete control ;
1308     }
1309     delete adv;
1310     module_config_free( p_config );
1311     module_release (p_module);
1312 }
1313