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