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