]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/open.cpp
Qt4 - Open Dialog: Continue Capture tab, and implement the MRL updates. Slots and...
[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 /**************************************************************************
38  * File open
39  **************************************************************************/
40 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
41                                 OpenPanel( _parent, _p_intf )
42 {
43     /* Classic UI Setup */
44     ui.setupUi( this );
45
46     /* Use a QFileDialog and customize it because we don't want to
47        rewrite it all. Be careful to your eyes cause there are a few hacks.
48        Be very careful and test correctly when you modify this. */
49
50     /* Set Filters for file selection */
51     QString fileTypes = "";
52     ADD_FILTER_MEDIA( fileTypes );
53     ADD_FILTER_VIDEO( fileTypes );
54     ADD_FILTER_AUDIO( fileTypes );
55     ADD_FILTER_PLAYLIST( fileTypes );
56     ADD_FILTER_ALL( fileTypes );
57     fileTypes.replace( QString(";*"), QString(" *"));
58
59     // Make this QFileDialog a child of tempWidget from the ui.
60     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
61             qfu( p_intf->p_libvlc->psz_homedir ), fileTypes );
62 /*    dialogBox->setFileMode( QFileDialog::ExistingFiles );*/
63     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
64
65     /* retrieve last known path used in file browsing */
66     char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
67     if( psz_filepath )
68     {
69         dialogBox->setDirectory( QString::fromUtf8( psz_filepath ) );
70         delete psz_filepath;
71     }
72
73     /* We don't want to see a grip in the middle of the window, do we? */
74     dialogBox->setSizeGripEnabled( false );
75     dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ));
76
77     // Add it to the layout
78     ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
79
80     // But hide the two OK/Cancel buttons. Enable them for debug.
81     QDialogButtonBox *fileDialogAcceptBox =
82                         findChildren<QDialogButtonBox*>()[0];
83     fileDialogAcceptBox->hide();
84
85     /* Ugly hacks to get the good Widget */
86     //This lineEdit is the normal line in the fileDialog.
87     lineFileEdit = findChildren<QLineEdit*>()[3];
88     lineFileEdit->hide();
89
90     /* Make a list of QLabel inside the QFileDialog to access the good ones */
91     QList<QLabel *> listLabel = findChildren<QLabel*>();
92
93     /* Hide the FileNames one. Enable it for debug */
94     listLabel[4]->hide();
95     /* Change the text that was uncool in the usual box */
96     listLabel[5]->setText( qtr( "Filter:" ) );
97
98     // Hide the subtitles control by default.
99     ui.subFrame->hide();
100
101     /* Build the subs size combo box */
102     module_config_t *p_item =
103         config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
104     if( p_item )
105     {
106         for( int i_index = 0; i_index < p_item->i_list; i_index++ )
107         {
108             ui.sizeSubComboBox->addItem(
109                 qfu( p_item->ppsz_list_text[i_index] ),
110                 QVariant( p_item->pi_list[i_index] ) );
111             if( p_item->value.i == p_item->pi_list[i_index] )
112             {
113                 ui.sizeSubComboBox->setCurrentIndex( i_index );
114             }
115         }
116     }
117
118     /* Build the subs align combo box */
119     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
120     if( p_item )
121     {
122         for( int i_index = 0; i_index < p_item->i_list; i_index++ )
123         {
124             ui.alignSubComboBox->addItem(
125                 qfu( p_item->ppsz_list_text[i_index] ),
126                 QVariant( p_item->pi_list[i_index] ) );
127             if( p_item->value.i == p_item->pi_list[i_index] )
128             {
129                 ui.alignSubComboBox->setCurrentIndex( i_index );
130             }
131         }
132     }
133
134     /* Connects  */
135     BUTTONACT( ui.subBrowseButton, browseFileSub() );
136     BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
137
138     CONNECT( ui.fileInput, editTextChanged( QString ), this, updateMRL());
139     CONNECT( ui.subInput, editTextChanged( QString ), this, updateMRL());
140     CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL());
141     CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL());
142     CONNECT( lineFileEdit, textChanged( QString ), this, browseFile());
143 }
144
145 FileOpenPanel::~FileOpenPanel()
146 {}
147
148 QStringList FileOpenPanel::browse( QString help )
149 {
150     return THEDP->showSimpleOpen( help );
151 }
152
153 /* Unused. FIXME ? */
154 void FileOpenPanel::browseFile()
155 {
156     QString fileString = "";
157     foreach( QString file, dialogBox->selectedFiles() ) {
158          fileString += "\"" + file + "\" ";
159     }
160     ui.fileInput->setEditText( fileString );
161     updateMRL();
162 }
163
164 void FileOpenPanel::browseFileSub()
165 {
166     // FIXME Handle selection of more than one subtitles file
167     QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
168                             EXT_FILTER_SUBTITLE,
169                             dialogBox->directory().absolutePath() );
170     if( files.isEmpty() ) return;
171     ui.subInput->setEditText( files.join(" ") );
172     updateMRL();
173 }
174
175 void FileOpenPanel::updateMRL()
176 {
177     QString mrl = ui.fileInput->currentText();
178
179     if( ui.subCheckBox->isChecked() ) {
180         mrl.append( " :sub-file=" + ui.subInput->currentText() );
181         int align = ui.alignSubComboBox->itemData(
182                     ui.alignSubComboBox->currentIndex() ).toInt();
183         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
184         int size = ui.sizeSubComboBox->itemData(
185                    ui.sizeSubComboBox->currentIndex() ).toInt();
186         mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
187     }
188
189     const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
190     if( ( NULL == psz_filepath )
191       || strcmp( psz_filepath,dialogBox->directory().absolutePath().toUtf8()) )
192     {
193         /* set dialog box current directory as last known path */
194         config_PutPsz( p_intf, "qt-filedialog-path",
195                        dialogBox->directory().absolutePath().toUtf8() );
196     }
197     delete psz_filepath;
198
199     emit mrlUpdated( mrl );
200     emit methodChanged( "file-caching" );
201 }
202
203
204 /* Function called by Open Dialog when clicke on Play/Enqueue */
205 void FileOpenPanel::accept()
206 {
207     ui.fileInput->addItem( ui.fileInput->currentText());
208     if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem( 0 );
209 }
210
211 void FileOpenBox::accept()
212 {
213     OpenDialog::getInstance( NULL, NULL )->play();
214 }
215
216 /* Function called by Open Dialog when clicked on cancel */
217 void FileOpenPanel::clear()
218 {
219     ui.fileInput->setEditText( "" );
220     ui.subInput->setEditText( "" );
221 }
222
223 void FileOpenPanel::toggleSubtitleFrame()
224 {
225     if ( ui.subFrame->isVisible() )
226     {
227         ui.subFrame->hide();
228         updateGeometry();
229     /* FiXME Size */
230     }
231     else
232     {
233         ui.subFrame->show();
234     }
235
236     /* Update the MRL */
237     updateMRL();
238 }
239
240 /**************************************************************************
241  * Disk open
242  **************************************************************************/
243 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
244                                 OpenPanel( _parent, _p_intf )
245 {
246     ui.setupUi( this );
247
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     /* 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
345     emit mrlUpdated( mrl );
346 }
347
348
349
350 /**************************************************************************
351  * Net open
352  **************************************************************************/
353 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
354                                 OpenPanel( _parent, _p_intf )
355 {
356     ui.setupUi( this );
357
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
396     updateMRL();
397 }
398
399 void NetOpenPanel::updateAddress() {
400     updateMRL();
401 }
402
403 void NetOpenPanel::updateMRL() {
404     QString mrl = "";
405     QString addr = ui.addressText->text();
406     int proto = ui.protocolCombo->currentIndex();
407
408     if( addr.contains( "://") && proto != 4 ) {
409         mrl = addr;
410     } else {
411         switch( proto ) {
412         case 0:
413         case 1:
414             mrl = "http://" + addr;
415             emit methodChanged("http-caching");
416             break;
417         case 3:
418             mrl = "mms://" + addr;
419             emit methodChanged("mms-caching");
420             break;
421         case 2:
422             mrl = "ftp://" + addr;
423             emit methodChanged("ftp-caching");
424             break;
425         case 4: /* RTSP */
426             mrl = "rtsp://" + addr;
427             emit methodChanged("rtsp-caching");
428             break;
429         case 5:
430             mrl = "udp://@";
431             if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
432                 mrl += "[::]";
433             }
434             mrl += QString(":%1").arg( ui.portSpin->value() );
435             emit methodChanged("udp-caching");
436             break;
437         case 6: /* UDP multicast */
438             mrl = "udp://@";
439             /* Add [] to IPv6 */
440             if ( addr.contains(':') && !addr.contains('[') ) {
441                 mrl += "[" + addr + "]";
442             } else mrl += addr;
443             mrl += QString(":%1").arg( ui.portSpin->value() );
444             emit methodChanged("udp-caching");
445         }
446     }
447     if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
448         mrl += " :access-filter=timeshift";
449     }
450     emit mrlUpdated( mrl );
451 }
452
453 /**************************************************************************
454  * Capture open
455  **************************************************************************/
456 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
457                                 OpenPanel( _parent, _p_intf )
458 {
459     ui.setupUi( this );
460
461     QStackedLayout *stackedDevLayout = new QStackedLayout;
462     ui.cardBox->setLayout( stackedDevLayout );
463
464     QStackedLayout *stackedPropLayout = new QStackedLayout;
465     ui.optionsBox->setLayout( stackedPropLayout );
466
467 #define addModuleAndLayouts( number, name, label )                    \
468     QWidget * name ## DevPage = new QWidget( this );                  \
469     QWidget * name ## PropPage = new QWidget( this );                 \
470     stackedDevLayout->insertWidget( number, name ## DevPage );        \
471     stackedPropLayout->insertWidget( number, name ## PropPage );      \
472     QGridLayout * name ## DevLayout = new QGridLayout;                \
473     QGridLayout * name ## PropLayout = new QGridLayout;               \
474     name ## DevPage->setLayout( name ## DevLayout );                  \
475     name ## PropPage->setLayout( name ## PropLayout );                \
476     ui.deviceCombo->insertItem( number, qtr( label ) );
477
478 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
479
480     /*******
481      * V4L *
482      *******/
483     /* V4l Main */
484     addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
485     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
486     v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
487     v4lVideoDevice = new QLineEdit;
488     v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
489     QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
490     v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
491     v4lAudioDevice = new QLineEdit;
492     v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
493
494     /* V4l Props */
495     v4lNormBox = new QComboBox;
496     v4lNormBox->insertItem( 3, qtr( "Automatic" ) );
497     v4lNormBox->insertItem( 0, "SECAM" );
498     v4lNormBox->insertItem( 1, "NTSC" );
499     v4lNormBox->insertItem( 2, "PAL" );
500
501     v4lFreq = new QSpinBox;
502     v4lFreq->setAlignment( Qt::AlignRight );
503     v4lFreq->setSuffix(" kHz");
504
505     QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
506     QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
507
508     v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
509     v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
510
511     v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
512     v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
513
514     /* v4l CONNECTs */
515     CuMRL( v4lVideoDevice, textChanged( QString ) );
516     CuMRL( v4lAudioDevice, textChanged( QString ) );
517     CuMRL( v4lFreq, valueChanged ( int ) );
518     CuMRL( v4lNormBox,  currentIndexChanged ( int ) );
519
520     /************
521      * PVR      *
522      ************/
523     addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
524
525     /* PVR Main */
526     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
527     pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
528     pvrDevice = new QLineEdit;
529     pvrDevLayout->addWidget( pvrDevice, 0, 1 );
530     QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
531     pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
532     pvrRadioDevice = new QLineEdit;
533     pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
534
535     /* PVR props */
536     pvrNormBox = new QComboBox;
537     pvrNormBox->insertItem( 3, qtr( "Automatic" ) );
538     pvrNormBox->insertItem( 0, "SECAM" );
539     pvrNormBox->insertItem( 1, "NTSC" );
540     pvrNormBox->insertItem( 2, "PAL" );
541
542     pvrFreq = new QSpinBox;
543     pvrFreq->setAlignment( Qt::AlignRight );
544     pvrFreq->setSuffix(" kHz");
545     pvrBitr = new QSpinBox;
546     pvrBitr->setAlignment( Qt::AlignRight );
547     pvrBitr->setSuffix(" kHz");
548     QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
549     QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
550     QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
551
552     pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
553     pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
554
555     pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
556     pvrPropLayout->addWidget( pvrFreq, 1, 1 );
557
558     pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
559     pvrPropLayout->addWidget( pvrBitr, 2, 1 );
560
561     /* PVR CONNECTs */
562     CuMRL( pvrDevice, textChanged( QString ) );
563     CuMRL( pvrRadioDevice, textChanged( QString ) );
564
565     CuMRL( pvrFreq, valueChanged ( int ) );
566     CuMRL( pvrBitr, valueChanged ( int ) );
567     CuMRL( pvrNormBox,  currentIndexChanged ( int ) );
568
569     /*********************
570      * DirectShow Stuffs *
571      *********************/
572     addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
573
574
575     /**************
576      * BDA Stuffs *
577      **************/
578     addModuleAndLayouts( BDA_DEVICE, bda, "DVB / BDA" );
579
580     /**************
581      * DVB Stuffs *
582      **************/
583     addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
584
585     /* DVB Main */
586     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
587     QLabel *dvbTyepLabel = new QLabel( qtr( "DVB Type:" ) );
588
589     dvbCard = new QSpinBox;
590     dvbCard->setAlignment( Qt::AlignRight );
591     dvbCard->setPrefix( "/dev/dvb/adapter" );
592
593     dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
594     dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
595
596     dvbs = new QRadioButton( "DVB-S" );
597     dvbs->setChecked( true );
598     dvbc = new QRadioButton( "DVB-C" );
599     dvbt = new QRadioButton( "DVB-T" );
600
601     dvbDevLayout->addWidget( dvbTyepLabel, 1, 0 );
602     dvbDevLayout->addWidget( dvbs, 1, 1 );
603     dvbDevLayout->addWidget( dvbc, 1, 2 );
604     dvbDevLayout->addWidget( dvbt, 1, 3 );
605
606     /* DVB Props */
607     QLabel *dvbFreqLabel =
608                     new QLabel( qtr( "Transponder/multiplex frequency" ) );
609     dvbFreq = new QSpinBox;
610     dvbFreq->setAlignment( Qt::AlignRight );
611     dvbFreq->setSuffix(" kHz");
612     dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
613     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
614
615     QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
616     dvbSrate = new QSpinBox;
617     dvbSrate->setAlignment( Qt::AlignRight );
618     dvbSrate->setSuffix(" kHz");
619     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
620     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
621
622     /* DVB CONNECTs */
623     CuMRL( dvbCard, valueChanged ( int ) );
624     CuMRL( dvbFreq, valueChanged ( int ) );
625     CuMRL( dvbSrate, valueChanged ( int ) );
626     BUTTONACT( dvbs, updateButtons() );
627     BUTTONACT( dvbt, updateButtons() );
628     BUTTONACT( dvbc, updateButtons() );
629
630     /* General connects */
631     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
632                      stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
633     connect( ui.deviceCombo, SIGNAL( activated( int ) ),
634                      stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
635     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
636
637 #undef addModule
638 }
639
640 CaptureOpenPanel::~CaptureOpenPanel()
641 {}
642
643 void CaptureOpenPanel::clear()
644 {}
645
646 void CaptureOpenPanel::updateMRL()
647 {
648     QString mrl = "";
649     int i_devicetype = ui.deviceCombo->currentIndex();
650     switch( i_devicetype )
651     {
652     case V4L_DEVICE:
653         mrl = "v4l://";
654         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
655         mrl += " :v4l-adev=" + v4lAudioDevice->text();
656         mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
657         mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
658         break;
659     case PVR_DEVICE:
660         mrl = "pvr://";
661         mrl += " :pvr-device=" + pvrDevice->text();
662         mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
663         mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
664         if( pvrFreq->value() )
665             mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
666         if( pvrBitr->value() )
667             mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
668         break;
669     case DVB_DEVICE:
670         mrl = "dvb://";
671         mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
672         mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
673         mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
674         break;
675     case BDA_DEVICE:
676         break;
677     case DSHOW_DEVICE:
678         break;
679     }
680
681     emit mrlUpdated( mrl );
682 }
683
684 void CaptureOpenPanel::updateButtons()
685 {
686     if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
687     if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
688 }