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