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