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