1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2008 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 *****************************************************************************/
34 #include "components/open_panels.hpp"
35 #include "dialogs/open.hpp"
36 #include "dialogs_provider.hpp"
38 #include <QFileDialog>
39 #include <QDialogButtonBox>
41 #include <QStackedLayout>
45 #include <QScrollArea>
49 #define I_DEVICE_TOOLTIP "Select the device or the VIDEO_TS directory"
51 /**************************************************************************
52 * Open Files and subtitles *
53 **************************************************************************/
54 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
55 OpenPanel( _parent, _p_intf )
57 /* Classic UI Setup */
60 /** BEGIN QFileDialog tweaking **/
61 /* Use a QFileDialog and customize it because we don't want to
62 rewrite it all. Be careful to your eyes cause there are a few hacks.
63 Be very careful and test correctly when you modify this. */
65 /* Set Filters for file selection */
66 QString fileTypes = "";
67 ADD_FILTER_MEDIA( fileTypes );
68 ADD_FILTER_VIDEO( fileTypes );
69 ADD_FILTER_AUDIO( fileTypes );
70 ADD_FILTER_PLAYLIST( fileTypes );
71 ADD_FILTER_ALL( fileTypes );
72 fileTypes.replace( QString(";*"), QString(" *"));
74 // Make this QFileDialog a child of tempWidget from the ui.
75 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
76 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
78 dialogBox->setFileMode( QFileDialog::ExistingFiles );
79 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
81 QSettings settings( "vlc", "vlc-qt-interface" );
82 dialogBox->restoreState(
83 settings.value( "file-dialog-state" ).toByteArray() );
86 /* We don't want to see a grip in the middle of the window, do we? */
87 dialogBox->setSizeGripEnabled( false );
90 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
92 // But hide the two OK/Cancel buttons. Enable them for debug.
93 QDialogButtonBox *fileDialogAcceptBox =
94 dialogBox->findChildren<QDialogButtonBox*>()[0];
95 fileDialogAcceptBox->hide();
97 /* Ugly hacks to get the good Widget */
98 //This lineEdit is the normal line in the fileDialog.
100 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
102 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
104 /* Make a list of QLabel inside the QFileDialog to access the good ones */
105 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
107 /* Hide the FileNames one. Enable it for debug */
108 listLabel[1]->setText( qtr( "File names:" ) );
109 /* Change the text that was uncool in the usual box */
110 listLabel[2]->setText( qtr( "Filter:" ) );
112 dialogBox->layout()->setMargin( 0 );
113 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
115 /** END of QFileDialog tweaking **/
117 // Add the DialogBox to the layout
118 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
120 //TODO later: fill the fileCompleteList with previous items played.
121 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
122 fileCompleter->setModel( new QDirModel( fileCompleter ) );
123 lineFileEdit->setCompleter( fileCompleter );
125 // Hide the subtitles control by default.
128 /* Build the subs size combo box */
129 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
130 ui.sizeSubComboBox );
132 /* Build the subs align combo box */
133 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
136 BUTTONACT( ui.subBrowseButton, browseFileSub() );
137 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
139 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
140 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
141 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
142 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
145 FileOpenPanel::~FileOpenPanel()
148 QSettings settings( "vlc", "vlc-qt-interface" );
149 settings.setValue( "file-dialog-state", dialogBox->saveState() );
153 /* Show a fileBrowser to select a subtitle */
154 void FileOpenPanel::browseFileSub()
156 // TODO Handle selection of more than one subtitles file
157 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
159 dialogBox->directory().absolutePath() );
160 if( files.isEmpty() ) return;
161 ui.subInput->setText( files.join(" ") );
165 /* Update the current MRL */
166 void FileOpenPanel::updateMRL()
169 foreach( QString file, dialogBox->selectedFiles() ) {
170 mrl += "\"" + file + "\" ";
173 if( ui.subCheckBox->isChecked() ) {
174 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
175 int align = ui.alignSubComboBox->itemData(
176 ui.alignSubComboBox->currentIndex() ).toInt();
177 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
178 int size = ui.sizeSubComboBox->itemData(
179 ui.sizeSubComboBox->currentIndex() ).toInt();
180 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
183 emit mrlUpdated( mrl );
184 emit methodChanged( "file-caching" );
187 /* Function called by Open Dialog when clicke on Play/Enqueue */
188 void FileOpenPanel::accept()
190 //TODO set the completer
191 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
194 void FileOpenBox::accept()
196 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
199 /* Function called by Open Dialog when clicked on cancel */
200 void FileOpenPanel::clear()
202 lineFileEdit->clear();
203 ui.subInput->clear();
206 void FileOpenPanel::toggleSubtitleFrame()
208 TOGGLEV( ui.subFrame );
214 /**************************************************************************
215 * Open Discs ( DVD, CD, VCD and similar devices ) *
216 **************************************************************************/
217 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
218 OpenPanel( _parent, _p_intf )
222 /* Get the default configuration path for the devices */
223 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
224 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
225 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
227 /* State to avoid overwritting the users changes with the configuration */
232 ui.browseDiscButton->setToolTip( I_DEVICE_TOOLTIP );
233 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
235 #if WIN32 /* Disc drives probing for Windows */
238 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
240 char *drive = szDrives;
241 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
244 if( GetDriveTypeA(drive) == DRIVE_CDROM )
245 ui.deviceCombo->addItem( drive );
247 /* go to next drive */
250 SetErrorMode(oldMode);
252 #else /* Use a Completer under Linux */
253 QCompleter *discCompleter = new QCompleter( this );
254 discCompleter->setModel( new QDirModel( discCompleter ) );
255 ui.deviceCombo->setCompleter( discCompleter );
259 BUTTONACT( ui.dvdRadioButton, updateButtons() );
260 BUTTONACT( ui.vcdRadioButton, updateButtons() );
261 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
262 BUTTONACT( ui.dvdsimple, updateButtons() );
263 BUTTONACT( ui.browseDiscButton, browseDevice() );
264 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
267 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
268 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
269 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
270 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
271 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
273 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
277 DiscOpenPanel::~DiscOpenPanel()
279 delete psz_dvddiscpath;
280 delete psz_vcddiscpath;
281 delete psz_cddadiscpath;
284 void DiscOpenPanel::clear()
286 ui.titleSpin->setValue( 0 );
287 ui.chapterSpin->setValue( 0 );
294 #define setDrive( psz_name ) {\
295 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
296 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
298 #define setDrive( psz_name ) {\
299 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
302 /* update the buttons according the type of device */
303 void DiscOpenPanel::updateButtons()
305 if ( ui.dvdRadioButton->isChecked() )
309 setDrive( psz_dvddiscpath );
312 ui.titleLabel->setText( qtr("Title") );
313 ui.chapterLabel->show();
314 ui.chapterSpin->show();
315 ui.diskOptionBox_2->show();
316 ui.dvdsimple->setEnabled( true );
318 else if ( ui.vcdRadioButton->isChecked() )
322 setDrive( psz_vcddiscpath );
325 ui.titleLabel->setText( qtr("Entry") );
326 ui.chapterLabel->hide();
327 ui.chapterSpin->hide();
328 ui.diskOptionBox_2->show();
329 ui.dvdsimple->setEnabled( false );
335 setDrive( psz_cddadiscpath );
338 ui.titleLabel->setText( qtr("Track") );
339 ui.chapterLabel->hide();
340 ui.chapterSpin->hide();
341 ui.diskOptionBox_2->hide();
342 ui.dvdsimple->setEnabled( false );
348 /* Update the current MRL */
349 void DiscOpenPanel::updateMRL()
353 /* CDDAX and VCDX not implemented. TODO ? */
355 if( ui.dvdRadioButton->isChecked() ) {
356 if( !ui.dvdsimple->isChecked() )
359 mrl = "\"dvdsimple://";
360 mrl += ui.deviceCombo->currentText();
361 emit methodChanged( "dvdnav-caching" );
363 if ( ui.titleSpin->value() > 0 ) {
364 mrl += QString("@%1").arg( ui.titleSpin->value() );
365 if ( ui.chapterSpin->value() > 0 ) {
366 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
371 } else if ( ui.vcdRadioButton->isChecked() ) {
372 mrl = "\"vcd://" + ui.deviceCombo->currentText();
373 emit methodChanged( "vcd-caching" );
375 if( ui.titleSpin->value() > 0 ) {
376 mrl += QString("@E%1").arg( ui.titleSpin->value() );
381 mrl = "\"cdda://" + ui.deviceCombo->currentText();
382 if( ui.titleSpin->value() > 0 ) {
383 QString("@%1").arg( ui.titleSpin->value() );
389 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
391 if ( ui.audioSpin->value() >= 0 ) {
392 mrl += " :audio-track=" +
393 QString("%1").arg( ui.audioSpin->value() );
395 if ( ui.subtitlesSpin->value() >= 0 ) {
396 mrl += " :sub-track=" +
397 QString("%1").arg( ui.subtitlesSpin->value() );
400 emit mrlUpdated( mrl );
403 void DiscOpenPanel::browseDevice()
405 QString dir = QFileDialog::getExistingDirectory( 0,
406 qtr( I_DEVICE_TOOLTIP ) );
407 if (!dir.isEmpty()) {
408 ui.deviceCombo->setEditText( dir );
413 void DiscOpenPanel::eject()
415 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
418 void DiscOpenPanel::accept()
421 /**************************************************************************
422 * Open Network streams and URL pages *
423 **************************************************************************/
424 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
425 OpenPanel( _parent, _p_intf )
430 CONNECT( ui.protocolCombo, activated( int ),
431 this, updateProtocol( int ) );
432 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
433 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
434 CONNECT( ui.timeShift, clicked(), this, updateMRL());
436 ui.protocolCombo->addItem( "" );
437 ui.protocolCombo->addItem("HTTP", QVariant("http"));
438 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
439 ui.protocolCombo->addItem("MMS", QVariant("mms"));
440 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
441 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
442 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
443 ui.protocolCombo->addItem("UDP", QVariant("udp"));
444 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
446 updateProtocol( ui.protocolCombo->currentIndex() );
449 NetOpenPanel::~NetOpenPanel()
452 void NetOpenPanel::clear()
455 /* update the widgets according the type of protocol */
456 void NetOpenPanel::updateProtocol( int idx_proto ) {
457 QString addr = ui.addressText->text();
458 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
460 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
461 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
462 idx_proto == RTP_PROTO );
464 if( idx_proto == NO_PROTO ) return;
466 /* If we already have a protocol in the address, replace it */
467 if( addr.contains( "://"))
469 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
470 addr.replace( QRegExp("^.*://@*"), proto + "://");
472 addr.replace( QRegExp("^.*://"), proto + "://@");
473 ui.addressText->setText( addr );
478 void NetOpenPanel::updateMRL() {
480 QString addr = ui.addressText->text();
481 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
482 int idx_proto = ui.protocolCombo->currentIndex();
484 if( addr.contains( "://"))
486 /* Match the correct item in the comboBox */
487 ui.protocolCombo->setCurrentIndex(
488 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
490 if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
495 switch( idx_proto ) {
497 mrl = "http://" + addr;
498 emit methodChanged("http-caching");
501 mrl = "https://" + addr;
502 emit methodChanged("http-caching");
505 mrl = "mms://" + addr;
506 emit methodChanged("mms-caching");
509 mrl = "ftp://" + addr;
510 emit methodChanged("ftp-caching");
513 mrl = "rtsp://" + addr;
514 emit methodChanged("rtsp-caching");
519 if ( addr.contains(':') && !addr.contains('[') )
521 mrl += "[" + addr + "]";
524 mrl += QString(":%1").arg( ui.portSpin->value() );
525 emit methodChanged("udp-caching");
529 if ( addr.contains(':') && !addr.contains('[') )
530 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
533 mrl += QString(":%1").arg( ui.portSpin->value() );
534 emit methodChanged("rtp-caching");
537 mrl = "rtmp://" + addr;
538 emit methodChanged("rtmp-caching");
543 // Encode the boring stuffs
545 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
546 mrl += " :access-filter=timeshift";
548 emit mrlUpdated( mrl );
551 /**************************************************************************
552 * Open Capture device ( DVB, PVR, V4L, and similar ) *
553 **************************************************************************/
554 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
555 OpenPanel( _parent, _p_intf )
559 BUTTONACT( ui.advancedButton, advancedDialog() );
561 /* Create two stacked layouts in the main comboBoxes */
562 QStackedLayout *stackedDevLayout = new QStackedLayout;
563 ui.cardBox->setLayout( stackedDevLayout );
565 QStackedLayout *stackedPropLayout = new QStackedLayout;
566 ui.optionsBox->setLayout( stackedPropLayout );
568 /* Creation and connections of the WIdgets in the stacked layout */
569 #define addModuleAndLayouts( number, name, label ) \
570 QWidget * name ## DevPage = new QWidget( this ); \
571 QWidget * name ## PropPage = new QWidget( this ); \
572 stackedDevLayout->addWidget( name ## DevPage ); \
573 stackedPropLayout->addWidget( name ## PropPage ); \
574 QGridLayout * name ## DevLayout = new QGridLayout; \
575 QGridLayout * name ## PropLayout = new QGridLayout; \
576 name ## DevPage->setLayout( name ## DevLayout ); \
577 name ## PropPage->setLayout( name ## PropLayout ); \
578 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
580 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
583 /*********************
584 * DirectShow Stuffs *
585 *********************/
586 if( module_Exists( p_intf, "dshow" ) ){
587 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
591 module_config_t *p_config =
592 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
593 vdevDshowW = new StringListConfigControl(
594 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
597 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
598 adevDshowW = new StringListConfigControl(
599 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
602 /* dshow Properties */
603 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
604 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
606 dshowVSizeLine = new QLineEdit;
607 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
608 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
612 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
613 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
614 CuMRL( dshowVSizeLine, textChanged( QString ) );
620 if( module_Exists( p_intf, "bda" ) ){
621 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
624 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
626 bdas = new QRadioButton( "DVB-S" );
627 bdas->setChecked( true );
628 bdac = new QRadioButton( "DVB-C" );
629 bdat = new QRadioButton( "DVB-T" );
631 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
632 bdaDevLayout->addWidget( bdas, 0, 1 );
633 bdaDevLayout->addWidget( bdac, 0, 2 );
634 bdaDevLayout->addWidget( bdat, 0, 3 );
637 QLabel *bdaFreqLabel =
638 new QLabel( qtr( "Transponder/multiplex frequency" ) );
639 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
641 bdaFreq = new QSpinBox;
642 bdaFreq->setAlignment( Qt::AlignRight );
643 bdaFreq->setSuffix(" kHz");
644 bdaFreq->setSingleStep( 1000 );
645 setSpinBoxFreq( bdaFreq )
646 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
648 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
649 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
651 bdaSrate = new QSpinBox;
652 bdaSrate->setAlignment( Qt::AlignRight );
653 bdaSrate->setSuffix(" kHz");
654 setSpinBoxFreq( bdaSrate );
655 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
657 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
658 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
660 bdaBandBox = new QComboBox;
661 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
662 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
664 bdaBandLabel->hide();
666 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
670 CuMRL( bdaFreq, valueChanged ( int ) );
671 CuMRL( bdaSrate, valueChanged ( int ) );
672 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
673 BUTTONACT( bdas, updateButtons() );
674 BUTTONACT( bdat, updateButtons() );
675 BUTTONACT( bdac, updateButtons() );
676 BUTTONACT( bdas, updateMRL() );
677 BUTTONACT( bdat, updateMRL() );
678 BUTTONACT( bdac, updateMRL() );
685 if( module_Exists( p_intf, "v4l2" ) ){
686 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
689 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
690 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
692 v4l2VideoDevice = new QLineEdit;
693 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
695 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
696 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
698 v4l2AudioDevice = new QLineEdit;
699 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
701 /* v4l2 Props panel */
702 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
703 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
705 v4l2StdBox = new QComboBox;
706 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
707 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
708 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
712 CuMRL( v4l2VideoDevice, textChanged( QString ) );
713 CuMRL( v4l2AudioDevice, textChanged( QString ) );
714 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
720 if( module_Exists( p_intf, "v4l" ) ){
721 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
724 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
725 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
727 v4lVideoDevice = new QLineEdit;
728 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
730 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
731 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
733 v4lAudioDevice = new QLineEdit;
734 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
736 /* V4l Props panel */
737 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
738 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
740 v4lNormBox = new QComboBox;
741 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
742 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
744 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
745 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
747 v4lFreq = new QSpinBox;
748 v4lFreq->setAlignment( Qt::AlignRight );
749 v4lFreq->setSuffix(" kHz");
750 setSpinBoxFreq( v4lFreq );
751 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
752 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
756 CuMRL( v4lVideoDevice, textChanged( QString ) );
757 CuMRL( v4lAudioDevice, textChanged( QString ) );
758 CuMRL( v4lFreq, valueChanged ( int ) );
759 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
765 if( module_Exists( p_intf, "jack" ) ){
766 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
768 /* Jack Main panel */
770 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
771 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
773 jackChannels = new QSpinBox;
774 setSpinBoxFreq( jackChannels );
775 jackChannels->setMaximum(255);
776 jackChannels->setValue(2);
777 jackChannels->setAlignment( Qt::AlignRight );
778 jackDevLayout->addWidget( jackChannels, 1, 1 );
780 /* Jack Props panel */
783 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
784 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
786 jackPortsSelected = new QLineEdit( qtr( ".*") );
787 jackPortsSelected->setAlignment( Qt::AlignRight );
788 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
791 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
792 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
793 jackCaching = new QSpinBox;
794 setSpinBoxFreq( jackCaching );
795 jackCaching->setSuffix( " ms" );
796 jackCaching->setValue(1000);
797 jackCaching->setAlignment( Qt::AlignRight );
798 jackPropLayout->addWidget( jackCaching, 1 , 1 );
801 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
802 jackPropLayout->addWidget( jackPace, 2, 1 );
805 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
806 jackPropLayout->addWidget( jackConnect, 3, 1 );
809 CuMRL( jackChannels, valueChanged( int ) );
810 CuMRL( jackCaching, valueChanged( int ) );
811 CuMRL( jackPace, stateChanged( int ) );
812 CuMRL( jackConnect, stateChanged( int ) );
813 CuMRL( jackPortsSelected, textChanged( QString ) );
819 if( module_Exists( p_intf, "pvr" ) ){
820 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
823 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
824 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
826 pvrDevice = new QLineEdit;
827 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
829 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
830 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
832 pvrRadioDevice = new QLineEdit;
833 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
835 /* PVR props panel */
836 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
837 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
839 pvrNormBox = new QComboBox;
840 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
841 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
843 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
844 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
846 pvrFreq = new QSpinBox;
847 pvrFreq->setAlignment( Qt::AlignRight );
848 pvrFreq->setSuffix(" kHz");
849 setSpinBoxFreq( pvrFreq );
850 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
852 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
853 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
855 pvrBitr = new QSpinBox;
856 pvrBitr->setAlignment( Qt::AlignRight );
857 pvrBitr->setSuffix(" kHz");
858 setSpinBoxFreq( pvrBitr );
859 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
860 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
864 CuMRL( pvrDevice, textChanged( QString ) );
865 CuMRL( pvrRadioDevice, textChanged( QString ) );
867 CuMRL( pvrFreq, valueChanged ( int ) );
868 CuMRL( pvrBitr, valueChanged ( int ) );
869 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
875 if( module_Exists( p_intf, "dvb" ) ){
876 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
879 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
880 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
882 dvbCard = new QSpinBox;
883 dvbCard->setAlignment( Qt::AlignRight );
884 dvbCard->setPrefix( "/dev/dvb/adapter" );
886 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
887 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
889 dvbs = new QRadioButton( "DVB-S" );
890 dvbs->setChecked( true );
891 dvbc = new QRadioButton( "DVB-C" );
892 dvbt = new QRadioButton( "DVB-T" );
894 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
895 dvbDevLayout->addWidget( dvbs, 1, 1 );
896 dvbDevLayout->addWidget( dvbc, 1, 2 );
897 dvbDevLayout->addWidget( dvbt, 1, 3 );
899 /* DVB Props panel */
900 QLabel *dvbFreqLabel =
901 new QLabel( qtr( "Transponder/multiplex frequency" ) );
902 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
904 dvbFreq = new QSpinBox;
905 dvbFreq->setAlignment( Qt::AlignRight );
906 dvbFreq->setSuffix(" kHz");
907 setSpinBoxFreq( dvbFreq );
908 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
910 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
911 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
913 dvbSrate = new QSpinBox;
914 dvbSrate->setAlignment( Qt::AlignRight );
915 dvbSrate->setSuffix(" kHz");
916 setSpinBoxFreq( dvbSrate );
917 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
918 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
922 CuMRL( dvbCard, valueChanged ( int ) );
923 CuMRL( dvbFreq, valueChanged ( int ) );
924 CuMRL( dvbSrate, valueChanged ( int ) );
926 BUTTONACT( dvbs, updateButtons() );
927 BUTTONACT( dvbt, updateButtons() );
928 BUTTONACT( dvbc, updateButtons() );
937 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
938 QLabel *screenLabel = new QLabel( "This option will open your own "
939 "desktop in order to save or stream it.");
940 screenLabel->setWordWrap( true );
941 screenDevLayout->addWidget( screenLabel, 0, 0 );
943 /* General connects */
944 CONNECT( ui.deviceCombo, activated( int ) ,
945 stackedDevLayout, setCurrentIndex( int ) );
946 CONNECT( ui.deviceCombo, activated( int ),
947 stackedPropLayout, setCurrentIndex( int ) );
948 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
949 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
954 CaptureOpenPanel::~CaptureOpenPanel()
958 void CaptureOpenPanel::clear()
963 void CaptureOpenPanel::updateMRL()
966 int i_devicetype = ui.deviceCombo->itemData(
967 ui.deviceCombo->currentIndex() ).toInt();
968 switch( i_devicetype )
972 if( bdas->isChecked() ) mrl = "dvb-s://";
973 else if( bdat->isChecked() ) mrl = "dvb-t://";
974 else if( bdac->isChecked() ) mrl = "dvb-c://";
976 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
977 if( bdas->isChecked() || bdac->isChecked() )
978 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
980 mrl += " :dvb-bandwidth=" +
981 QString("%1").arg( bdaBandBox->itemData(
982 bdaBandBox->currentIndex() ).toInt() );
986 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
987 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
988 if( dshowVSizeLine->isModified() )
989 mrl += " :dshow-size=" + dshowVSizeLine->text();
994 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
995 mrl += " :v4l-adev=" + v4lAudioDevice->text();
996 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
997 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1001 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1002 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1003 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1007 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1008 mrl += ":ports=" + jackPortsSelected->text();
1009 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1010 if ( jackPace->isChecked() )
1012 mrl += " --jack-input-use-vlc-pace";
1014 if ( jackConnect->isChecked() )
1016 mrl += " --jack-input-auto-connect";
1021 mrl += " :pvr-device=" + pvrDevice->text();
1022 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1023 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1024 if( pvrFreq->value() )
1025 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1026 if( pvrBitr->value() )
1027 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1031 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1032 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1033 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1042 if( !advMRL.isEmpty() ) mrl += advMRL;
1044 emit mrlUpdated( mrl );
1048 * Update the Buttons (show/hide) for the GUI as all device type don't
1049 * use the same ui. elements.
1051 void CaptureOpenPanel::updateButtons()
1053 /* Be sure to display the ui Elements in case they were hidden by
1054 * some Device Type (like Screen://) */
1055 ui.optionsBox->show();
1056 ui.advancedButton->show();
1057 /* Get the current Device Number */
1058 int i_devicetype = ui.deviceCombo->itemData(
1059 ui.deviceCombo->currentIndex() ).toInt();
1060 switch( i_devicetype )
1064 if( bdas->isChecked() || bdac->isChecked() )
1067 bdaSrateLabel->show();
1069 bdaBandLabel->hide();
1074 bdaSrateLabel->hide();
1076 bdaBandLabel->show();
1081 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1082 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1086 ui.optionsBox->hide();
1087 ui.advancedButton->hide();
1094 void CaptureOpenPanel::advancedDialog()
1096 /* Get selected device type */
1097 int i_devicetype = ui.deviceCombo->itemData(
1098 ui.deviceCombo->currentIndex() ).toInt();
1100 /* Get the corresponding module */
1101 module_t *p_module =
1102 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1103 if( NULL == p_module ) return;
1106 QList<ConfigControl *> controls;
1108 /* Get the confsize */
1109 unsigned int i_confsize;
1110 module_config_t *p_config;
1111 p_config = module_GetConfig( p_module, &i_confsize );
1113 /* New Adv Prop dialog */
1114 adv = new QDialog( this );
1115 adv->setWindowTitle( qtr( "Advanced Options" ) );
1117 /* A main Layout with a Frame */
1118 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1119 QFrame *advFrame = new QFrame;
1120 QScrollArea *scroll = new QScrollArea;
1121 mainLayout->addWidget( scroll );
1123 /* GridLayout inside the Frame */
1124 QGridLayout *gLayout = new QGridLayout( advFrame );
1125 gLayout->setSizeConstraint( QLayout::SetFixedSize );
1127 scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
1128 scroll->setWidgetResizable( true );
1129 scroll->setWidget( advFrame );
1131 /* Create the options inside the FrameLayout */
1132 for( int n = 0; n < i_confsize; n++ )
1134 module_config_t *p_item = p_config + n;
1135 ConfigControl *config = ConfigControl::createControl(
1136 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1137 controls.append( config );
1141 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1142 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1143 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1145 CONNECT( closeButton, clicked(), adv, accept() );
1146 CONNECT( cancelButton, clicked(), adv, reject() );
1148 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1149 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1151 mainLayout->addWidget( advButtonBox );
1153 /* Creation of the MRL */
1156 QString tempMRL = "";
1157 for( int i = 0; i < controls.size(); i++ )
1159 ConfigControl *control = controls[i];
1162 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1166 tempMRL += (i ? " :" : ":");
1168 if( control->getType() == CONFIG_ITEM_BOOL )
1169 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1172 tempMRL += control->getName();
1174 switch( control->getType() )
1176 case CONFIG_ITEM_STRING:
1177 case CONFIG_ITEM_FILE:
1178 case CONFIG_ITEM_DIRECTORY:
1179 case CONFIG_ITEM_MODULE:
1180 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1182 case CONFIG_ITEM_INTEGER:
1183 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1185 case CONFIG_ITEM_FLOAT:
1186 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1192 msg_Dbg( p_intf, "%s", qtu( advMRL ) );