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