]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open.cpp
Qt4 - Open: accept more than one file.
[vlc] / modules / gui / qt4 / components / open.cpp
1 /*****************************************************************************
2  * open.cpp : Panels for the open dialogs
3  ****************************************************************************
4  * Copyright (C) 2006-2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25
26 #include "qt4.hpp"
27 #include "components/open.hpp"
28 #include "dialogs/open.hpp"
29 #include "dialogs_provider.hpp"
30 #include "util/customwidgets.hpp"
31
32 #include <QFileDialog>
33 #include <QDialogButtonBox>
34 #include <QLineEdit>
35 #include <QStackedLayout>
36 #include <QListView>
37
38 #ifdef HAVE_LIMITS_H
39 #   include <limits.h>
40 #endif
41
42 /**************************************************************************
43  * Open Files and subtitles                                               *
44  **************************************************************************/
45 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
46                                 OpenPanel( _parent, _p_intf )
47 {
48     /* Classic UI Setup */
49     ui.setupUi( this );
50
51     /* Use a QFileDialog and customize it because we don't want to
52        rewrite it all. Be careful to your eyes cause there are a few hacks.
53        Be very careful and test correctly when you modify this. */
54
55     /* Set Filters for file selection */
56     QString fileTypes = "";
57     ADD_FILTER_MEDIA( fileTypes );
58     ADD_FILTER_VIDEO( fileTypes );
59     ADD_FILTER_AUDIO( fileTypes );
60     ADD_FILTER_PLAYLIST( fileTypes );
61     ADD_FILTER_ALL( fileTypes );
62     fileTypes.replace( QString(";*"), QString(" *"));
63
64     // Make this QFileDialog a child of tempWidget from the ui.
65     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
66             qfu( p_intf->p_libvlc->psz_homedir ), fileTypes );
67     dialogBox->setFileMode( QFileDialog::ExistingFiles );
68     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
69
70     /* retrieve last known path used in file browsing */
71     char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
72     if( psz_filepath )
73     {
74         dialogBox->setDirectory( QString::fromUtf8( psz_filepath ) );
75         delete psz_filepath;
76     }
77
78     /* We don't want to see a grip in the middle of the window, do we? */
79     dialogBox->setSizeGripEnabled( false );
80
81     /* Add a tooltip */
82     dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
83
84     // Add it to the layout
85     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
86
87     // But hide the two OK/Cancel buttons. Enable them for debug.
88     QDialogButtonBox *fileDialogAcceptBox =
89                                         findChildren<QDialogButtonBox*>()[0];
90     fileDialogAcceptBox->hide();
91
92     /* Ugly hacks to get the good Widget */
93     //This lineEdit is the normal line in the fileDialog.
94     lineFileEdit = findChildren<QLineEdit*>()[3];
95     lineFileEdit->hide();
96
97     /* Make a list of QLabel inside the QFileDialog to access the good ones */
98     QList<QLabel *> listLabel = findChildren<QLabel*>();
99
100     /* Hide the FileNames one. Enable it for debug */
101     listLabel[4]->hide();
102     /* Change the text that was uncool in the usual box */
103     listLabel[5]->setText( qtr( "Filter:" ) );
104
105 #if WIN32
106     /* QFileDialog is quite buggy make it brerable on win32 by tweaking 
107        the followin */
108     QListView *fileListView = findChildren<QListView*>().first();
109     fileListView->setLayoutMode(QListView::Batched);
110     fileListView->setViewMode(QListView::ListMode);
111     fileListView->setResizeMode(QListView::Adjust);
112     fileListView->setUniformItemSizes(false);
113     fileListView->setFlow(QListView::TopToBottom);
114     fileListView->setWrapping(true);
115 #endif
116
117     // Hide the subtitles control by default.
118     ui.subFrame->hide();
119
120     /* Build the subs size combo box */
121     setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
122                             ui.sizeSubComboBox );
123
124     /* Build the subs align combo box */
125     setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
126
127     /* Connects  */
128     BUTTONACT( ui.subBrowseButton, browseFileSub() );
129     BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
130
131     CONNECT( ui.fileInput, editTextChanged( QString ), this, updateMRL() );
132     CONNECT( ui.subInput, editTextChanged( QString ), this, updateMRL() );
133     CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
134                                                             updateMRL() );
135     CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this,
136                                                             updateMRL() );
137
138     CONNECT( lineFileEdit, textChanged( QString ), this, browseFile() );
139 }
140
141 FileOpenPanel::~FileOpenPanel()
142 {}
143
144 QStringList FileOpenPanel::browse( QString help )
145 {
146     return THEDP->showSimpleOpen( help );
147 }
148
149 void FileOpenPanel::browseFile()
150 {
151     QString fileString = "";
152     foreach( QString file, dialogBox->selectedFiles() ) {
153          fileString += "\"" + file + "\" ";
154     }
155     ui.fileInput->setEditText( fileString );
156     updateMRL();
157 }
158
159 void FileOpenPanel::browseFileSub()
160 {
161     // FIXME Handle selection of more than one subtitles file
162     QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
163                             EXT_FILTER_SUBTITLE,
164                             dialogBox->directory().absolutePath() );
165     if( files.isEmpty() ) return;
166     ui.subInput->setEditText( files.join(" ") );
167     updateMRL();
168 }
169
170 void FileOpenPanel::updateMRL()
171 {
172     QString mrl = ui.fileInput->currentText();
173
174     if( ui.subCheckBox->isChecked() ) {
175         mrl.append( " :sub-file=" + ui.subInput->currentText() );
176         int align = ui.alignSubComboBox->itemData(
177                     ui.alignSubComboBox->currentIndex() ).toInt();
178         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
179         int size = ui.sizeSubComboBox->itemData(
180                    ui.sizeSubComboBox->currentIndex() ).toInt();
181         mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
182     }
183
184     const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
185     if( ( NULL == psz_filepath )
186       || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
187     {
188         /* set dialog box current directory as last known path */
189         config_PutPsz( p_intf, "qt-filedialog-path",
190                        qtu( dialogBox->directory().absolutePath() ) );
191     }
192     delete psz_filepath;
193
194     emit mrlUpdated( mrl );
195     emit methodChanged( "file-caching" );
196 }
197
198
199 /* Function called by Open Dialog when clicke on Play/Enqueue */
200 void FileOpenPanel::accept()
201 {
202     ui.fileInput->addItem( ui.fileInput->currentText());
203     if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem( 0 );
204 }
205
206 void FileOpenBox::accept()
207 {
208     OpenDialog::getInstance( NULL, NULL )->play();
209 }
210
211 /* Function called by Open Dialog when clicked on cancel */
212 void FileOpenPanel::clear()
213 {
214     ui.fileInput->setEditText( "" );
215     ui.subInput->setEditText( "" );
216 }
217
218 void FileOpenPanel::toggleSubtitleFrame()
219 {
220     if ( ui.subFrame->isVisible() )
221     {
222         ui.subFrame->hide();
223         updateGeometry();
224     /* FiXME Size */
225     }
226     else
227     {
228         ui.subFrame->show();
229     }
230
231     /* Update the MRL */
232     updateMRL();
233 }
234
235 /**************************************************************************
236  * Open Discs ( DVD, CD, VCD and similar devices )                        *
237  **************************************************************************/
238 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
239                                 OpenPanel( _parent, _p_intf )
240 {
241     ui.setupUi( this );
242
243     /*Win 32 Probe  as in WX ? */
244
245     /* CONNECTs */
246     BUTTONACT( ui.dvdRadioButton, updateButtons());
247     BUTTONACT( ui.vcdRadioButton, updateButtons());
248     BUTTONACT( ui.audioCDRadioButton, updateButtons());
249     BUTTONACT( ui.dvdsimple,  updateButtons());
250
251     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
252     CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
253     CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
254     CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
255     CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
256 }
257
258 DiscOpenPanel::~DiscOpenPanel()
259 {}
260
261 void DiscOpenPanel::clear()
262 {
263     ui.titleSpin->setValue( 0 );
264     ui.chapterSpin->setValue( 0 );
265 }
266
267 void DiscOpenPanel::updateButtons()
268 {
269     if ( ui.dvdRadioButton->isChecked() )
270     {
271         ui.titleLabel->setText( qtr("Title") );
272         ui.chapterLabel->show();
273         ui.chapterSpin->show();
274         ui.diskOptionBox_2->show();
275     }
276     else if ( ui.vcdRadioButton->isChecked() )
277     {
278         ui.titleLabel->setText( qtr("Entry") );
279         ui.chapterLabel->hide();
280         ui.chapterSpin->hide();
281         ui.diskOptionBox_2->show();
282     }
283     else
284     {
285         ui.titleLabel->setText( qtr("Track") );
286         ui.chapterLabel->hide();
287         ui.chapterSpin->hide();
288         ui.diskOptionBox_2->hide();
289     }
290
291     updateMRL();
292 }
293
294
295 void DiscOpenPanel::updateMRL()
296 {
297     QString mrl = "";
298
299     /* CDDAX and VCDX not implemented. FIXME ? */
300     /* DVD */
301     if( ui.dvdRadioButton->isChecked() ) {
302         if( !ui.dvdsimple->isChecked() )
303             mrl = "dvd://";
304         else
305             mrl = "dvdsimple://";
306         mrl += ui.deviceCombo->currentText();
307         emit methodChanged( "dvdnav-caching" );
308
309         if ( ui.titleSpin->value() > 0 ) {
310             mrl += QString("@%1").arg( ui.titleSpin->value() );
311             if ( ui.chapterSpin->value() > 0 ) {
312                 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
313             }
314         }
315
316     /* VCD */
317     } else if ( ui.vcdRadioButton->isChecked() ) {
318         mrl = "vcd://" + ui.deviceCombo->currentText();
319         emit methodChanged( "vcd-caching" );
320
321         if( ui.titleSpin->value() > 0 ) {
322             mrl += QString("@E%1").arg( ui.titleSpin->value() );
323         }
324
325     /* CDDA */
326     } else {
327         mrl = "cdda://" + ui.deviceCombo->currentText();
328         if( ui.titleSpin->value() > 0 ) {
329             QString("@%1").arg( ui.titleSpin->value() );
330         }
331     }
332
333     if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
334     {
335         if ( ui.audioSpin->value() >= 0 ) {
336             mrl += " :audio-track=" +
337                 QString("%1").arg( ui.audioSpin->value() );
338         }
339         if ( ui.subtitlesSpin->value() >= 0 ) {
340             mrl += " :sub-track=" +
341                 QString("%1").arg( ui.subtitlesSpin->value() );
342         }
343     }
344     emit mrlUpdated( mrl );
345 }
346
347
348
349 /**************************************************************************
350  * Open Network streams and URL pages                                     *
351  **************************************************************************/
352 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
353                                 OpenPanel( _parent, _p_intf )
354 {
355     ui.setupUi( this );
356
357     /* CONNECTs */
358     CONNECT( ui.protocolCombo, currentIndexChanged( int ),
359              this, updateProtocol( int ) );
360     CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
361     CONNECT( ui.addressText, textChanged( QString ), this, updateAddress());
362     CONNECT( ui.timeShift, clicked(), this, updateMRL());
363     CONNECT( ui.ipv6, clicked(), this, updateMRL());
364
365     ui.protocolCombo->addItem("HTTP", QVariant("http"));
366     ui.protocolCombo->addItem("HTTPS", QVariant("https"));
367     ui.protocolCombo->addItem("FTP", QVariant("ftp"));
368     ui.protocolCombo->addItem("MMS", QVariant("mms"));
369     ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
370     ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
371     ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
372 }
373
374 NetOpenPanel::~NetOpenPanel()
375 {}
376
377 void NetOpenPanel::clear()
378 {}
379
380 void NetOpenPanel::updateProtocol( int idx ) {
381     QString addr = ui.addressText->text();
382     QString proto = ui.protocolCombo->itemData( idx ).toString();
383
384     ui.timeShift->setEnabled( idx >= 4 );
385     ui.ipv6->setEnabled( idx == 4 );
386     ui.addressText->setEnabled( idx != 4 );
387     ui.portSpin->setEnabled( idx >= 4 );
388
389     /* If we already have a protocol in the address, replace it */
390     if( addr.contains( "://")) {
391         msg_Err( p_intf, "replace");
392         addr.replace( QRegExp("^.*://"), proto + "://");
393         ui.addressText->setText( addr );
394     }
395     updateMRL();
396 }
397
398 void NetOpenPanel::updateAddress() {
399     updateMRL();
400 }
401
402 void NetOpenPanel::updateMRL() {
403     QString mrl = "";
404     QString addr = ui.addressText->text();
405     int proto = ui.protocolCombo->currentIndex();
406
407     if( addr.contains( "://") && proto != 4 ) {
408         mrl = addr;
409     } else {
410         switch( proto ) {
411         case 0:
412         case 1:
413             mrl = "http://" + addr;
414             emit methodChanged("http-caching");
415             break;
416         case 3:
417             mrl = "mms://" + addr;
418             emit methodChanged("mms-caching");
419             break;
420         case 2:
421             mrl = "ftp://" + addr;
422             emit methodChanged("ftp-caching");
423             break;
424         case 4: /* RTSP */
425             mrl = "rtsp://" + addr;
426             emit methodChanged("rtsp-caching");
427             break;
428         case 5:
429             mrl = "udp://@";
430             if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
431                 mrl += "[::]";
432             }
433             mrl += QString(":%1").arg( ui.portSpin->value() );
434             emit methodChanged("udp-caching");
435             break;
436         case 6: /* UDP multicast */
437             mrl = "udp://@";
438             /* Add [] to IPv6 */
439             if ( addr.contains(':') && !addr.contains('[') ) {
440                 mrl += "[" + addr + "]";
441             } else mrl += addr;
442             mrl += QString(":%1").arg( ui.portSpin->value() );
443             emit methodChanged("udp-caching");
444         }
445     }
446     if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
447         mrl += " :access-filter=timeshift";
448     }
449     emit mrlUpdated( mrl );
450 }
451
452 /**************************************************************************
453  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
454  **************************************************************************/
455 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
456                                 OpenPanel( _parent, _p_intf )
457 {
458     ui.setupUi( this );
459
460     /* Create two stacked layouts in the main comboBoxes */
461     QStackedLayout *stackedDevLayout = new QStackedLayout;
462     ui.cardBox->setLayout( stackedDevLayout );
463
464     QStackedLayout *stackedPropLayout = new QStackedLayout;
465     ui.optionsBox->setLayout( stackedPropLayout );
466
467     /* Creation and connections of the WIdgets in the stacked layout */
468 #define addModuleAndLayouts( number, name, label )                    \
469     QWidget * name ## DevPage = new QWidget( this );                  \
470     QWidget * name ## PropPage = new QWidget( this );                 \
471     stackedDevLayout->addWidget( name ## DevPage );        \
472     stackedPropLayout->addWidget( name ## PropPage );      \
473     QGridLayout * name ## DevLayout = new QGridLayout;                \
474     QGridLayout * name ## PropLayout = new QGridLayout;               \
475     name ## DevPage->setLayout( name ## DevLayout );                  \
476     name ## PropPage->setLayout( name ## PropLayout );                \
477     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
478
479 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
480
481 #define setMaxBound( spinbox ) spinbox->setRange ( 0, INT_MAX );
482
483     /*******
484      * V4L *
485      *******/
486     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
487
488     /* V4l Main panel */
489     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
490     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
491
492     v4lVideoDevice = new QLineEdit;
493     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
494
495     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
496     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
497
498     v4lAudioDevice = new QLineEdit;
499     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
500
501     /* V4l Props panel */
502     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
503     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
504
505     v4lNormBox = new QComboBox;
506     setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
507     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
508
509     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
510     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
511
512     v4lFreq = new QSpinBox;
513     v4lFreq->setAlignment( Qt::AlignRight );
514     v4lFreq->setSuffix(" kHz");
515     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
516
517     /* v4l CONNECTs */
518     CuMRL( v4lVideoDevice, textChanged( QString ) );
519     CuMRL( v4lAudioDevice, textChanged( QString ) );
520     CuMRL( v4lFreq, valueChanged ( int ) );
521     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
522
523     /************
524      * PVR      *
525      ************/
526     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
527
528     /* PVR Main panel */
529     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
530     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
531
532     pvrDevice = new QLineEdit;
533     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
534
535     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
536     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
537
538     pvrRadioDevice = new QLineEdit;
539     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
540
541     /* PVR props panel */
542     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
543     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
544
545     pvrNormBox = new QComboBox;
546     setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
547     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
548
549     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
550     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
551
552     pvrFreq = new QSpinBox;
553     pvrFreq->setAlignment( Qt::AlignRight );
554     pvrFreq->setSuffix(" kHz");
555     setMaxBound( pvrFreq );
556     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
557
558     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
559     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
560
561     pvrBitr = new QSpinBox;
562     pvrBitr->setAlignment( Qt::AlignRight );
563     pvrBitr->setSuffix(" kHz");
564     setMaxBound( pvrBitr );
565     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
566
567     /* PVR CONNECTs */
568     CuMRL( pvrDevice, textChanged( QString ) );
569     CuMRL( pvrRadioDevice, textChanged( QString ) );
570
571     CuMRL( pvrFreq, valueChanged ( int ) );
572     CuMRL( pvrBitr, valueChanged ( int ) );
573     CuMRL( pvrNormBox,  currentIndexChanged ( int ) );
574
575     /*********************
576      * DirectShow Stuffs *
577      *********************/
578     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
579
580     /* dshow Main */
581
582     QLabel *dshowVDeviceLabel = new QLabel( qtr( "Video Device Name " ) );
583     dshowDevLayout->addWidget( dshowVDeviceLabel, 0, 0 );
584
585     QLabel *dshowADeviceLabel = new QLabel( qtr( "Audio Device Name " ) );
586     dshowDevLayout->addWidget( dshowADeviceLabel, 1, 0 );
587
588     QComboBox *dshowVDevice = new QComboBox;
589     dshowDevLayout->addWidget( dshowVDevice, 0, 1 );
590
591     QComboBox *dshowADevice = new QComboBox;
592     dshowDevLayout->addWidget( dshowADevice, 1, 1 );
593
594     QPushButton *dshowVRefresh = new QPushButton( qtr( "Update List" ) );
595     dshowDevLayout->addWidget( dshowVRefresh, 0, 2 );
596
597     QPushButton *dshowARefresh = new QPushButton( qtr( "Update List" ) );
598     dshowDevLayout->addWidget( dshowARefresh, 1, 2 );
599
600     QPushButton *dshowVConfig = new QPushButton( qtr( "Configure" ) );
601     dshowDevLayout->addWidget( dshowVConfig, 0, 3 );
602
603     QPushButton *dshowAConfig = new QPushButton( qtr( "Configure" ) );
604     dshowDevLayout->addWidget( dshowAConfig, 1, 3 );
605
606     /* dshow Properties */
607
608     QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
609     dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
610
611     QLineEdit *dshowVSizeLine = new QLineEdit;
612     dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
613
614     /* dshow CONNECTs */
615     CuMRL( dshowVDevice, currentIndexChanged ( int ) );
616     CuMRL( dshowADevice, currentIndexChanged ( int ) );
617     CuMRL( dshowVSizeLine, textChanged( QString ) );
618
619     /**************
620      * BDA Stuffs *
621      **************/
622     addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
623
624     /* bda Main */
625     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
626
627     bdas = new QRadioButton( "DVB-S" );
628     bdas->setChecked( true );
629     bdac = new QRadioButton( "DVB-C" );
630     bdat = new QRadioButton( "DVB-T" );
631
632     bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
633     bdaDevLayout->addWidget( bdas, 0, 1 );
634     bdaDevLayout->addWidget( bdac, 0, 2 );
635     bdaDevLayout->addWidget( bdat, 0, 3 );
636
637     /* bda Props */
638     QLabel *bdaFreqLabel =
639                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
640     bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
641
642     bdaFreq = new QSpinBox;
643     bdaFreq->setAlignment( Qt::AlignRight );
644     bdaFreq->setSuffix(" kHz");
645     bdaFreq->setSingleStep( 1000 );
646     setMaxBound( bdaFreq )
647     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
648
649     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
650     bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
651
652     bdaSrate = new QSpinBox;
653     bdaSrate->setAlignment( Qt::AlignRight );
654     bdaSrate->setSuffix(" kHz");
655     setMaxBound( bdaSrate );
656     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
657
658     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
659     bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
660
661     bdaBandBox = new QComboBox;
662     setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
663     bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
664
665     bdaBandLabel->hide();
666     bdaBandBox->hide();
667
668     /* bda CONNECTs */
669     CuMRL( bdaFreq, valueChanged ( int ) );
670     CuMRL( bdaSrate, valueChanged ( int ) );
671     CuMRL( bdaBandBox,  currentIndexChanged ( int ) );
672     BUTTONACT( bdas, updateButtons() );
673     BUTTONACT( bdat, updateButtons() );
674     BUTTONACT( bdac, updateButtons() );
675     BUTTONACT( bdas, updateMRL() );
676     BUTTONACT( bdat, updateMRL() );
677     BUTTONACT( bdac, updateMRL() );
678
679     /**************
680      * DVB Stuffs *
681      **************/
682     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
683
684     /* DVB Main */
685     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
686     QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
687
688     dvbCard = new QSpinBox;
689     dvbCard->setAlignment( Qt::AlignRight );
690     dvbCard->setPrefix( "/dev/dvb/adapter" );
691
692     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
693     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
694
695     dvbs = new QRadioButton( "DVB-S" );
696     dvbs->setChecked( true );
697     dvbc = new QRadioButton( "DVB-C" );
698     dvbt = new QRadioButton( "DVB-T" );
699
700     dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
701     dvbDevLayout->addWidget( dvbs, 1, 1 );
702     dvbDevLayout->addWidget( dvbc, 1, 2 );
703     dvbDevLayout->addWidget( dvbt, 1, 3 );
704
705     /* DVB Props panel */
706     QLabel *dvbFreqLabel =
707                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
708     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
709
710     dvbFreq = new QSpinBox;
711     dvbFreq->setAlignment( Qt::AlignRight );
712     dvbFreq->setSuffix(" kHz");
713     setMaxBound( dvbFreq  );
714     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
715
716     QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
717     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
718
719     dvbSrate = new QSpinBox;
720     dvbSrate->setAlignment( Qt::AlignRight );
721     dvbSrate->setSuffix(" kHz");
722     setMaxBound( dvbSrate );
723     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
724
725     /* DVB CONNECTs */
726     CuMRL( dvbCard, valueChanged ( int ) );
727     CuMRL( dvbFreq, valueChanged ( int ) );
728     CuMRL( dvbSrate, valueChanged ( int ) );
729
730     BUTTONACT( dvbs, updateButtons() );
731     BUTTONACT( dvbt, updateButtons() );
732     BUTTONACT( dvbc, updateButtons() );
733
734     /* General connects */
735     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
736                      stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
737     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
738                      stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
739     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
740
741 #undef addModule
742 }
743
744 CaptureOpenPanel::~CaptureOpenPanel()
745 {}
746
747 void CaptureOpenPanel::clear()
748 {}
749
750 void CaptureOpenPanel::updateMRL()
751 {
752     QString mrl = "";
753     int i_devicetype = ui.deviceCombo->itemData(
754             ui.deviceCombo->currentIndex() ).toInt();
755     msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
756     switch( i_devicetype )
757     {
758     case V4L_DEVICE:
759         mrl = "v4l://";
760         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
761         mrl += " :v4l-adev=" + v4lAudioDevice->text();
762         mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
763         mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
764         break;
765     case PVR_DEVICE:
766         mrl = "pvr://";
767         mrl += " :pvr-device=" + pvrDevice->text();
768         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
769         mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
770         if( pvrFreq->value() )
771             mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
772         if( pvrBitr->value() )
773             mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
774         break;
775     case DVB_DEVICE:
776         mrl = "dvb://";
777         mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
778         mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
779         mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
780         break;
781     case BDA_DEVICE:
782         if( bdas->isChecked() ) mrl = "dvb-s://";
783         else if(  bdat->isChecked() ) mrl = "dvb-t://";
784         else if(  bdac->isChecked() ) mrl = "dvb-c://";
785         else return;
786         mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
787         if( bdas->isChecked() || bdac->isChecked() )
788             mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
789         else
790             mrl += " :dvb-bandwidth=" +
791                 QString("%1").arg( bdaBandBox->itemData(
792                     bdaBandBox->currentIndex() ).toInt() );
793         break;
794   case DSHOW_DEVICE:
795         break;
796     }
797     emit mrlUpdated( mrl );
798 }
799
800 void CaptureOpenPanel::updateButtons()
801 {
802     int i_devicetype = ui.deviceCombo->itemData(
803             ui.deviceCombo->currentIndex() ).toInt();
804     msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
805     switch( i_devicetype )
806     {
807     case DVB_DEVICE:
808         if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
809         if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
810         break;
811     case BDA_DEVICE:
812         if( bdas->isChecked() || bdac->isChecked() )
813         {
814             bdaSrate->show();
815             bdaSrateLabel->show();
816             bdaBandBox->hide();
817             bdaBandLabel->hide();
818         }
819         else
820         {
821             bdaSrate->hide();
822             bdaSrateLabel->hide();
823             bdaBandBox->show();
824             bdaBandLabel->show();
825         }
826         break;
827     }
828 }