]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.cpp
qt4: i18n fixes
[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( qtr(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     if( !tempL.contains( ui.addressText->text() ) )
627         tempL.append( ui.addressText->text() );
628     mrlList->setStringList( tempL );
629 }
630
631 /**************************************************************************
632  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
633  **************************************************************************/
634 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
635                                 OpenPanel( _parent, _p_intf )
636 {
637     isInitialized = false;
638 }
639
640 void CaptureOpenPanel::initialize()
641 {
642     if( isInitialized ) return;
643
644     msg_Dbg( p_intf, "Initialization of Capture device panel" );
645     isInitialized = true;
646
647     ui.setupUi( this );
648
649     BUTTONACT( ui.advancedButton, advancedDialog() );
650
651     /* Create two stacked layouts in the main comboBoxes */
652     QStackedLayout *stackedDevLayout = new QStackedLayout;
653     ui.cardBox->setLayout( stackedDevLayout );
654
655     QStackedLayout *stackedPropLayout = new QStackedLayout;
656     ui.optionsBox->setLayout( stackedPropLayout );
657
658     /* Creation and connections of the WIdgets in the stacked layout */
659 #define addModuleAndLayouts( number, name, label )                    \
660     QWidget * name ## DevPage = new QWidget( this );                  \
661     QWidget * name ## PropPage = new QWidget( this );                 \
662     stackedDevLayout->addWidget( name ## DevPage );        \
663     stackedPropLayout->addWidget( name ## PropPage );      \
664     QGridLayout * name ## DevLayout = new QGridLayout;                \
665     QGridLayout * name ## PropLayout = new QGridLayout;               \
666     name ## DevPage->setLayout( name ## DevLayout );                  \
667     name ## PropPage->setLayout( name ## PropLayout );                \
668     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
669
670 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
671
672 #ifdef WIN32
673     /*********************
674      * DirectShow Stuffs *
675      *********************/
676     if( module_exists( "dshow" ) ){
677     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
678
679     /* dshow Main */
680     int line = 0;
681     module_config_t *p_config =
682         config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
683     vdevDshowW = new StringListConfigControl(
684         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
685     line++;
686
687     p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
688     adevDshowW = new StringListConfigControl(
689         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
690     line++;
691
692     /* dshow Properties */
693     QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
694     dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
695
696     dshowVSizeLine = new QLineEdit;
697     dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
698     dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
699             1, 0, 3, 1 );
700
701     /* dshow CONNECTs */
702     CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
703     CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
704     CuMRL( dshowVSizeLine, textChanged( const QString& ) );
705     }
706
707     /**************
708      * BDA Stuffs *
709      **************/
710     if( module_exists( "bda" ) ){
711     addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
712
713     /* bda Main */
714     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
715
716     bdas = new QRadioButton( "DVB-S" );
717     bdas->setChecked( true );
718     bdac = new QRadioButton( "DVB-C" );
719     bdat = new QRadioButton( "DVB-T" );
720     bdaa = new QRadioButton( "ATSC" );
721
722     bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
723     bdaDevLayout->addWidget( bdas, 0, 1 );
724     bdaDevLayout->addWidget( bdac, 0, 2 );
725     bdaDevLayout->addWidget( bdat, 0, 3 );
726     bdaDevLayout->addWidget( bdaa, 0, 4 );
727
728     /* bda Props */
729     QLabel *bdaFreqLabel =
730                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
731     bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
732
733     bdaFreq = new QSpinBox;
734     bdaFreq->setAlignment( Qt::AlignRight );
735     bdaFreq->setSuffix(" kHz");
736     bdaFreq->setSingleStep( 1000 );
737     setSpinBoxFreq( bdaFreq )
738     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
739
740     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
741     bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
742
743     bdaSrate = new QSpinBox;
744     bdaSrate->setAlignment( Qt::AlignRight );
745     bdaSrate->setSuffix(" kHz");
746     setSpinBoxFreq( bdaSrate );
747     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
748
749     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
750     bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
751
752     bdaBandBox = new QComboBox;
753     setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
754     bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
755
756     bdaBandLabel->hide();
757     bdaBandBox->hide();
758     bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
759             2, 0, 2, 1 );
760
761     /* bda CONNECTs */
762     CuMRL( bdaFreq, valueChanged ( int ) );
763     CuMRL( bdaSrate, valueChanged ( int ) );
764     CuMRL( bdaBandBox,  currentIndexChanged ( int ) );
765     BUTTONACT( bdas, updateButtons() );
766     BUTTONACT( bdat, updateButtons() );
767     BUTTONACT( bdac, updateButtons() );
768     BUTTONACT( bdaa, updateButtons() );
769     BUTTONACT( bdas, updateMRL() );
770     BUTTONACT( bdat, updateMRL() );
771     BUTTONACT( bdac, updateMRL() );
772     BUTTONACT( bdaa, updateMRL() );
773     }
774
775 #else /* WIN32 */
776     /*******
777      * V4L2*
778      *******/
779     if( module_exists( "v4l2" ) ){
780     addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
781
782     /* V4l Main panel */
783     QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
784     v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
785
786     v4l2VideoDevice = new QLineEdit;
787     v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
788
789     QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
790     v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
791
792     v4l2AudioDevice = new QLineEdit;
793     v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
794
795     /* v4l2 Props panel */
796     QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
797     v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
798
799     v4l2StdBox = new QComboBox;
800     setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
801     v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
802     v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
803             1, 0, 3, 1 );
804
805     /* v4l2 CONNECTs */
806     CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
807     CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
808     CuMRL( v4l2StdBox,  currentIndexChanged ( int ) );
809     }
810
811     /*******
812      * V4L *
813      *******/
814     if( module_exists( "v4l" ) ){
815     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
816
817     /* V4l Main panel */
818     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
819     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
820
821     v4lVideoDevice = new QLineEdit;
822     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
823
824     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
825     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
826
827     v4lAudioDevice = new QLineEdit;
828     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
829
830     /* V4l Props panel */
831     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
832     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
833
834     v4lNormBox = new QComboBox;
835     setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
836     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
837
838     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
839     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
840
841     v4lFreq = new QSpinBox;
842     v4lFreq->setAlignment( Qt::AlignRight );
843     v4lFreq->setSuffix(" kHz");
844     setSpinBoxFreq( v4lFreq );
845     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
846     v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
847             2, 0, 2, 1 );
848
849     /* v4l CONNECTs */
850     CuMRL( v4lVideoDevice, textChanged( const QString& ) );
851     CuMRL( v4lAudioDevice, textChanged( const QString& ) );
852     CuMRL( v4lFreq, valueChanged ( int ) );
853     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
854     }
855
856     /*******
857      * JACK *
858      *******/
859     if( module_exists( "jack" ) ){
860     addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
861
862     /* Jack Main panel */
863     /* Channels */
864     QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
865     jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
866
867     jackChannels = new QSpinBox;
868     setSpinBoxFreq( jackChannels );
869     jackChannels->setMaximum(255);
870     jackChannels->setValue(2);
871     jackChannels->setAlignment( Qt::AlignRight );
872     jackDevLayout->addWidget( jackChannels, 1, 1 );
873
874     /* Selected ports */
875     QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
876     jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
877
878     jackPortsSelected = new QLineEdit( qtr( ".*") );
879     jackPortsSelected->setAlignment( Qt::AlignRight );
880     jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
881
882     /* Jack Props panel */
883
884     /* Caching */
885     QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
886     jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
887     jackCaching = new QSpinBox;
888     setSpinBoxFreq( jackCaching );
889     jackCaching->setSuffix( " ms" );
890     jackCaching->setValue(1000);
891     jackCaching->setAlignment( Qt::AlignRight );
892     jackPropLayout->addWidget( jackCaching, 1 , 2 );
893
894     /* Pace */
895     jackPace = new QCheckBox(qtr( "Use VLC pace" ));
896     jackPropLayout->addWidget( jackPace, 2, 1 );
897
898     /* Auto Connect */
899     jackConnect = new QCheckBox( qtr( "Auto connnection" ));
900     jackPropLayout->addWidget( jackConnect, 2, 2 );
901
902     /* Jack CONNECTs */
903     CuMRL( jackChannels, valueChanged( int ) );
904     CuMRL( jackCaching, valueChanged( int ) );
905     CuMRL( jackPace, stateChanged( int ) );
906     CuMRL( jackConnect, stateChanged( int ) );
907     CuMRL( jackPortsSelected, textChanged( const QString& ) );
908     }
909
910     /************
911      * PVR      *
912      ************/
913     if( module_exists( "pvr" ) ){
914     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
915
916     /* PVR Main panel */
917     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
918     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
919
920     pvrDevice = new QLineEdit;
921     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
922
923     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
924     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
925
926     pvrRadioDevice = new QLineEdit;
927     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
928
929     /* PVR props panel */
930     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
931     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
932
933     pvrNormBox = new QComboBox;
934     setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
935     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
936
937     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
938     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
939
940     pvrFreq = new QSpinBox;
941     pvrFreq->setAlignment( Qt::AlignRight );
942     pvrFreq->setSuffix(" kHz");
943     setSpinBoxFreq( pvrFreq );
944     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
945
946     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
947     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
948
949     pvrBitr = new QSpinBox;
950     pvrBitr->setAlignment( Qt::AlignRight );
951     pvrBitr->setSuffix(" kHz");
952     setSpinBoxFreq( pvrBitr );
953     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
954     pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
955             3, 0, 1, 1 );
956
957     /* PVR CONNECTs */
958     CuMRL( pvrDevice, textChanged( const QString& ) );
959     CuMRL( pvrRadioDevice, textChanged( const QString& ) );
960
961     CuMRL( pvrFreq, valueChanged ( int ) );
962     CuMRL( pvrBitr, valueChanged ( int ) );
963     CuMRL( pvrNormBox, currentIndexChanged ( int ) );
964     }
965
966     /**************
967      * DVB Stuffs *
968      **************/
969     if( module_exists( "dvb" ) ){
970     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
971
972     /* DVB Main */
973     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
974     QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
975
976     dvbCard = new QSpinBox;
977     dvbCard->setAlignment( Qt::AlignRight );
978     dvbCard->setPrefix( "/dev/dvb/adapter" );
979
980     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
981     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
982
983     dvbs = new QRadioButton( "DVB-S" );
984     dvbs->setChecked( true );
985     dvbc = new QRadioButton( "DVB-C" );
986     dvbt = new QRadioButton( "DVB-T" );
987
988     dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
989     dvbDevLayout->addWidget( dvbs, 1, 1 );
990     dvbDevLayout->addWidget( dvbc, 1, 2 );
991     dvbDevLayout->addWidget( dvbt, 1, 3 );
992
993     /* DVB Props panel */
994     QLabel *dvbFreqLabel =
995                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
996     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
997
998     dvbFreq = new QSpinBox;
999     dvbFreq->setAlignment( Qt::AlignRight );
1000     dvbFreq->setSuffix(" kHz");
1001     setSpinBoxFreq( dvbFreq  );
1002     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
1003
1004     QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
1005     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
1006
1007     dvbSrate = new QSpinBox;
1008     dvbSrate->setAlignment( Qt::AlignRight );
1009     dvbSrate->setSuffix(" kHz");
1010     setSpinBoxFreq( dvbSrate );
1011     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
1012     dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
1013             2, 0, 2, 1 );
1014
1015     /* DVB CONNECTs */
1016     CuMRL( dvbCard, valueChanged ( int ) );
1017     CuMRL( dvbFreq, valueChanged ( int ) );
1018     CuMRL( dvbSrate, valueChanged ( int ) );
1019
1020     BUTTONACT( dvbs, updateButtons() );
1021     BUTTONACT( dvbt, updateButtons() );
1022     BUTTONACT( dvbc, updateButtons() );
1023     }
1024
1025 #endif
1026
1027
1028     /**********
1029      * Screen *
1030      **********/
1031     addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
1032     QLabel *screenLabel = new QLabel( "Your display will will be "
1033             "opened and played in order to stream or save it." );
1034     screenLabel->setWordWrap( true );
1035     screenDevLayout->addWidget( screenLabel, 0, 0 );
1036
1037     QLabel *screenFPSLabel = new QLabel(
1038             qtr( "Desired frame rate for the capture." ) );
1039     screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1040
1041     screenFPS = new QSpinBox;
1042     screenFPS->setValue( 1 );
1043     screenFPS->setAlignment( Qt::AlignRight );
1044     screenPropLayout->addWidget( screenFPS, 0, 1 );
1045
1046     /* General connects */
1047     CONNECT( ui.deviceCombo, activated( int ) ,
1048              stackedDevLayout, setCurrentIndex( int ) );
1049     CONNECT( ui.deviceCombo, activated( int ),
1050              stackedPropLayout, setCurrentIndex( int ) );
1051     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1052     CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1053
1054 #undef addModule
1055 }
1056
1057 CaptureOpenPanel::~CaptureOpenPanel()
1058 {
1059 }
1060
1061 void CaptureOpenPanel::clear()
1062 {
1063     advMRL.clear();
1064 }
1065
1066 void CaptureOpenPanel::updateMRL()
1067 {
1068     QString mrl = "";
1069     QStringList fileList;
1070     int i_devicetype = ui.deviceCombo->itemData(
1071             ui.deviceCombo->currentIndex() ).toInt();
1072     switch( i_devicetype )
1073     {
1074 #ifdef WIN32
1075     case BDA_DEVICE:
1076         if( bdas->isChecked() ) mrl = "dvb-s://";
1077         else if(  bdat->isChecked() ) mrl = "dvb-t://";
1078         else if(  bdac->isChecked() ) mrl = "dvb-c://";
1079         else if(  bdaa->isChecked() ) mrl = "atsc://";
1080         else return;
1081         fileList << mrl; mrl = "";
1082
1083         mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
1084         if( bdas->isChecked() || bdac->isChecked() )
1085             mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1086         else if( bdat->isChecked() )
1087             mrl += " :dvb-bandwidth=" +
1088                 QString::number( bdaBandBox->itemData(
1089                     bdaBandBox->currentIndex() ).toInt() );
1090         break;
1091     case DSHOW_DEVICE:
1092         fileList << "dshow://";
1093         mrl+= " :dshow-vdev=" +
1094             colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1095         mrl+= " :dshow-adev=" +
1096             colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
1097         if( dshowVSizeLine->isModified() )
1098             mrl += " :dshow-size=" + dshowVSizeLine->text();
1099         break;
1100 #else
1101     case V4L_DEVICE:
1102         fileList << "v4l://";
1103         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1104         mrl += " :v4l-adev=" + v4lAudioDevice->text();
1105         mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1106         mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1107         break;
1108     case V4L2_DEVICE:
1109         fileList << "v4l2://";
1110         mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1111         mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1112         mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1113         break;
1114     case JACK_DEVICE:
1115         mrl = "jack://";
1116         mrl += "channels=" + QString::number( jackChannels->value() );
1117         mrl += ":ports=" + jackPortsSelected->text();
1118         fileList << mrl; mrl = "";
1119
1120         mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1121         if ( jackPace->isChecked() )
1122         {
1123                 mrl += " :jack-input-use-vlc-pace";
1124         }
1125         if ( jackConnect->isChecked() )
1126         {
1127                 mrl += " :jack-input-auto-connect";
1128         }
1129         break;
1130     case PVR_DEVICE:
1131         fileList << "pvr://";
1132         mrl += " :pvr-device=" + pvrDevice->text();
1133         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1134         mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1135         if( pvrFreq->value() )
1136             mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1137         if( pvrBitr->value() )
1138             mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1139         break;
1140     case DVB_DEVICE:
1141         fileList << "dvb://";
1142         mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1143         mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
1144         mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1145         break;
1146 #endif
1147     case SCREEN_DEVICE:
1148         fileList << "screen://";
1149         mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1150         updateButtons();
1151         break;
1152     }
1153
1154     if( !advMRL.isEmpty() ) mrl += advMRL;
1155
1156     emit mrlUpdated( fileList, mrl );
1157 }
1158
1159 /**
1160  * Update the Buttons (show/hide) for the GUI as all device type don't
1161  * use the same ui. elements.
1162  **/
1163 void CaptureOpenPanel::updateButtons()
1164 {
1165     /*  Be sure to display the ui Elements in case they were hidden by
1166      *  some Device Type (like Screen://) */
1167     ui.optionsBox->show();
1168     ui.advancedButton->show();
1169     /* Get the current Device Number */
1170     int i_devicetype = ui.deviceCombo->itemData(
1171                                 ui.deviceCombo->currentIndex() ).toInt();
1172     switch( i_devicetype )
1173     {
1174 #ifdef WIN32
1175     case BDA_DEVICE:
1176         if( bdas->isChecked() || bdac->isChecked() )
1177         {
1178             bdaSrate->show();
1179             bdaSrateLabel->show();
1180             bdaBandBox->hide();
1181             bdaBandLabel->hide();
1182         }
1183         else if( bdat->isChecked() )
1184         {
1185             bdaSrate->hide();
1186             bdaSrateLabel->hide();
1187             bdaBandBox->show();
1188             bdaBandLabel->show();
1189         }
1190         break;
1191 #else
1192     case DVB_DEVICE:
1193         if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1194         if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1195         break;
1196 #endif
1197     case SCREEN_DEVICE:
1198         //ui.optionsBox->hide();
1199         ui.advancedButton->hide();
1200         break;
1201     }
1202
1203     advMRL.clear();
1204 }
1205
1206 void CaptureOpenPanel::advancedDialog()
1207 {
1208     /* Get selected device type */
1209     int i_devicetype = ui.deviceCombo->itemData(
1210                                 ui.deviceCombo->currentIndex() ).toInt();
1211
1212     /* Get the corresponding module */
1213     module_t *p_module =
1214         module_find( psz_devModule[i_devicetype] );
1215     if( NULL == p_module ) return;
1216
1217     /* Init */
1218     QList<ConfigControl *> controls;
1219
1220     /* Get the confsize  */
1221     unsigned int i_confsize;
1222     module_config_t *p_config;
1223     p_config = module_config_get( p_module, &i_confsize );
1224
1225     /* New Adv Prop dialog */
1226     adv = new QDialog( this );
1227     adv->setWindowTitle( qtr( "Advanced Options" ) );
1228
1229     /* A main Layout with a Frame */
1230     QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1231     QScrollArea *scroll = new QScrollArea;
1232     mainLayout->addWidget( scroll );
1233
1234     QFrame *advFrame = new QFrame;
1235     /* GridLayout inside the Frame */
1236     QGridLayout *gLayout = new QGridLayout( advFrame );
1237
1238     scroll->setWidgetResizable( true );
1239     scroll->setWidget( advFrame );
1240
1241     /* Create the options inside the FrameLayout */
1242     for( int n = 0; n < (int)i_confsize; n++ )
1243     {
1244         module_config_t *p_item = p_config + n;
1245         ConfigControl *config = ConfigControl::createControl(
1246                         VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1247         controls.append( config );
1248     }
1249
1250     /* Button stuffs */
1251     QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1252     QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1253     QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1254
1255     CONNECT( closeButton, clicked(), adv, accept() );
1256     CONNECT( cancelButton, clicked(), adv, reject() );
1257
1258     advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1259     advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1260
1261     mainLayout->addWidget( advButtonBox );
1262
1263     /* Creation of the MRL */
1264     if( adv->exec() )
1265     {
1266         QString tempMRL = "";
1267         for( int i = 0; i < controls.size(); i++ )
1268         {
1269             ConfigControl *control = controls[i];
1270             if( !control )
1271             {
1272                 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1273                 continue;
1274             }
1275
1276             tempMRL += (i ? " :" : ":");
1277
1278             if( control->getType() == CONFIG_ITEM_BOOL )
1279                 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1280                     tempMRL += "no-";
1281
1282             tempMRL += control->getName();
1283
1284             switch( control->getType() )
1285             {
1286                 case CONFIG_ITEM_STRING:
1287                 case CONFIG_ITEM_FILE:
1288                 case CONFIG_ITEM_DIRECTORY:
1289                 case CONFIG_ITEM_MODULE:
1290                     tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1291                     break;
1292                 case CONFIG_ITEM_INTEGER:
1293                     tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1294                     break;
1295                 case CONFIG_ITEM_FLOAT:
1296                     tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1297                     break;
1298             }
1299         }
1300         advMRL = tempMRL;
1301         updateMRL();
1302         msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1303     }
1304     delete adv;
1305     module_config_free( p_config );
1306     module_release (p_module);
1307 }
1308