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