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