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