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