]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open_panels.cpp
qt4: missing undefs.
[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                                  p_intf->p_sys->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->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     p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
244     ui.fileListWidg->clear();
245 }
246
247 /* Function called by Open Dialog when clicked on cancel */
248 void FileOpenPanel::clear()
249 {
250     ui.fileListWidg->clear();
251     ui.subInput->clear();
252 }
253
254 /**************************************************************************
255  * Open Discs ( DVD, CD, VCD and similar devices )                        *
256  **************************************************************************/
257 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
258                                 OpenPanel( _parent, _p_intf )
259 {
260     ui.setupUi( this );
261
262     /* Get the default configuration path for the devices */
263     psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
264     psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
265     psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
266
267     /* State to avoid overwritting the users changes with the configuration */
268     b_firstdvd = true;
269     b_firstvcd = true;
270     b_firstcdda = true;
271
272     ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
273     ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
274
275 #ifdef WIN32 /* Disc drives probing for Windows */
276     char szDrives[512];
277     szDrives[0] = '\0';
278     if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
279     {
280         char *drive = szDrives;
281         UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
282         while( *drive )
283         {
284             if( GetDriveTypeA(drive) == DRIVE_CDROM )
285                 ui.deviceCombo->addItem( drive );
286
287             /* go to next drive */
288             while( *(drive++) );
289         }
290         SetErrorMode(oldMode);
291     }
292 #else /* Use a Completer under Linux */
293     QCompleter *discCompleter = new QCompleter( this );
294     discCompleter->setModel( new QDirModel( discCompleter ) );
295     ui.deviceCombo->setCompleter( discCompleter );
296 #endif
297
298     /* CONNECTs */
299     BUTTONACT( ui.dvdRadioButton, updateButtons() );
300     BUTTONACT( ui.vcdRadioButton, updateButtons() );
301     BUTTONACT( ui.audioCDRadioButton, updateButtons() );
302     BUTTONACT( ui.dvdsimple, updateButtons() );
303     BUTTONACT( ui.browseDiscButton, browseDevice() );
304     BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
305             eject() );
306
307     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
308     CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
309     CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
310     CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
311     CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
312
313     /* Run once the updateButtons function in order to fill correctly the comboBoxes */
314     updateButtons();
315 }
316
317 DiscOpenPanel::~DiscOpenPanel()
318 {
319     free( psz_dvddiscpath );
320     free( psz_vcddiscpath );
321     free( psz_cddadiscpath );
322 }
323
324 void DiscOpenPanel::clear()
325 {
326     ui.titleSpin->setValue( 0 );
327     ui.chapterSpin->setValue( 0 );
328     ui.subtitlesSpin->setValue( -1 );
329     ui.audioSpin->setValue( -1 );
330     b_firstcdda = true;
331     b_firstdvd = true;
332     b_firstvcd = true;
333 }
334
335 #ifdef WIN32
336     #define setDrive( psz_name ) {\
337     int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
338     if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
339 #else
340     #define setDrive( psz_name ) {\
341     ui.deviceCombo->setEditText( qfu( psz_name ) ); }
342 #endif
343
344 /* update the buttons according the type of device */
345 void DiscOpenPanel::updateButtons()
346 {
347     if ( ui.dvdRadioButton->isChecked() )
348     {
349         if( b_firstdvd )
350         {
351             setDrive( psz_dvddiscpath );
352             b_firstdvd = false;
353         }
354         ui.titleLabel->setText( qtr("Title") );
355         ui.chapterLabel->show();
356         ui.chapterSpin->show();
357         ui.diskOptionBox_2->show();
358         ui.dvdsimple->setEnabled( true );
359     }
360     else if ( ui.vcdRadioButton->isChecked() )
361     {
362         if( b_firstvcd )
363         {
364             setDrive( psz_vcddiscpath );
365             b_firstvcd = false;
366         }
367         ui.titleLabel->setText( qtr("Entry") );
368         ui.chapterLabel->hide();
369         ui.chapterSpin->hide();
370         ui.diskOptionBox_2->show();
371         ui.dvdsimple->setEnabled( false );
372     }
373     else /* CDDA */
374     {
375         if( b_firstcdda )
376         {
377             setDrive( psz_cddadiscpath );
378             b_firstcdda = false;
379         }
380         ui.titleLabel->setText( qtr("Track") );
381         ui.chapterLabel->hide();
382         ui.chapterSpin->hide();
383         ui.diskOptionBox_2->hide();
384         ui.dvdsimple->setEnabled( false );
385     }
386
387     updateMRL();
388 }
389
390 #undef setDrive
391
392 /* Update the current MRL */
393 void DiscOpenPanel::updateMRL()
394 {
395     QString mrl = "";
396     QStringList fileList;
397
398     /* CDDAX and VCDX not implemented. TODO ? No. */
399     /* DVD */
400     if( ui.dvdRadioButton->isChecked() ) {
401         if( !ui.dvdsimple->isChecked() )
402             mrl = "dvd://";
403         else
404             mrl = "dvdsimple://";
405         mrl += ui.deviceCombo->currentText();
406         emit methodChanged( "dvdnav-caching" );
407
408         if ( ui.titleSpin->value() > 0 ) {
409             mrl += QString("@%1").arg( ui.titleSpin->value() );
410             if ( ui.chapterSpin->value() > 0 ) {
411                 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
412             }
413         }
414
415     /* VCD */
416     } else if ( ui.vcdRadioButton->isChecked() ) {
417         mrl = "vcd://" + ui.deviceCombo->currentText();
418         emit methodChanged( "vcd-caching" );
419
420         if( ui.titleSpin->value() > 0 ) {
421             mrl += QString("@E%1").arg( ui.titleSpin->value() );
422         }
423
424     /* CDDA */
425     } else {
426         mrl = "cdda://" + ui.deviceCombo->currentText();
427     }
428
429     fileList << mrl; mrl = "";
430
431     if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
432     {
433         if ( ui.audioSpin->value() >= 0 ) {
434             mrl += " :audio-track=" +
435                 QString("%1").arg( ui.audioSpin->value() );
436         }
437         if ( ui.subtitlesSpin->value() >= 0 ) {
438             mrl += " :sub-track=" +
439                 QString("%1").arg( ui.subtitlesSpin->value() );
440         }
441     }
442     else
443     {
444         if( ui.titleSpin->value() > 0 )
445             mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
446     }
447     emit mrlUpdated( fileList, mrl );
448 }
449
450 void DiscOpenPanel::browseDevice()
451 {
452     QString dir = QFileDialog::getExistingDirectory( this,
453             qtr( I_DEVICE_TOOLTIP ) );
454     if (!dir.isEmpty())
455         ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
456
457     updateMRL();
458 }
459
460 void DiscOpenPanel::eject()
461 {
462     intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
463 }
464
465 void DiscOpenPanel::accept()
466 {}
467
468 /**************************************************************************
469  * Open Network streams and URL pages                                     *
470  **************************************************************************/
471 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
472                                 OpenPanel( _parent, _p_intf )
473 {
474     ui.setupUi( this );
475
476     /* CONNECTs */
477     CONNECT( ui.protocolCombo, activated( int ),
478              this, updateProtocol( int ) );
479     CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
480     CONNECT( ui.addressText, textChanged( const QString& ), this, updateMRL());
481
482     ui.protocolCombo->addItem( "" );
483     ui.protocolCombo->addItem("HTTP", QVariant("http"));
484     ui.protocolCombo->addItem("HTTPS", QVariant("https"));
485     ui.protocolCombo->addItem("MMS", QVariant("mms"));
486     ui.protocolCombo->addItem("FTP", QVariant("ftp"));
487     ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
488     ui.protocolCombo->addItem("RTP", QVariant("rtp"));
489     ui.protocolCombo->addItem("UDP", QVariant("udp"));
490     ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
491
492     updateProtocol( ui.protocolCombo->currentIndex() );
493
494     if( config_GetInt( p_intf, "qt-recentplay" ) )
495     {
496         mrlList = new QStringListModel(
497                 getSettings()->value( "Open/netMRL" ).toStringList() );
498         QCompleter *completer = new QCompleter( mrlList, this );
499         ui.addressText->setCompleter( completer );
500
501         CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
502     }
503     else
504         mrlList = NULL;
505 }
506
507 NetOpenPanel::~NetOpenPanel()
508 {
509     if( !mrlList ) return;
510
511     QStringList tempL = mrlList->stringList();
512     while( tempL.size() > 8 ) tempL.removeFirst();
513
514     getSettings()->setValue( "Open/netMRL", tempL );
515
516     delete mrlList;
517 }
518
519 void NetOpenPanel::clear()
520 {}
521
522 /* update the widgets according the type of protocol */
523 void NetOpenPanel::updateProtocol( int idx_proto ) {
524     QString addr = ui.addressText->text();
525     QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
526
527     ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
528                              idx_proto == RTP_PROTO );
529
530     if( idx_proto == NO_PROTO ) return;
531
532     /* If we already have a protocol in the address, replace it */
533     if( addr.contains( "://"))
534     {
535         if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
536             addr.replace( QRegExp("^.*://@*"), proto + "://");
537         else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
538                 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
539                 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
540              addr.replace( QRegExp("^.*://"), proto + "://@");
541     else
542              addr.replace( QRegExp("^.*://"), proto + "://");
543         addr.replace( QRegExp("@+"), "@");
544         ui.addressText->setText( addr );
545     }
546     updateMRL();
547 }
548
549 void NetOpenPanel::updateMRL() {
550     QString mrl = "";
551     QString addr = ui.addressText->text();
552     addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
553     int idx_proto = ui.protocolCombo->currentIndex();
554     int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
555     int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
556     int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
557     int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
558     if( addr.contains( "://"))
559     {
560         /* Match the correct item in the comboBox */
561         ui.protocolCombo->setCurrentIndex(
562                 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
563         mrl = addr;
564     }
565     else
566     {
567         switch( idx_proto ) {
568         case HTTP_PROTO:
569             mrl = "http://" + addr;
570             emit methodChanged("http-caching");
571             break;
572         case HTTPS_PROTO:
573             mrl = "https://" + addr;
574             emit methodChanged("http-caching");
575             break;
576         case MMS_PROTO:
577             mrl = "mms://" + addr;
578             emit methodChanged("mms-caching");
579             break;
580         case FTP_PROTO:
581             mrl = "ftp://" + addr;
582             emit methodChanged("ftp-caching");
583             break;
584         case RTSP_PROTO:
585             mrl = "rtsp://" + addr;
586             emit methodChanged("rtsp-caching");
587             break;
588         case UDP_PROTO:
589             if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
590                 mrl = "udp://@";
591         else
592                     mrl = "udp://";
593             /* Add [] to IPv6 */
594             if ( addr_is_ipv6  && !addr.contains('[') )
595             {
596                 mrl += "[" + addr + "]";
597             }
598             else mrl += addr;
599             if(!addr_has_port)
600                 mrl += QString(":%1").arg( ui.portSpin->value() );
601             emit methodChanged("udp-caching");
602             break;
603         case RTP_PROTO:
604             if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
605                     mrl = "rtp://@";
606             else
607                     mrl = "rtp://";
608             if ( addr_is_ipv6 && !addr.contains('[') )
609                 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
610             else
611                 mrl += addr;
612             if(!addr_has_port)
613                 mrl += QString(":%1").arg( ui.portSpin->value() );
614             emit methodChanged("rtp-caching");
615             break;
616         case RTMP_PROTO:
617             mrl = "rtmp://" + addr;
618             emit methodChanged("rtmp-caching");
619             break;
620         }
621     }
622
623     QStringList qsl; qsl<< mrl;
624     emit mrlUpdated( qsl, "" );
625 }
626
627 void NetOpenPanel::updateCompleter()
628 {
629     assert( mrlList );
630     QStringList tempL = mrlList->stringList();
631     if( !tempL.contains( ui.addressText->text() ) )
632         tempL.append( ui.addressText->text() );
633     mrlList->setStringList( tempL );
634 }
635
636 /**************************************************************************
637  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
638  **************************************************************************/
639 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
640                                 OpenPanel( _parent, _p_intf )
641 {
642     isInitialized = false;
643 }
644
645 void CaptureOpenPanel::initialize()
646 {
647     if( isInitialized ) return;
648
649     msg_Dbg( p_intf, "Initialization of Capture device panel" );
650     isInitialized = true;
651
652     ui.setupUi( this );
653
654     BUTTONACT( ui.advancedButton, advancedDialog() );
655
656     /* Create two stacked layouts in the main comboBoxes */
657     QStackedLayout *stackedDevLayout = new QStackedLayout;
658     ui.cardBox->setLayout( stackedDevLayout );
659
660     QStackedLayout *stackedPropLayout = new QStackedLayout;
661     ui.optionsBox->setLayout( stackedPropLayout );
662
663     /* Creation and connections of the WIdgets in the stacked layout */
664 #define addModuleAndLayouts( number, name, label )                    \
665     QWidget * name ## DevPage = new QWidget( this );                  \
666     QWidget * name ## PropPage = new QWidget( this );                 \
667     stackedDevLayout->addWidget( name ## DevPage );        \
668     stackedPropLayout->addWidget( name ## PropPage );      \
669     QGridLayout * name ## DevLayout = new QGridLayout;                \
670     QGridLayout * name ## PropLayout = new QGridLayout;               \
671     name ## DevPage->setLayout( name ## DevLayout );                  \
672     name ## PropPage->setLayout( name ## PropLayout );                \
673     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
674
675 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
676
677 #ifdef WIN32
678     /*********************
679      * DirectShow Stuffs *
680      *********************/
681     if( module_exists( "dshow" ) ){
682     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
683
684     /* dshow Main */
685     int line = 0;
686     module_config_t *p_config =
687         config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
688     vdevDshowW = new StringListConfigControl(
689         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
690     line++;
691
692     p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
693     adevDshowW = new StringListConfigControl(
694         VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
695     line++;
696
697     /* dshow Properties */
698     QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
699     dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
700
701     dshowVSizeLine = new QLineEdit;
702     dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
703     dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
704             1, 0, 3, 1 );
705
706     /* dshow CONNECTs */
707     CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
708     CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
709     CuMRL( dshowVSizeLine, textChanged( const QString& ) );
710     }
711
712     /**************
713      * BDA Stuffs *
714      **************/
715     if( module_exists( "bda" ) ){
716     addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
717
718     /* bda Main */
719     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
720
721     bdas = new QRadioButton( "DVB-S" );
722     bdas->setChecked( true );
723     bdac = new QRadioButton( "DVB-C" );
724     bdat = new QRadioButton( "DVB-T" );
725     bdaa = new QRadioButton( "ATSC" );
726
727     bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
728     bdaDevLayout->addWidget( bdas, 0, 1 );
729     bdaDevLayout->addWidget( bdac, 0, 2 );
730     bdaDevLayout->addWidget( bdat, 0, 3 );
731     bdaDevLayout->addWidget( bdaa, 0, 4 );
732
733     /* bda Props */
734     QLabel *bdaFreqLabel =
735                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
736     bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
737
738     bdaFreq = new QSpinBox;
739     bdaFreq->setAlignment( Qt::AlignRight );
740     bdaFreq->setSuffix(" kHz");
741     bdaFreq->setSingleStep( 1000 );
742     setSpinBoxFreq( bdaFreq )
743     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
744
745     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
746     bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
747
748     bdaSrate = new QSpinBox;
749     bdaSrate->setAlignment( Qt::AlignRight );
750     bdaSrate->setSuffix(" kHz");
751     setSpinBoxFreq( bdaSrate );
752     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
753
754     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
755     bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
756
757     bdaBandBox = new QComboBox;
758     setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
759     bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
760
761     bdaBandLabel->hide();
762     bdaBandBox->hide();
763     bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
764             2, 0, 2, 1 );
765
766     /* bda CONNECTs */
767     CuMRL( bdaFreq, valueChanged ( int ) );
768     CuMRL( bdaSrate, valueChanged ( int ) );
769     CuMRL( bdaBandBox,  currentIndexChanged ( int ) );
770     BUTTONACT( bdas, updateButtons() );
771     BUTTONACT( bdat, updateButtons() );
772     BUTTONACT( bdac, updateButtons() );
773     BUTTONACT( bdaa, updateButtons() );
774     BUTTONACT( bdas, updateMRL() );
775     BUTTONACT( bdat, updateMRL() );
776     BUTTONACT( bdac, updateMRL() );
777     BUTTONACT( bdaa, updateMRL() );
778     }
779
780 #else /* WIN32 */
781     /*******
782      * V4L2*
783      *******/
784     if( module_exists( "v4l2" ) ){
785     addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
786
787     /* V4l Main panel */
788     QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
789     v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
790
791     v4l2VideoDevice = new QLineEdit;
792     v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
793
794     QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
795     v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
796
797     v4l2AudioDevice = new QLineEdit;
798     v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
799
800     /* v4l2 Props panel */
801     QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
802     v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
803
804     v4l2StdBox = new QComboBox;
805     setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
806     v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
807     v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
808             1, 0, 3, 1 );
809
810     /* v4l2 CONNECTs */
811     CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
812     CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
813     CuMRL( v4l2StdBox,  currentIndexChanged ( int ) );
814     }
815
816     /*******
817      * V4L *
818      *******/
819     if( module_exists( "v4l" ) ){
820     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
821
822     /* V4l Main panel */
823     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
824     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
825
826     v4lVideoDevice = new QLineEdit;
827     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
828
829     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
830     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
831
832     v4lAudioDevice = new QLineEdit;
833     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
834
835     /* V4l Props panel */
836     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
837     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
838
839     v4lNormBox = new QComboBox;
840     setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
841     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
842
843     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
844     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
845
846     v4lFreq = new QSpinBox;
847     v4lFreq->setAlignment( Qt::AlignRight );
848     v4lFreq->setSuffix(" kHz");
849     setSpinBoxFreq( v4lFreq );
850     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
851     v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
852             2, 0, 2, 1 );
853
854     /* v4l CONNECTs */
855     CuMRL( v4lVideoDevice, textChanged( const QString& ) );
856     CuMRL( v4lAudioDevice, textChanged( const QString& ) );
857     CuMRL( v4lFreq, valueChanged ( int ) );
858     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
859     }
860
861     /*******
862      * JACK *
863      *******/
864     if( module_exists( "jack" ) ){
865     addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
866
867     /* Jack Main panel */
868     /* Channels */
869     QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
870     jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
871
872     jackChannels = new QSpinBox;
873     setSpinBoxFreq( jackChannels );
874     jackChannels->setMaximum(255);
875     jackChannels->setValue(2);
876     jackChannels->setAlignment( Qt::AlignRight );
877     jackDevLayout->addWidget( jackChannels, 1, 1 );
878
879     /* Selected ports */
880     QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
881     jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
882
883     jackPortsSelected = new QLineEdit( qtr( ".*") );
884     jackPortsSelected->setAlignment( Qt::AlignRight );
885     jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
886
887     /* Jack Props panel */
888
889     /* Caching */
890     QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
891     jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
892     jackCaching = new QSpinBox;
893     setSpinBoxFreq( jackCaching );
894     jackCaching->setSuffix( " ms" );
895     jackCaching->setValue(1000);
896     jackCaching->setAlignment( Qt::AlignRight );
897     jackPropLayout->addWidget( jackCaching, 1 , 2 );
898
899     /* Pace */
900     jackPace = new QCheckBox(qtr( "Use VLC pace" ));
901     jackPropLayout->addWidget( jackPace, 2, 1 );
902
903     /* Auto Connect */
904     jackConnect = new QCheckBox( qtr( "Auto connnection" ));
905     jackPropLayout->addWidget( jackConnect, 2, 2 );
906
907     /* Jack CONNECTs */
908     CuMRL( jackChannels, valueChanged( int ) );
909     CuMRL( jackCaching, valueChanged( int ) );
910     CuMRL( jackPace, stateChanged( int ) );
911     CuMRL( jackConnect, stateChanged( int ) );
912     CuMRL( jackPortsSelected, textChanged( const QString& ) );
913     }
914
915     /************
916      * PVR      *
917      ************/
918     if( module_exists( "pvr" ) ){
919     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
920
921     /* PVR Main panel */
922     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
923     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
924
925     pvrDevice = new QLineEdit;
926     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
927
928     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
929     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
930
931     pvrRadioDevice = new QLineEdit;
932     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
933
934     /* PVR props panel */
935     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
936     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
937
938     pvrNormBox = new QComboBox;
939     setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
940     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
941
942     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
943     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
944
945     pvrFreq = new QSpinBox;
946     pvrFreq->setAlignment( Qt::AlignRight );
947     pvrFreq->setSuffix(" kHz");
948     setSpinBoxFreq( pvrFreq );
949     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
950
951     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
952     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
953
954     pvrBitr = new QSpinBox;
955     pvrBitr->setAlignment( Qt::AlignRight );
956     pvrBitr->setSuffix(" kHz");
957     setSpinBoxFreq( pvrBitr );
958     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
959     pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
960             3, 0, 1, 1 );
961
962     /* PVR CONNECTs */
963     CuMRL( pvrDevice, textChanged( const QString& ) );
964     CuMRL( pvrRadioDevice, textChanged( const QString& ) );
965
966     CuMRL( pvrFreq, valueChanged ( int ) );
967     CuMRL( pvrBitr, valueChanged ( int ) );
968     CuMRL( pvrNormBox, currentIndexChanged ( int ) );
969     }
970
971     /**************
972      * DVB Stuffs *
973      **************/
974     if( module_exists( "dvb" ) ){
975     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
976
977     /* DVB Main */
978     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
979     QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
980
981     dvbCard = new QSpinBox;
982     dvbCard->setAlignment( Qt::AlignRight );
983     dvbCard->setPrefix( "/dev/dvb/adapter" );
984
985     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
986     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
987
988     dvbs = new QRadioButton( "DVB-S" );
989     dvbs->setChecked( true );
990     dvbc = new QRadioButton( "DVB-C" );
991     dvbt = new QRadioButton( "DVB-T" );
992
993     dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
994     dvbDevLayout->addWidget( dvbs, 1, 1 );
995     dvbDevLayout->addWidget( dvbc, 1, 2 );
996     dvbDevLayout->addWidget( dvbt, 1, 3 );
997
998     /* DVB Props panel */
999     QLabel *dvbFreqLabel =
1000                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
1001     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
1002
1003     dvbFreq = new QSpinBox;
1004     dvbFreq->setAlignment( Qt::AlignRight );
1005     dvbFreq->setSuffix(" kHz");
1006     dvbFreq->setSingleStep( 1000 );
1007     setSpinBoxFreq( dvbFreq  );
1008     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
1009
1010     dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
1011     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
1012
1013     dvbSrate = new QSpinBox;
1014     dvbSrate->setAlignment( Qt::AlignRight );
1015     dvbSrate->setSuffix(" kHz");
1016     setSpinBoxFreq( dvbSrate );
1017     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
1018
1019     dvbBandLabel = new QLabel( qtr( "Bandwidth" ) );
1020     dvbPropLayout->addWidget( dvbBandLabel, 2, 0 );
1021
1022     dvbBandBox = new QComboBox;
1023     /* This doesn't work since dvb-bandwidth doesn't seem to be a
1024        list of Integers
1025        setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
1026      */
1027     dvbBandBox->addItem( qtr( "Auto" ), 0 );
1028     dvbBandBox->addItem( qtr( "6 MHz" ), 6 );
1029     dvbBandBox->addItem( qtr( "7 MHz" ), 7 );
1030     dvbBandBox->addItem( qtr( "8 MHz" ), 8 );
1031     dvbPropLayout->addWidget( dvbBandBox, 2, 1 );
1032
1033     dvbBandLabel->hide();
1034     dvbBandBox->hide();
1035
1036     dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
1037             2, 0, 2, 1 );
1038
1039     /* DVB CONNECTs */
1040     CuMRL( dvbCard, valueChanged ( int ) );
1041     CuMRL( dvbFreq, valueChanged ( int ) );
1042     CuMRL( dvbSrate, valueChanged ( int ) );
1043
1044     BUTTONACT( dvbs, updateButtons() );
1045     BUTTONACT( dvbt, updateButtons() );
1046     BUTTONACT( dvbc, updateButtons() );
1047     }
1048
1049 #endif
1050
1051
1052     /**********
1053      * Screen *
1054      **********/
1055     addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
1056     QLabel *screenLabel = new QLabel( qtr( "Your display will be "
1057             "opened and played in order to stream or save it." ) );
1058     screenLabel->setWordWrap( true );
1059     screenDevLayout->addWidget( screenLabel, 0, 0 );
1060
1061     QLabel *screenFPSLabel = new QLabel(
1062             qtr( "Desired frame rate for the capture." ) );
1063     screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1064
1065     screenFPS = new QSpinBox;
1066     screenFPS->setValue( 1 );
1067     screenFPS->setAlignment( Qt::AlignRight );
1068     screenPropLayout->addWidget( screenFPS, 0, 1 );
1069
1070     /* General connects */
1071     CONNECT( ui.deviceCombo, activated( int ) ,
1072              stackedDevLayout, setCurrentIndex( int ) );
1073     CONNECT( ui.deviceCombo, activated( int ),
1074              stackedPropLayout, setCurrentIndex( int ) );
1075     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1076     CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1077
1078 #undef CuMRL
1079 #undef addModuleAndLayouts
1080 }
1081
1082 CaptureOpenPanel::~CaptureOpenPanel()
1083 {
1084 }
1085
1086 void CaptureOpenPanel::clear()
1087 {
1088     advMRL.clear();
1089 }
1090
1091 void CaptureOpenPanel::updateMRL()
1092 {
1093     QString mrl = "";
1094     QStringList fileList;
1095     int i_devicetype = ui.deviceCombo->itemData(
1096             ui.deviceCombo->currentIndex() ).toInt();
1097     switch( i_devicetype )
1098     {
1099 #ifdef WIN32
1100     case BDA_DEVICE:
1101         if( bdas->isChecked() ) mrl = "dvb-s://";
1102         else if(  bdat->isChecked() ) mrl = "dvb-t://";
1103         else if(  bdac->isChecked() ) mrl = "dvb-c://";
1104         else if(  bdaa->isChecked() ) mrl = "atsc://";
1105         else return;
1106         fileList << mrl; mrl = "";
1107
1108         mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
1109         if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked() )
1110             mrl +="000";
1111         if( bdas->isChecked() || bdac->isChecked() )
1112             mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1113         else if( bdat->isChecked() || bdaa->isChecked() )
1114             mrl += " :dvb-bandwidth=" +
1115                 QString::number( bdaBandBox->itemData(
1116                     bdaBandBox->currentIndex() ).toInt() );
1117         break;
1118     case DSHOW_DEVICE:
1119         fileList << "dshow://";
1120         mrl+= " :dshow-vdev=" +
1121             colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1122         mrl+= " :dshow-adev=" +
1123             colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
1124         if( dshowVSizeLine->isModified() )
1125             mrl += " :dshow-size=" + dshowVSizeLine->text();
1126         break;
1127 #else
1128     case V4L_DEVICE:
1129         fileList << "v4l://";
1130         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1131         mrl += " :v4l-adev=" + v4lAudioDevice->text();
1132         mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1133         mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1134         break;
1135     case V4L2_DEVICE:
1136         fileList << "v4l2://";
1137         mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1138         mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1139         mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1140         break;
1141     case JACK_DEVICE:
1142         mrl = "jack://";
1143         mrl += "channels=" + QString::number( jackChannels->value() );
1144         mrl += ":ports=" + jackPortsSelected->text();
1145         fileList << mrl; mrl = "";
1146
1147         mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1148         if ( jackPace->isChecked() )
1149         {
1150                 mrl += " :jack-input-use-vlc-pace";
1151         }
1152         if ( jackConnect->isChecked() )
1153         {
1154                 mrl += " :jack-input-auto-connect";
1155         }
1156         break;
1157     case PVR_DEVICE:
1158         fileList << "pvr://";
1159         mrl += " :pvr-device=" + pvrDevice->text();
1160         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1161         mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1162         if( pvrFreq->value() )
1163             mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1164         if( pvrBitr->value() )
1165             mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1166         break;
1167     case DVB_DEVICE:
1168         fileList << "dvb://";
1169         mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1170         mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
1171         if( dvbc->isChecked() || dvbt->isChecked() )
1172             mrl +="000";
1173         if( dvbs->isChecked() || dvbc->isChecked() )
1174             mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1175         else if( dvbt->isChecked() )
1176             mrl += " :dvb-bandwidth=" +
1177                 QString::number( dvbBandBox->itemData(
1178                     dvbBandBox->currentIndex() ).toInt() );
1179
1180         break;
1181 #endif
1182     case SCREEN_DEVICE:
1183         fileList << "screen://";
1184         mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1185         updateButtons();
1186         break;
1187     }
1188
1189     if( !advMRL.isEmpty() ) mrl += advMRL;
1190
1191     emit mrlUpdated( fileList, mrl );
1192 }
1193
1194 /**
1195  * Update the Buttons (show/hide) for the GUI as all device type don't
1196  * use the same ui. elements.
1197  **/
1198 void CaptureOpenPanel::updateButtons()
1199 {
1200     /*  Be sure to display the ui Elements in case they were hidden by
1201      *  some Device Type (like Screen://) */
1202     ui.optionsBox->show();
1203     ui.advancedButton->show();
1204     /* Get the current Device Number */
1205     int i_devicetype = ui.deviceCombo->itemData(
1206                                 ui.deviceCombo->currentIndex() ).toInt();
1207     switch( i_devicetype )
1208     {
1209 #ifdef WIN32
1210     case BDA_DEVICE:
1211         if( bdas->isChecked() || bdac->isChecked() )
1212         {
1213             bdaSrate->show();
1214             bdaSrateLabel->show();
1215             bdaBandBox->hide();
1216             bdaBandLabel->hide();
1217         }
1218         else if( bdat->isChecked() || bdaa->isChecked() )
1219         {
1220             bdaSrate->hide();
1221             bdaSrateLabel->hide();
1222             bdaBandBox->show();
1223             bdaBandLabel->show();
1224         }
1225         break;
1226 #else
1227     case DVB_DEVICE:
1228         if( dvbs->isChecked() || dvbc->isChecked() )
1229         {
1230             dvbSrate->show();
1231             dvbSrateLabel->show();
1232             dvbBandBox->hide();
1233             dvbBandLabel->hide();
1234         }
1235         else if( dvbt->isChecked() )
1236         {
1237             dvbSrate->hide();
1238             dvbSrateLabel->hide();
1239             dvbBandBox->show();
1240             dvbBandLabel->show();
1241         }
1242         break;
1243 #endif
1244     case SCREEN_DEVICE:
1245         //ui.optionsBox->hide();
1246         ui.advancedButton->hide();
1247         break;
1248     }
1249
1250     advMRL.clear();
1251 }
1252
1253 void CaptureOpenPanel::advancedDialog()
1254 {
1255     /* Get selected device type */
1256     int i_devicetype = ui.deviceCombo->itemData(
1257                                 ui.deviceCombo->currentIndex() ).toInt();
1258
1259     /* Get the corresponding module */
1260     module_t *p_module =
1261         module_find( psz_devModule[i_devicetype] );
1262     if( NULL == p_module ) return;
1263
1264     /* Init */
1265     QList<ConfigControl *> controls;
1266
1267     /* Get the confsize  */
1268     unsigned int i_confsize;
1269     module_config_t *p_config;
1270     p_config = module_config_get( p_module, &i_confsize );
1271
1272     /* New Adv Prop dialog */
1273     adv = new QDialog( this );
1274     adv->setWindowTitle( qtr( "Advanced Options" ) );
1275
1276     /* A main Layout with a Frame */
1277     QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1278     QScrollArea *scroll = new QScrollArea;
1279     mainLayout->addWidget( scroll );
1280
1281     QFrame *advFrame = new QFrame;
1282     /* GridLayout inside the Frame */
1283     QGridLayout *gLayout = new QGridLayout( advFrame );
1284
1285     scroll->setWidgetResizable( true );
1286     scroll->setWidget( advFrame );
1287
1288     /* Create the options inside the FrameLayout */
1289     for( int n = 0; n < (int)i_confsize; n++ )
1290     {
1291         module_config_t *p_item = p_config + n;
1292         ConfigControl *config = ConfigControl::createControl(
1293                         VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1294         if ( config )
1295             controls.append( config );
1296     }
1297
1298     /* Button stuffs */
1299     QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1300     QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1301     QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1302
1303     CONNECT( closeButton, clicked(), adv, accept() );
1304     CONNECT( cancelButton, clicked(), adv, reject() );
1305
1306     advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1307     advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1308
1309     mainLayout->addWidget( advButtonBox );
1310
1311     /* Creation of the MRL */
1312     if( adv->exec() )
1313     {
1314         QString tempMRL = "";
1315         for( int i = 0; i < controls.size(); i++ )
1316         {
1317             ConfigControl *control = controls[i];
1318
1319             tempMRL += (i ? " :" : ":");
1320
1321             if( control->getType() == CONFIG_ITEM_BOOL )
1322                 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1323                     tempMRL += "no-";
1324
1325             tempMRL += control->getName();
1326
1327             switch( control->getType() )
1328             {
1329                 case CONFIG_ITEM_STRING:
1330                 case CONFIG_ITEM_FILE:
1331                 case CONFIG_ITEM_DIRECTORY:
1332                 case CONFIG_ITEM_MODULE:
1333                     tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1334                     break;
1335                 case CONFIG_ITEM_INTEGER:
1336                     tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1337                     break;
1338                 case CONFIG_ITEM_FLOAT:
1339                     tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1340                     break;
1341             }
1342         }
1343         advMRL = tempMRL;
1344         updateMRL();
1345         msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1346     }
1347     for( int i = 0; i < controls.size(); i++ )
1348     {
1349         ConfigControl *control = controls[i];
1350         delete control ;
1351     }
1352     delete adv;
1353     module_config_free( p_config );
1354     module_release (p_module);
1355 }
1356