]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open.cpp
qt4 - Open: various fixes.
[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     CONNECT( lineFileEdit, textChanged( QString ), this, browseFile() );
138 }
139
140 FileOpenPanel::~FileOpenPanel()
141 {}
142
143 QStringList FileOpenPanel::browse( QString help )
144 {
145     return THEDP->showSimpleOpen( help );
146 }
147
148 #if 0
149 /* Unused. FIXME ? */
150 void FileOpenPanel::browseFile()
151 {
152     QString fileString = "";
153     foreach( QString file, dialogBox->selectedFiles() ) {
154          fileString += "\"" + file + "\" ";
155     }
156     ui.fileInput->setEditText( fileString );
157     updateMRL();
158 }
159 #endif
160
161 void FileOpenPanel::browseFileSub()
162 {
163     // FIXME Handle selection of more than one subtitles file
164     QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
165                             EXT_FILTER_SUBTITLE,
166                             dialogBox->directory().absolutePath() );
167     if( files.isEmpty() ) return;
168     ui.subInput->setEditText( files.join(" ") );
169     updateMRL();
170 }
171
172 void FileOpenPanel::updateMRL()
173 {
174     QString mrl = ui.fileInput->currentText();
175
176     if( ui.subCheckBox->isChecked() ) {
177         mrl.append( " :sub-file=" + ui.subInput->currentText() );
178         int align = ui.alignSubComboBox->itemData(
179                     ui.alignSubComboBox->currentIndex() ).toInt();
180         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
181         int size = ui.sizeSubComboBox->itemData(
182                    ui.sizeSubComboBox->currentIndex() ).toInt();
183         mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
184     }
185
186     const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
187     if( ( NULL == psz_filepath )
188       || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
189     {
190         /* set dialog box current directory as last known path */
191         config_PutPsz( p_intf, "qt-filedialog-path",
192                        qtu( dialogBox->directory().absolutePath() ) );
193     }
194     delete psz_filepath;
195
196     emit mrlUpdated( mrl );
197     emit methodChanged( "file-caching" );
198 }
199
200
201 /* Function called by Open Dialog when clicke on Play/Enqueue */
202 void FileOpenPanel::accept()
203 {
204     ui.fileInput->addItem( ui.fileInput->currentText());
205     if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem( 0 );
206 }
207
208 void FileOpenBox::accept()
209 {
210     OpenDialog::getInstance( NULL, NULL )->play();
211 }
212
213 /* Function called by Open Dialog when clicked on cancel */
214 void FileOpenPanel::clear()
215 {
216     ui.fileInput->setEditText( "" );
217     ui.subInput->setEditText( "" );
218 }
219
220 void FileOpenPanel::toggleSubtitleFrame()
221 {
222     if ( ui.subFrame->isVisible() )
223     {
224         ui.subFrame->hide();
225         updateGeometry();
226     /* FiXME Size */
227     }
228     else
229     {
230         ui.subFrame->show();
231     }
232
233     /* Update the MRL */
234     updateMRL();
235 }
236
237 /**************************************************************************
238  * Open Discs ( DVD, CD, VCD and similar devices )                        *
239  **************************************************************************/
240 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
241                                 OpenPanel( _parent, _p_intf )
242 {
243     ui.setupUi( this );
244
245     /*Win 32 Probe  as in WX ? */
246
247     /* CONNECTs */
248     BUTTONACT( ui.dvdRadioButton, updateButtons());
249     BUTTONACT( ui.vcdRadioButton, updateButtons());
250     BUTTONACT( ui.audioCDRadioButton, updateButtons());
251     BUTTONACT( ui.dvdsimple,  updateButtons());
252
253     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
254     CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
255     CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
256     CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
257     CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
258 }
259
260 DiscOpenPanel::~DiscOpenPanel()
261 {}
262
263 void DiscOpenPanel::clear()
264 {
265     ui.titleSpin->setValue( 0 );
266     ui.chapterSpin->setValue( 0 );
267 }
268
269 void DiscOpenPanel::updateButtons()
270 {
271     if ( ui.dvdRadioButton->isChecked() )
272     {
273         ui.titleLabel->setText( qtr("Title") );
274         ui.chapterLabel->show();
275         ui.chapterSpin->show();
276         ui.diskOptionBox_2->show();
277     }
278     else if ( ui.vcdRadioButton->isChecked() )
279     {
280         ui.titleLabel->setText( qtr("Entry") );
281         ui.chapterLabel->hide();
282         ui.chapterSpin->hide();
283         ui.diskOptionBox_2->show();
284     }
285     else
286     {
287         ui.titleLabel->setText( qtr("Track") );
288         ui.chapterLabel->hide();
289         ui.chapterSpin->hide();
290         ui.diskOptionBox_2->hide();
291     }
292
293     updateMRL();
294 }
295
296
297 void DiscOpenPanel::updateMRL()
298 {
299     QString mrl = "";
300
301     /* CDDAX and VCDX not implemented. FIXME ? */
302     /* DVD */
303     if( ui.dvdRadioButton->isChecked() ) {
304         if( !ui.dvdsimple->isChecked() )
305             mrl = "dvd://";
306         else
307             mrl = "dvdsimple://";
308         mrl += ui.deviceCombo->currentText();
309         emit methodChanged( "dvdnav-caching" );
310
311         if ( ui.titleSpin->value() > 0 ) {
312             mrl += QString("@%1").arg( ui.titleSpin->value() );
313             if ( ui.chapterSpin->value() > 0 ) {
314                 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
315             }
316         }
317
318     /* VCD */
319     } else if ( ui.vcdRadioButton->isChecked() ) {
320         mrl = "vcd://" + ui.deviceCombo->currentText();
321         emit methodChanged( "vcd-caching" );
322
323         if( ui.titleSpin->value() > 0 ) {
324             mrl += QString("@E%1").arg( ui.titleSpin->value() );
325         }
326
327     /* CDDA */
328     } else {
329         mrl = "cdda://" + ui.deviceCombo->currentText();
330         if( ui.titleSpin->value() > 0 ) {
331             QString("@%1").arg( ui.titleSpin->value() );
332         }
333     }
334
335     if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
336     {
337         if ( ui.audioSpin->value() >= 0 ) {
338             mrl += " :audio-track=" +
339                 QString("%1").arg( ui.audioSpin->value() );
340         }
341         if ( ui.subtitlesSpin->value() >= 0 ) {
342             mrl += " :sub-track=" +
343                 QString("%1").arg( ui.subtitlesSpin->value() );
344         }
345     }
346     emit mrlUpdated( mrl );
347 }
348
349
350
351 /**************************************************************************
352  * Open Network streams and URL pages                                     *
353  **************************************************************************/
354 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
355                                 OpenPanel( _parent, _p_intf )
356 {
357     ui.setupUi( this );
358
359     /* CONNECTs */
360     CONNECT( ui.protocolCombo, currentIndexChanged( int ),
361              this, updateProtocol( int ) );
362     CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
363     CONNECT( ui.addressText, textChanged( QString ), this, updateAddress());
364     CONNECT( ui.timeShift, clicked(), this, updateMRL());
365     CONNECT( ui.ipv6, clicked(), this, updateMRL());
366
367     ui.protocolCombo->addItem("HTTP", QVariant("http"));
368     ui.protocolCombo->addItem("HTTPS", QVariant("https"));
369     ui.protocolCombo->addItem("FTP", QVariant("ftp"));
370     ui.protocolCombo->addItem("MMS", QVariant("mms"));
371     ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
372     ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
373     ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
374 }
375
376 NetOpenPanel::~NetOpenPanel()
377 {}
378
379 void NetOpenPanel::clear()
380 {}
381
382 void NetOpenPanel::updateProtocol( int idx ) {
383     QString addr = ui.addressText->text();
384     QString proto = ui.protocolCombo->itemData( idx ).toString();
385
386     ui.timeShift->setEnabled( idx >= 4 );
387     ui.ipv6->setEnabled( idx == 4 );
388     ui.addressText->setEnabled( idx != 4 );
389     ui.portSpin->setEnabled( idx >= 4 );
390
391     /* If we already have a protocol in the address, replace it */
392     if( addr.contains( "://")) {
393         msg_Err( p_intf, "replace");
394         addr.replace( QRegExp("^.*://"), proto + "://");
395         ui.addressText->setText( addr );
396     }
397     updateMRL();
398 }
399
400 void NetOpenPanel::updateAddress() {
401     updateMRL();
402 }
403
404 void NetOpenPanel::updateMRL() {
405     QString mrl = "";
406     QString addr = ui.addressText->text();
407     int proto = ui.protocolCombo->currentIndex();
408
409     if( addr.contains( "://") && proto != 4 ) {
410         mrl = addr;
411     } else {
412         switch( proto ) {
413         case 0:
414         case 1:
415             mrl = "http://" + addr;
416             emit methodChanged("http-caching");
417             break;
418         case 3:
419             mrl = "mms://" + addr;
420             emit methodChanged("mms-caching");
421             break;
422         case 2:
423             mrl = "ftp://" + addr;
424             emit methodChanged("ftp-caching");
425             break;
426         case 4: /* RTSP */
427             mrl = "rtsp://" + addr;
428             emit methodChanged("rtsp-caching");
429             break;
430         case 5:
431             mrl = "udp://@";
432             if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
433                 mrl += "[::]";
434             }
435             mrl += QString(":%1").arg( ui.portSpin->value() );
436             emit methodChanged("udp-caching");
437             break;
438         case 6: /* UDP multicast */
439             mrl = "udp://@";
440             /* Add [] to IPv6 */
441             if ( addr.contains(':') && !addr.contains('[') ) {
442                 mrl += "[" + addr + "]";
443             } else mrl += addr;
444             mrl += QString(":%1").arg( ui.portSpin->value() );
445             emit methodChanged("udp-caching");
446         }
447     }
448     if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
449         mrl += " :access-filter=timeshift";
450     }
451     emit mrlUpdated( mrl );
452 }
453
454 /**************************************************************************
455  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
456  **************************************************************************/
457 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
458                                 OpenPanel( _parent, _p_intf )
459 {
460     ui.setupUi( this );
461
462     /* Create two stacked layouts in the main comboBoxes */
463     QStackedLayout *stackedDevLayout = new QStackedLayout;
464     ui.cardBox->setLayout( stackedDevLayout );
465
466     QStackedLayout *stackedPropLayout = new QStackedLayout;
467     ui.optionsBox->setLayout( stackedPropLayout );
468
469     /* Creation and connections of the WIdgets in the stacked layout */
470 #define addModuleAndLayouts( number, name, label )                    \
471     QWidget * name ## DevPage = new QWidget( this );                  \
472     QWidget * name ## PropPage = new QWidget( this );                 \
473     stackedDevLayout->addWidget( name ## DevPage );        \
474     stackedPropLayout->addWidget( name ## PropPage );      \
475     QGridLayout * name ## DevLayout = new QGridLayout;                \
476     QGridLayout * name ## PropLayout = new QGridLayout;               \
477     name ## DevPage->setLayout( name ## DevLayout );                  \
478     name ## PropPage->setLayout( name ## PropLayout );                \
479     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
480
481 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
482
483 #define setMaxBound( spinbox ) spinbox->setRange ( 0, INT_MAX );
484
485     /*******
486      * V4L *
487      *******/
488     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
489
490     /* V4l Main panel */
491     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
492     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
493
494     v4lVideoDevice = new QLineEdit;
495     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
496
497     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
498     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
499
500     v4lAudioDevice = new QLineEdit;
501     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
502
503     /* V4l Props panel */
504     v4lNormBox = new QComboBox;
505     setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
506     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
507
508     v4lFreq = new QSpinBox;
509     v4lFreq->setAlignment( Qt::AlignRight );
510     v4lFreq->setSuffix(" kHz");
511     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
512
513     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
514     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
515
516     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
517     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
518
519     /* v4l CONNECTs */
520     CuMRL( v4lVideoDevice, textChanged( QString ) );
521     CuMRL( v4lAudioDevice, textChanged( QString ) );
522     CuMRL( v4lFreq, valueChanged ( int ) );
523     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
524
525     /************
526      * PVR      *
527      ************/
528     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
529
530     /* PVR Main panel */
531     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
532     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
533
534     pvrDevice = new QLineEdit;
535     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
536
537     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
538     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
539
540     pvrRadioDevice = new QLineEdit;
541     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
542
543     /* PVR props panel */
544     pvrNormBox = new QComboBox;
545     setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
546     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
547
548     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
549     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
550
551     pvrFreq = new QSpinBox;
552     pvrFreq->setAlignment( Qt::AlignRight );
553     pvrFreq->setSuffix(" kHz");
554     setMaxBound( pvrFreq );
555     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
556
557     pvrBitr = new QSpinBox;
558     pvrBitr->setAlignment( Qt::AlignRight );
559     pvrBitr->setSuffix(" kHz");
560     setMaxBound( pvrBitr );
561     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
562
563     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
564     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
565
566     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
567     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
568
569     /* PVR CONNECTs */
570     CuMRL( pvrDevice, textChanged( QString ) );
571     CuMRL( pvrRadioDevice, textChanged( QString ) );
572
573     CuMRL( pvrFreq, valueChanged ( int ) );
574     CuMRL( pvrBitr, valueChanged ( int ) );
575     CuMRL( pvrNormBox,  currentIndexChanged ( int ) );
576
577     /*********************
578      * DirectShow Stuffs *
579      *********************/
580     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
581
582     /**************
583      * BDA Stuffs *
584      **************/
585     addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
586
587     /* bda Main */
588     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
589
590     bdas = new QRadioButton( "DVB-S" );
591     bdas->setChecked( true );
592     bdac = new QRadioButton( "DVB-C" );
593     bdat = new QRadioButton( "DVB-T" );
594
595     bdaDevLayout->addWidget( bdaTypeLabel, 1, 0 );
596     bdaDevLayout->addWidget( bdas, 1, 1 );
597     bdaDevLayout->addWidget( bdac, 1, 2 );
598     bdaDevLayout->addWidget( bdat, 1, 3 );
599
600     /* bda Props */
601     QLabel *bdaFreqLabel =
602                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
603     bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
604
605     bdaFreq = new QSpinBox;
606     bdaFreq->setAlignment( Qt::AlignRight );
607     bdaFreq->setSuffix(" kHz");
608     bdaFreq->setSingleStep( 1000 );
609     setMaxBound( bdaFreq )
610     bdaPropLayout->addWidget( bdaFreq, 0, 1 );
611
612     bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
613     bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
614
615     bdaSrate = new QSpinBox;
616     bdaSrate->setAlignment( Qt::AlignRight );
617     bdaSrate->setSuffix(" kHz");
618     setMaxBound( bdaSrate );
619     bdaPropLayout->addWidget( bdaSrate, 1, 1 );
620
621     bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
622     bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
623
624     bdaBandBox = new QComboBox;
625     setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
626     bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
627
628     bdaBandLabel->hide();
629     bdaBandBox->hide();
630
631     /* bda CONNECTs */
632     CuMRL( bdaFreq, valueChanged ( int ) );
633     CuMRL( bdaSrate, valueChanged ( int ) );
634     CuMRL( bdaBandBox,  currentIndexChanged ( int ) );
635     BUTTONACT( bdas, updateButtons() );
636     BUTTONACT( bdat, updateButtons() );
637     BUTTONACT( bdac, updateButtons() );
638     BUTTONACT( bdas, updateMRL() );
639     BUTTONACT( bdat, updateMRL() );
640     BUTTONACT( bdac, updateMRL() );
641
642     /**************
643      * DVB Stuffs *
644      **************/
645     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
646
647     /* DVB Main */
648     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
649     QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
650
651     dvbCard = new QSpinBox;
652     dvbCard->setAlignment( Qt::AlignRight );
653     dvbCard->setPrefix( "/dev/dvb/adapter" );
654
655     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
656     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
657
658     dvbs = new QRadioButton( "DVB-S" );
659     dvbs->setChecked( true );
660     dvbc = new QRadioButton( "DVB-C" );
661     dvbt = new QRadioButton( "DVB-T" );
662
663     dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
664     dvbDevLayout->addWidget( dvbs, 1, 1 );
665     dvbDevLayout->addWidget( dvbc, 1, 2 );
666     dvbDevLayout->addWidget( dvbt, 1, 3 );
667
668     /* DVB Props panel */
669     QLabel *dvbFreqLabel =
670                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
671     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
672
673     dvbFreq = new QSpinBox;
674     dvbFreq->setAlignment( Qt::AlignRight );
675     dvbFreq->setSuffix(" kHz");
676     setMaxBound( dvbFreq  );
677     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
678
679     QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
680     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
681
682     dvbSrate = new QSpinBox;
683     dvbSrate->setAlignment( Qt::AlignRight );
684     dvbSrate->setSuffix(" kHz");
685     setMaxBound( dvbSrate );
686     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
687
688     /* DVB CONNECTs */
689     CuMRL( dvbCard, valueChanged ( int ) );
690     CuMRL( dvbFreq, valueChanged ( int ) );
691     CuMRL( dvbSrate, valueChanged ( int ) );
692
693     BUTTONACT( dvbs, updateButtons() );
694     BUTTONACT( dvbt, updateButtons() );
695     BUTTONACT( dvbc, updateButtons() );
696
697     /* General connects */
698     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
699                      stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
700     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
701                      stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
702     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
703
704 #undef addModule
705 }
706
707 CaptureOpenPanel::~CaptureOpenPanel()
708 {}
709
710 void CaptureOpenPanel::clear()
711 {}
712
713 void CaptureOpenPanel::updateMRL()
714 {
715     QString mrl = "";
716     int i_devicetype = ui.deviceCombo->itemData(
717             ui.deviceCombo->currentIndex() ).toInt();
718     msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
719     switch( i_devicetype )
720     {
721     case V4L_DEVICE:
722         mrl = "v4l://";
723         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
724         mrl += " :v4l-adev=" + v4lAudioDevice->text();
725         mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
726         mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
727         break;
728     case PVR_DEVICE:
729         mrl = "pvr://";
730         mrl += " :pvr-device=" + pvrDevice->text();
731         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
732         mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
733         if( pvrFreq->value() )
734             mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
735         if( pvrBitr->value() )
736             mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
737         break;
738     case DVB_DEVICE:
739         mrl = "dvb://";
740         mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
741         mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
742         mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
743         break;
744     case BDA_DEVICE:
745         if( bdas->isChecked() ) mrl = "dvb-s://";
746         else if(  bdat->isChecked() ) mrl = "dvb-t://";
747         else if(  bdac->isChecked() ) mrl = "dvb-c://";
748         else return;
749         mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
750         if( bdas->isChecked() || bdac->isChecked() )
751             mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
752         else
753             mrl += " :dvb-bandwidth=" +
754                 QString("%1").arg( bdaBandBox->itemData(
755                     bdaBandBox->currentIndex() ).toInt() );
756         break;
757   case DSHOW_DEVICE:
758         break;
759     }
760     emit mrlUpdated( mrl );
761 }
762
763 void CaptureOpenPanel::updateButtons()
764 {
765     int i_devicetype = ui.deviceCombo->itemData(
766             ui.deviceCombo->currentIndex() ).toInt();
767     msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
768     switch( i_devicetype )
769     {
770     case DVB_DEVICE:
771         if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
772         if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
773         break;
774     case BDA_DEVICE:
775         if( bdas->isChecked() || bdac->isChecked() )
776         {
777             bdaSrate->show();
778             bdaSrateLabel->show();
779             bdaBandBox->hide();
780             bdaBandLabel->hide();
781         }
782         else
783         {
784             bdaSrate->hide();
785             bdaSrateLabel->hide();
786             bdaBandBox->show();
787             bdaBandLabel->show();
788         }
789         break;
790     }
791 }