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