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