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