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