1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
5 * Copyright (C) 2007 Société des arts technologiques
6 * Copyright (C) 2007 Savoir-faire Linux
10 * Authors: Clément Stenac <zorglub@videolan.org>
11 * Jean-Baptiste Kempf <jb@videolan.org>
12 * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 *****************************************************************************/
31 #include "components/open_panels.hpp"
32 #include "dialogs/open.hpp"
33 #include "dialogs_provider.hpp"
35 #include <QFileDialog>
36 #include <QDialogButtonBox>
38 #include <QStackedLayout>
43 /**************************************************************************
44 * Open Files and subtitles *
45 **************************************************************************/
46 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
47 OpenPanel( _parent, _p_intf )
49 /* Classic UI Setup */
52 /** BEGIN QFileDialog tweaking **/
53 /* Use a QFileDialog and customize it because we don't want to
54 rewrite it all. Be careful to your eyes cause there are a few hacks.
55 Be very careful and test correctly when you modify this. */
57 /* Set Filters for file selection */
58 QString fileTypes = "";
59 ADD_FILTER_MEDIA( fileTypes );
60 ADD_FILTER_VIDEO( fileTypes );
61 ADD_FILTER_AUDIO( fileTypes );
62 ADD_FILTER_PLAYLIST( fileTypes );
63 ADD_FILTER_ALL( fileTypes );
64 fileTypes.replace( QString(";*"), QString(" *"));
66 /* retrieve last known path used in file browsing */
67 char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
68 if( EMPTY_STR( psz_filepath ) )
70 psz_filepath = p_intf->p_libvlc->psz_homedir;
73 // Make this QFileDialog a child of tempWidget from the ui.
74 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
75 qfu( psz_filepath ), fileTypes );
78 dialogBox->setFileMode( QFileDialog::ExistingFiles );
79 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
81 /* We don't want to see a grip in the middle of the window, do we? */
82 dialogBox->setSizeGripEnabled( false );
85 dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
87 // But hide the two OK/Cancel buttons. Enable them for debug.
88 QDialogButtonBox *fileDialogAcceptBox =
89 dialogBox->findChildren<QDialogButtonBox*>()[0];
90 fileDialogAcceptBox->hide();
92 /* Ugly hacks to get the good Widget */
93 //This lineEdit is the normal line in the fileDialog.
95 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
97 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
99 /* Make a list of QLabel inside the QFileDialog to access the good ones */
100 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
102 /* Hide the FileNames one. Enable it for debug */
103 listLabel[1]->setText( qtr( "File names:" ) );
104 /* Change the text that was uncool in the usual box */
105 listLabel[2]->setText( qtr( "Filter:" ) );
107 dialogBox->layout()->setMargin( 0 );
108 dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
110 /** END of QFileDialog tweaking **/
112 // Add the DialogBox to the layout
113 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
115 //TODO later: fill the fileCompleteList with previous items played.
116 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
117 fileCompleter->setModel( new QDirModel( fileCompleter ) );
118 lineFileEdit->setCompleter( fileCompleter );
120 // Hide the subtitles control by default.
123 /* Build the subs size combo box */
124 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
125 ui.sizeSubComboBox );
127 /* Build the subs align combo box */
128 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
131 BUTTONACT( ui.subBrowseButton, browseFileSub() );
132 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
134 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
135 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
136 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
137 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
140 FileOpenPanel::~FileOpenPanel(){}
142 /* Show a fileBrowser to select a subtitle */
143 void FileOpenPanel::browseFileSub()
145 // TODO Handle selection of more than one subtitles file
146 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
148 dialogBox->directory().absolutePath() );
149 if( files.isEmpty() ) return;
150 ui.subInput->setText( files.join(" ") );
154 /* Update the current MRL */
155 void FileOpenPanel::updateMRL()
158 foreach( QString file, dialogBox->selectedFiles() ) {
159 mrl += "\"" + file + "\" ";
162 if( ui.subCheckBox->isChecked() ) {
163 mrl.append( " :sub-file=" + ui.subInput->text() );
164 int align = ui.alignSubComboBox->itemData(
165 ui.alignSubComboBox->currentIndex() ).toInt();
166 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
167 int size = ui.sizeSubComboBox->itemData(
168 ui.sizeSubComboBox->currentIndex() ).toInt();
169 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
172 emit mrlUpdated( mrl );
173 emit methodChanged( "file-caching" );
176 /* Function called by Open Dialog when clicke on Play/Enqueue */
177 void FileOpenPanel::accept()
179 //TODO set the completer
180 const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
181 if( ( NULL == psz_filepath )
182 || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
184 /* set dialog box current directory as last known path */
185 config_PutPsz( p_intf, "qt-filedialog-path",
186 qtu( dialogBox->directory().absolutePath() ) );
191 void FileOpenBox::accept()
193 OpenDialog::getInstance( NULL, NULL )->play();
196 /* Function called by Open Dialog when clicked on cancel */
197 void FileOpenPanel::clear()
199 lineFileEdit->clear();
200 ui.subInput->clear();
203 void FileOpenPanel::toggleSubtitleFrame()
205 TOGGLEV( ui.subFrame );
211 /**************************************************************************
212 * Open Discs ( DVD, CD, VCD and similar devices ) *
213 **************************************************************************/
214 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
215 OpenPanel( _parent, _p_intf )
219 /* Get the default configuration path for the devices */
220 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
221 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
222 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
224 /* State to avoid overwritting the users changes with the configuration */
229 #if WIN32 /* Disc drives probing for Windows */
232 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
234 char *drive = szDrives;
235 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
238 if( GetDriveTypeA(drive) == DRIVE_CDROM )
239 ui.deviceCombo->addItem( drive );
241 /* go to next drive */
244 SetErrorMode(oldMode);
246 #else /* Use a Completer under Linux */
247 QCompleter *discCompleter = new QCompleter( this );
248 discCompleter->setModel( new QDirModel( discCompleter ) );
249 ui.deviceCombo->setCompleter( discCompleter );
253 BUTTONACT( ui.dvdRadioButton, updateButtons() );
254 BUTTONACT( ui.vcdRadioButton, updateButtons() );
255 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
256 BUTTONACT( ui.dvdsimple, updateButtons() );
257 BUTTONACT( ui.browseDiscButton, browseDevice() );
259 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
260 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
261 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
262 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
263 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
265 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
269 DiscOpenPanel::~DiscOpenPanel()
271 delete psz_dvddiscpath;
272 delete psz_vcddiscpath;
273 delete psz_cddadiscpath;
276 void DiscOpenPanel::clear()
278 ui.titleSpin->setValue( 0 );
279 ui.chapterSpin->setValue( 0 );
286 #define setDrive( psz_name ) {\
287 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
288 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
290 #define setDrive( psz_name ) {\
291 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
294 /* update the buttons according the type of device */
295 void DiscOpenPanel::updateButtons()
297 if ( ui.dvdRadioButton->isChecked() )
301 setDrive( psz_dvddiscpath );
304 ui.titleLabel->setText( qtr("Title") );
305 ui.chapterLabel->show();
306 ui.chapterSpin->show();
307 ui.diskOptionBox_2->show();
309 else if ( ui.vcdRadioButton->isChecked() )
313 setDrive( psz_vcddiscpath );
316 ui.titleLabel->setText( qtr("Entry") );
317 ui.chapterLabel->hide();
318 ui.chapterSpin->hide();
319 ui.diskOptionBox_2->show();
325 setDrive( psz_cddadiscpath );
328 ui.titleLabel->setText( qtr("Track") );
329 ui.chapterLabel->hide();
330 ui.chapterSpin->hide();
331 ui.diskOptionBox_2->hide();
337 /* Update the current MRL */
338 void DiscOpenPanel::updateMRL()
342 /* CDDAX and VCDX not implemented. TODO ? */
344 if( ui.dvdRadioButton->isChecked() ) {
345 if( !ui.dvdsimple->isChecked() )
348 mrl = "dvdsimple://";
349 mrl += ui.deviceCombo->currentText();
350 emit methodChanged( "dvdnav-caching" );
352 if ( ui.titleSpin->value() > 0 ) {
353 mrl += QString("@%1").arg( ui.titleSpin->value() );
354 if ( ui.chapterSpin->value() > 0 ) {
355 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
360 } else if ( ui.vcdRadioButton->isChecked() ) {
361 mrl = "vcd://" + ui.deviceCombo->currentText();
362 emit methodChanged( "vcd-caching" );
364 if( ui.titleSpin->value() > 0 ) {
365 mrl += QString("@E%1").arg( ui.titleSpin->value() );
370 mrl = "cdda://" + ui.deviceCombo->currentText();
371 if( ui.titleSpin->value() > 0 ) {
372 QString("@%1").arg( ui.titleSpin->value() );
376 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
378 if ( ui.audioSpin->value() >= 0 ) {
379 mrl += " :audio-track=" +
380 QString("%1").arg( ui.audioSpin->value() );
382 if ( ui.subtitlesSpin->value() >= 0 ) {
383 mrl += " :sub-track=" +
384 QString("%1").arg( ui.subtitlesSpin->value() );
387 emit mrlUpdated( mrl );
390 void DiscOpenPanel::browseDevice()
392 QString dir = QFileDialog::getExistingDirectory( 0,
393 qtr("Open a device or a VIDEO_TS directory") );
394 if (!dir.isEmpty()) {
395 ui.deviceCombo->setEditText( dir );
400 void DiscOpenPanel::accept()
403 /**************************************************************************
404 * Open Network streams and URL pages *
405 **************************************************************************/
406 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
407 OpenPanel( _parent, _p_intf )
412 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
413 this, updateProtocol( int ) );
414 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
415 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
416 CONNECT( ui.timeShift, clicked(), this, updateMRL());
417 CONNECT( ui.ipv6, clicked(), this, updateMRL());
419 ui.protocolCombo->addItem("HTTP", QVariant("http"));
420 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
421 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
422 ui.protocolCombo->addItem("MMS", QVariant("mms"));
423 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
424 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
425 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
428 NetOpenPanel::~NetOpenPanel()
431 void NetOpenPanel::clear()
434 /* update the widgets according the type of protocol */
435 void NetOpenPanel::updateProtocol( int idx ) {
436 QString addr = ui.addressText->text();
437 QString proto = ui.protocolCombo->itemData( idx ).toString();
439 ui.timeShift->setEnabled( idx >= 5 );
440 ui.ipv6->setEnabled( idx == 5 );
441 ui.addressText->setEnabled( idx != 5 );
442 ui.portSpin->setEnabled( idx >= 5 );
444 /* If we already have a protocol in the address, replace it */
445 if( addr.contains( "://")) {
446 msg_Err( p_intf, "replace");
447 addr.replace( QRegExp("^.*://"), proto + "://");
448 ui.addressText->setText( addr );
453 void NetOpenPanel::updateMRL() {
455 QString addr = ui.addressText->text();
456 int proto = ui.protocolCombo->currentIndex();
458 if( addr.contains( "://") && proto != 5 ) {
463 mrl = "http://" + addr;
464 emit methodChanged("http-caching");
467 mrl = "https://" + addr;
468 emit methodChanged("http-caching");
471 mrl = "mms://" + addr;
472 emit methodChanged("mms-caching");
475 mrl = "ftp://" + addr;
476 emit methodChanged("ftp-caching");
479 mrl = "rtsp://" + addr;
480 emit methodChanged("rtsp-caching");
484 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
487 mrl += QString(":%1").arg( ui.portSpin->value() );
488 emit methodChanged("udp-caching");
490 case 6: /* UDP multicast */
493 if ( addr.contains(':') && !addr.contains('[') ) {
494 mrl += "[" + addr + "]";
496 mrl += QString(":%1").arg( ui.portSpin->value() );
497 emit methodChanged("udp-caching");
500 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
501 mrl += " :access-filter=timeshift";
503 emit mrlUpdated( mrl );
506 /**************************************************************************
507 * Open Capture device ( DVB, PVR, V4L, and similar ) *
508 **************************************************************************/
509 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
510 OpenPanel( _parent, _p_intf )
514 /* Create two stacked layouts in the main comboBoxes */
515 QStackedLayout *stackedDevLayout = new QStackedLayout;
516 ui.cardBox->setLayout( stackedDevLayout );
518 QStackedLayout *stackedPropLayout = new QStackedLayout;
519 ui.optionsBox->setLayout( stackedPropLayout );
521 /* Creation and connections of the WIdgets in the stacked layout */
522 #define addModuleAndLayouts( number, name, label ) \
523 QWidget * name ## DevPage = new QWidget( this ); \
524 QWidget * name ## PropPage = new QWidget( this ); \
525 stackedDevLayout->addWidget( name ## DevPage ); \
526 stackedPropLayout->addWidget( name ## PropPage ); \
527 QGridLayout * name ## DevLayout = new QGridLayout; \
528 QGridLayout * name ## PropLayout = new QGridLayout; \
529 name ## DevPage->setLayout( name ## DevLayout ); \
530 name ## PropPage->setLayout( name ## PropLayout ); \
531 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
533 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
539 if( module_Exists( p_intf, "v4l" ) ){
540 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
543 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
544 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
546 v4lVideoDevice = new QLineEdit;
547 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
549 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
550 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
552 v4lAudioDevice = new QLineEdit;
553 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
555 /* V4l Props panel */
556 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
557 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
559 v4lNormBox = new QComboBox;
560 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
561 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
563 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
564 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
566 v4lFreq = new QSpinBox;
567 v4lFreq->setAlignment( Qt::AlignRight );
568 v4lFreq->setSuffix(" kHz");
569 setSpinBoxFreq( v4lFreq );
570 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
571 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
575 CuMRL( v4lVideoDevice, textChanged( QString ) );
576 CuMRL( v4lAudioDevice, textChanged( QString ) );
577 CuMRL( v4lFreq, valueChanged ( int ) );
578 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
584 if( module_Exists( p_intf, "v4l2" ) ){
585 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
588 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
589 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
591 v4l2VideoDevice = new QLineEdit;
592 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
594 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
595 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
597 v4l2AudioDevice = new QLineEdit;
598 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
600 /* v4l2 Props panel */
601 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
602 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
604 v4l2StdBox = new QComboBox;
605 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
606 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
607 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
611 CuMRL( v4l2VideoDevice, textChanged( QString ) );
612 CuMRL( v4l2AudioDevice, textChanged( QString ) );
613 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
619 if( module_Exists( p_intf, "access_jack" ) ){
620 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
622 /* Jack Main panel */
624 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
625 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
627 jackChannels = new QSpinBox;
628 setSpinBoxFreq( jackChannels );
629 jackChannels->setMaximum(255);
630 jackChannels->setValue(2);
631 jackChannels->setAlignment( Qt::AlignRight );
632 jackDevLayout->addWidget( jackChannels, 1, 1 );
634 /* Jack Props panel */
637 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
638 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
640 jackPortsSelected = new QLineEdit( qtr( ".*") );
641 jackPortsSelected->setAlignment( Qt::AlignRight );
642 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
645 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
646 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
647 jackCaching = new QSpinBox;
648 setSpinBoxFreq( jackCaching );
649 jackCaching->setSuffix( " ms" );
650 jackCaching->setValue(1000);
651 jackCaching->setAlignment( Qt::AlignRight );
652 jackPropLayout->addWidget( jackCaching, 1 , 1 );
655 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
656 jackPropLayout->addWidget( jackPace, 2, 1 );
659 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
660 jackPropLayout->addWidget( jackConnect, 3, 1 );
663 CuMRL( jackChannels, valueChanged( int ) );
664 CuMRL( jackCaching, valueChanged( int ) );
665 CuMRL( jackPace, stateChanged( int ) );
666 CuMRL( jackConnect, stateChanged( int ) );
667 CuMRL( jackPortsSelected, textChanged( QString ) );
673 if( module_Exists( p_intf, "pvr" ) ){
674 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
677 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
678 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
680 pvrDevice = new QLineEdit;
681 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
683 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
684 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
686 pvrRadioDevice = new QLineEdit;
687 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
689 /* PVR props panel */
690 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
691 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
693 pvrNormBox = new QComboBox;
694 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
695 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
697 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
698 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
700 pvrFreq = new QSpinBox;
701 pvrFreq->setAlignment( Qt::AlignRight );
702 pvrFreq->setSuffix(" kHz");
703 setSpinBoxFreq( pvrFreq );
704 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
706 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
707 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
709 pvrBitr = new QSpinBox;
710 pvrBitr->setAlignment( Qt::AlignRight );
711 pvrBitr->setSuffix(" kHz");
712 setSpinBoxFreq( pvrBitr );
713 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
714 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
718 CuMRL( pvrDevice, textChanged( QString ) );
719 CuMRL( pvrRadioDevice, textChanged( QString ) );
721 CuMRL( pvrFreq, valueChanged ( int ) );
722 CuMRL( pvrBitr, valueChanged ( int ) );
723 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
729 if( module_Exists( p_intf, "dvb" ) ){
730 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
733 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
734 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
736 dvbCard = new QSpinBox;
737 dvbCard->setAlignment( Qt::AlignRight );
738 dvbCard->setPrefix( "/dev/dvb/adapter" );
740 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
741 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
743 dvbs = new QRadioButton( "DVB-S" );
744 dvbs->setChecked( true );
745 dvbc = new QRadioButton( "DVB-C" );
746 dvbt = new QRadioButton( "DVB-T" );
748 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
749 dvbDevLayout->addWidget( dvbs, 1, 1 );
750 dvbDevLayout->addWidget( dvbc, 1, 2 );
751 dvbDevLayout->addWidget( dvbt, 1, 3 );
753 /* DVB Props panel */
754 QLabel *dvbFreqLabel =
755 new QLabel( qtr( "Transponder/multiplex frequency" ) );
756 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
758 dvbFreq = new QSpinBox;
759 dvbFreq->setAlignment( Qt::AlignRight );
760 dvbFreq->setSuffix(" kHz");
761 setSpinBoxFreq( dvbFreq );
762 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
764 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
765 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
767 dvbSrate = new QSpinBox;
768 dvbSrate->setAlignment( Qt::AlignRight );
769 dvbSrate->setSuffix(" kHz");
770 setSpinBoxFreq( dvbSrate );
771 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
772 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
776 CuMRL( dvbCard, valueChanged ( int ) );
777 CuMRL( dvbFreq, valueChanged ( int ) );
778 CuMRL( dvbSrate, valueChanged ( int ) );
780 BUTTONACT( dvbs, updateButtons() );
781 BUTTONACT( dvbt, updateButtons() );
782 BUTTONACT( dvbc, updateButtons() );
787 /*********************
788 * DirectShow Stuffs *
789 *********************/
790 if( module_Exists( p_intf, "dshow" ) ){
791 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
795 module_config_t *p_config =
796 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
797 vdevDshowW = new StringListConfigControl(
798 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
801 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
802 adevDshowW = new StringListConfigControl(
803 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
806 /* dshow Properties */
807 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
808 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
810 dshowVSizeLine = new QLineEdit;
811 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
812 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
816 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
817 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
818 CuMRL( dshowVSizeLine, textChanged( QString ) );
824 if( module_Exists( p_intf, "bda" ) ){
825 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
828 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
830 bdas = new QRadioButton( "DVB-S" );
831 bdas->setChecked( true );
832 bdac = new QRadioButton( "DVB-C" );
833 bdat = new QRadioButton( "DVB-T" );
835 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
836 bdaDevLayout->addWidget( bdas, 0, 1 );
837 bdaDevLayout->addWidget( bdac, 0, 2 );
838 bdaDevLayout->addWidget( bdat, 0, 3 );
841 QLabel *bdaFreqLabel =
842 new QLabel( qtr( "Transponder/multiplex frequency" ) );
843 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
845 bdaFreq = new QSpinBox;
846 bdaFreq->setAlignment( Qt::AlignRight );
847 bdaFreq->setSuffix(" kHz");
848 bdaFreq->setSingleStep( 1000 );
849 setSpinBoxFreq( bdaFreq )
850 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
852 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
853 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
855 bdaSrate = new QSpinBox;
856 bdaSrate->setAlignment( Qt::AlignRight );
857 bdaSrate->setSuffix(" kHz");
858 setSpinBoxFreq( bdaSrate );
859 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
861 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
862 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
864 bdaBandBox = new QComboBox;
865 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
866 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
868 bdaBandLabel->hide();
870 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
874 CuMRL( bdaFreq, valueChanged ( int ) );
875 CuMRL( bdaSrate, valueChanged ( int ) );
876 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
877 BUTTONACT( bdas, updateButtons() );
878 BUTTONACT( bdat, updateButtons() );
879 BUTTONACT( bdac, updateButtons() );
880 BUTTONACT( bdas, updateMRL() );
881 BUTTONACT( bdat, updateMRL() );
882 BUTTONACT( bdac, updateMRL() );
890 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
891 QLabel *screenLabel = new QLabel( "This option will open your own "
892 "desktop in order to save or stream it.");
893 screenLabel->setWordWrap( true );
894 screenDevLayout->addWidget( screenLabel, 0, 0 );
896 /* General connects */
897 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
898 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
899 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
900 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
901 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
902 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
907 CaptureOpenPanel::~CaptureOpenPanel()
910 void CaptureOpenPanel::clear()
913 void CaptureOpenPanel::updateMRL()
916 int i_devicetype = ui.deviceCombo->itemData(
917 ui.deviceCombo->currentIndex() ).toInt();
918 switch( i_devicetype )
923 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
924 mrl += " :v4l-adev=" + v4lAudioDevice->text();
925 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
926 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
930 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
931 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
932 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
936 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
937 mrl += ":ports=" + jackPortsSelected->text();
938 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
939 if ( jackPace->isChecked() )
941 mrl += " --jack-input-use-vlc-pace";
943 if ( jackConnect->isChecked() )
945 mrl += " --jack-input-auto-connect";
950 mrl += " :pvr-device=" + pvrDevice->text();
951 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
952 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
953 if( pvrFreq->value() )
954 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
955 if( pvrBitr->value() )
956 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
960 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
961 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
962 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
966 if( bdas->isChecked() ) mrl = "dvb-s://";
967 else if( bdat->isChecked() ) mrl = "dvb-t://";
968 else if( bdac->isChecked() ) mrl = "dvb-c://";
970 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
971 if( bdas->isChecked() || bdac->isChecked() )
972 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
974 mrl += " :dvb-bandwidth=" +
975 QString("%1").arg( bdaBandBox->itemData(
976 bdaBandBox->currentIndex() ).toInt() );
980 mrl += " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
981 mrl += " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
982 if( dshowVSizeLine->isModified() )
983 mrl += " :dshow-size=" + dshowVSizeLine->text();
991 emit mrlUpdated( mrl );
995 * Update the Buttons (show/hide) for the GUI as all device type don't
996 * use the same ui. elements.
998 void CaptureOpenPanel::updateButtons()
1000 /* Be sure to display the ui Elements in case they were hidden by
1001 * some Device Type (like Screen://) */
1002 ui.optionsBox->show();
1003 ui.advancedButton->show();
1004 /* Get the current Device Number */
1005 int i_devicetype = ui.deviceCombo->itemData(
1006 ui.deviceCombo->currentIndex() ).toInt();
1007 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
1008 switch( i_devicetype )
1012 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1013 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1017 if( bdas->isChecked() || bdac->isChecked() )
1020 bdaSrateLabel->show();
1022 bdaBandLabel->hide();
1027 bdaSrateLabel->hide();
1029 bdaBandLabel->show();
1034 ui.optionsBox->hide();
1035 ui.advancedButton->hide();