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