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