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