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>
48 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
50 /**************************************************************************
51 * Open Files and subtitles *
52 **************************************************************************/
53 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
54 OpenPanel( _parent, _p_intf )
56 /* Classic UI Setup */
59 /** BEGIN QFileDialog tweaking **/
60 /* Use a QFileDialog and customize it because we don't want to
61 rewrite it all. Be careful to your eyes cause there are a few hacks.
62 Be very careful and test correctly when you modify this. */
64 /* Set Filters for file selection */
65 QString fileTypes = "";
66 ADD_FILTER_MEDIA( fileTypes );
67 ADD_FILTER_VIDEO( fileTypes );
68 ADD_FILTER_AUDIO( fileTypes );
69 ADD_FILTER_PLAYLIST( fileTypes );
70 ADD_FILTER_ALL( fileTypes );
71 fileTypes.replace( QString(";*"), QString(" *"));
73 // Make this QFileDialog a child of tempWidget from the ui.
74 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
75 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
77 dialogBox->setFileMode( QFileDialog::ExistingFiles );
78 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
80 dialogBox->restoreState(
81 getSettings()->value( "file-dialog-state" ).toByteArray() );
84 /* We don't want to see a grip in the middle of the window, do we? */
85 dialogBox->setSizeGripEnabled( false );
88 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
89 dialogBox->setMinimumHeight( 250 );
91 // But hide the two OK/Cancel buttons. Enable them for debug.
92 QDialogButtonBox *fileDialogAcceptBox =
93 dialogBox->findChildren<QDialogButtonBox*>()[0];
94 fileDialogAcceptBox->hide();
96 /* Ugly hacks to get the good Widget */
97 //This lineEdit is the normal line in the fileDialog.
99 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
101 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
103 /* Make a list of QLabel inside the QFileDialog to access the good ones */
104 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
106 /* Hide the FileNames one. Enable it for debug */
107 listLabel[1]->setText( qtr( "File names:" ) );
108 /* Change the text that was uncool in the usual box */
109 listLabel[2]->setText( qtr( "Filter:" ) );
111 dialogBox->layout()->setMargin( 0 );
112 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
114 /** END of QFileDialog tweaking **/
116 // Add the DialogBox to the layout
117 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
119 //TODO later: fill the fileCompleteList with previous items played.
120 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
121 fileCompleter->setModel( new QDirModel( fileCompleter ) );
122 lineFileEdit->setCompleter( fileCompleter );
124 // Hide the subtitles control by default.
127 /* Build the subs size combo box */
128 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
129 ui.sizeSubComboBox );
131 /* Build the subs align combo box */
132 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
135 BUTTONACT( ui.subBrowseButton, browseFileSub() );
136 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
138 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
139 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
140 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
141 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
144 FileOpenPanel::~FileOpenPanel()
147 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
151 /* Show a fileBrowser to select a subtitle */
152 void FileOpenPanel::browseFileSub()
154 // TODO Handle selection of more than one subtitles file
155 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
157 dialogBox->directory().absolutePath() );
158 if( files.isEmpty() ) return;
159 ui.subInput->setText( files.join(" ") );
163 /* Update the current MRL */
164 void FileOpenPanel::updateMRL()
167 foreach( QString file, dialogBox->selectedFiles() ) {
168 mrl += "\"" + file + "\" ";
171 if( ui.subCheckBox->isChecked() ) {
172 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
173 int align = ui.alignSubComboBox->itemData(
174 ui.alignSubComboBox->currentIndex() ).toInt();
175 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
176 int size = ui.sizeSubComboBox->itemData(
177 ui.sizeSubComboBox->currentIndex() ).toInt();
178 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
181 emit mrlUpdated( mrl );
182 emit methodChanged( "file-caching" );
185 /* Function called by Open Dialog when clicke on Play/Enqueue */
186 void FileOpenPanel::accept()
188 //TODO set the completer
189 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
192 void FileOpenBox::accept()
194 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
197 void FileOpenBox::reject()
199 OpenDialog::getInstance( NULL, NULL, true )->cancel();
202 /* Function called by Open Dialog when clicked on cancel */
203 void FileOpenPanel::clear()
205 lineFileEdit->clear();
206 ui.subInput->clear();
209 void FileOpenPanel::toggleSubtitleFrame()
211 TOGGLEV( ui.subFrame );
217 /**************************************************************************
218 * Open Discs ( DVD, CD, VCD and similar devices ) *
219 **************************************************************************/
220 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
221 OpenPanel( _parent, _p_intf )
225 /* Get the default configuration path for the devices */
226 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
227 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
228 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
230 /* State to avoid overwritting the users changes with the configuration */
235 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
236 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
238 #ifdef WIN32 /* Disc drives probing for Windows */
241 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
243 char *drive = szDrives;
244 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
247 if( GetDriveTypeA(drive) == DRIVE_CDROM )
248 ui.deviceCombo->addItem( drive );
250 /* go to next drive */
253 SetErrorMode(oldMode);
255 #else /* Use a Completer under Linux */
256 QCompleter *discCompleter = new QCompleter( this );
257 discCompleter->setModel( new QDirModel( discCompleter ) );
258 ui.deviceCombo->setCompleter( discCompleter );
262 BUTTONACT( ui.dvdRadioButton, updateButtons() );
263 BUTTONACT( ui.vcdRadioButton, updateButtons() );
264 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
265 BUTTONACT( ui.dvdsimple, updateButtons() );
266 BUTTONACT( ui.browseDiscButton, browseDevice() );
267 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
270 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
271 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
272 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
273 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
274 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
276 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
280 DiscOpenPanel::~DiscOpenPanel()
282 free( psz_dvddiscpath );
283 free( psz_vcddiscpath );
284 free( psz_cddadiscpath );
287 void DiscOpenPanel::clear()
289 ui.titleSpin->setValue( 0 );
290 ui.chapterSpin->setValue( 0 );
297 #define setDrive( psz_name ) {\
298 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
299 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
301 #define setDrive( psz_name ) {\
302 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
305 /* update the buttons according the type of device */
306 void DiscOpenPanel::updateButtons()
308 if ( ui.dvdRadioButton->isChecked() )
312 setDrive( psz_dvddiscpath );
315 ui.titleLabel->setText( qtr("Title") );
316 ui.chapterLabel->show();
317 ui.chapterSpin->show();
318 ui.diskOptionBox_2->show();
319 ui.dvdsimple->setEnabled( true );
321 else if ( ui.vcdRadioButton->isChecked() )
325 setDrive( psz_vcddiscpath );
328 ui.titleLabel->setText( qtr("Entry") );
329 ui.chapterLabel->hide();
330 ui.chapterSpin->hide();
331 ui.diskOptionBox_2->show();
332 ui.dvdsimple->setEnabled( false );
338 setDrive( psz_cddadiscpath );
341 ui.titleLabel->setText( qtr("Track") );
342 ui.chapterLabel->hide();
343 ui.chapterSpin->hide();
344 ui.diskOptionBox_2->hide();
345 ui.dvdsimple->setEnabled( false );
351 /* Update the current MRL */
352 void DiscOpenPanel::updateMRL()
356 /* CDDAX and VCDX not implemented. TODO ? */
358 if( ui.dvdRadioButton->isChecked() ) {
359 if( !ui.dvdsimple->isChecked() )
362 mrl = "\"dvdsimple://";
363 mrl += ui.deviceCombo->currentText();
364 emit methodChanged( "dvdnav-caching" );
366 if ( ui.titleSpin->value() > 0 ) {
367 mrl += QString("@%1").arg( ui.titleSpin->value() );
368 if ( ui.chapterSpin->value() > 0 ) {
369 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
374 } else if ( ui.vcdRadioButton->isChecked() ) {
375 mrl = "\"vcd://" + ui.deviceCombo->currentText();
376 emit methodChanged( "vcd-caching" );
378 if( ui.titleSpin->value() > 0 ) {
379 mrl += QString("@E%1").arg( ui.titleSpin->value() );
384 mrl = "\"cdda://" + ui.deviceCombo->currentText();
385 if( ui.titleSpin->value() > 0 ) {
386 QString("@%1").arg( ui.titleSpin->value() );
392 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
394 if ( ui.audioSpin->value() >= 0 ) {
395 mrl += " :audio-track=" +
396 QString("%1").arg( ui.audioSpin->value() );
398 if ( ui.subtitlesSpin->value() >= 0 ) {
399 mrl += " :sub-track=" +
400 QString("%1").arg( ui.subtitlesSpin->value() );
403 emit mrlUpdated( mrl );
406 void DiscOpenPanel::browseDevice()
408 QString dir = QFileDialog::getExistingDirectory( this,
409 qtr( I_DEVICE_TOOLTIP ) );
411 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
416 void DiscOpenPanel::eject()
418 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
421 void DiscOpenPanel::accept()
424 /**************************************************************************
425 * Open Network streams and URL pages *
426 **************************************************************************/
427 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
428 OpenPanel( _parent, _p_intf )
433 CONNECT( ui.protocolCombo, activated( int ),
434 this, updateProtocol( int ) );
435 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
436 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
437 CONNECT( ui.timeShift, clicked(), this, updateMRL());
439 ui.protocolCombo->addItem( "" );
440 ui.protocolCombo->addItem("HTTP", QVariant("http"));
441 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
442 ui.protocolCombo->addItem("MMS", QVariant("mms"));
443 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
444 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
445 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
446 ui.protocolCombo->addItem("UDP", QVariant("udp"));
447 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
449 updateProtocol( ui.protocolCombo->currentIndex() );
452 NetOpenPanel::~NetOpenPanel()
455 void NetOpenPanel::clear()
458 /* update the widgets according the type of protocol */
459 void NetOpenPanel::updateProtocol( int idx_proto ) {
460 QString addr = ui.addressText->text();
461 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
463 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
464 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
465 idx_proto == RTP_PROTO );
467 if( idx_proto == NO_PROTO ) return;
469 /* If we already have a protocol in the address, replace it */
470 if( addr.contains( "://"))
472 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
473 addr.replace( QRegExp("^.*://@*"), proto + "://");
475 addr.replace( QRegExp("^.*://"), proto + "://@");
476 ui.addressText->setText( addr );
481 void NetOpenPanel::updateMRL() {
483 QString addr = ui.addressText->text();
484 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
485 int idx_proto = ui.protocolCombo->currentIndex();
487 if( addr.contains( "://"))
489 /* Match the correct item in the comboBox */
490 ui.protocolCombo->setCurrentIndex(
491 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
493 if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
498 switch( idx_proto ) {
500 mrl = "http://" + addr;
501 emit methodChanged("http-caching");
504 mrl = "https://" + addr;
505 emit methodChanged("http-caching");
508 mrl = "mms://" + addr;
509 emit methodChanged("mms-caching");
512 mrl = "ftp://" + addr;
513 emit methodChanged("ftp-caching");
516 mrl = "rtsp://" + addr;
517 emit methodChanged("rtsp-caching");
522 if ( addr.contains(':') && !addr.contains('[') )
524 mrl += "[" + addr + "]";
527 mrl += QString(":%1").arg( ui.portSpin->value() );
528 emit methodChanged("udp-caching");
532 if ( addr.contains(':') && !addr.contains('[') )
533 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
536 mrl += QString(":%1").arg( ui.portSpin->value() );
537 emit methodChanged("rtp-caching");
540 mrl = "rtmp://" + addr;
541 emit methodChanged("rtmp-caching");
546 // Encode the boring stuffs
548 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
549 mrl += " :access-filter=timeshift";
551 emit mrlUpdated( mrl );
554 /**************************************************************************
555 * Open Capture device ( DVB, PVR, V4L, and similar ) *
556 **************************************************************************/
557 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
558 OpenPanel( _parent, _p_intf )
560 isInitialized = false;
563 void CaptureOpenPanel::initialize()
565 if( isInitialized ) return;
567 msg_Dbg( p_intf, "Initialization of Capture device panel" );
568 isInitialized = true;
572 BUTTONACT( ui.advancedButton, advancedDialog() );
574 /* Create two stacked layouts in the main comboBoxes */
575 QStackedLayout *stackedDevLayout = new QStackedLayout;
576 ui.cardBox->setLayout( stackedDevLayout );
578 QStackedLayout *stackedPropLayout = new QStackedLayout;
579 ui.optionsBox->setLayout( stackedPropLayout );
581 /* Creation and connections of the WIdgets in the stacked layout */
582 #define addModuleAndLayouts( number, name, label ) \
583 QWidget * name ## DevPage = new QWidget( this ); \
584 QWidget * name ## PropPage = new QWidget( this ); \
585 stackedDevLayout->addWidget( name ## DevPage ); \
586 stackedPropLayout->addWidget( name ## PropPage ); \
587 QGridLayout * name ## DevLayout = new QGridLayout; \
588 QGridLayout * name ## PropLayout = new QGridLayout; \
589 name ## DevPage->setLayout( name ## DevLayout ); \
590 name ## PropPage->setLayout( name ## PropLayout ); \
591 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
593 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
596 /*********************
597 * DirectShow Stuffs *
598 *********************/
599 if( module_exists( p_intf, "dshow" ) ){
600 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
604 module_config_t *p_config =
605 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
606 vdevDshowW = new StringListConfigControl(
607 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
610 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
611 adevDshowW = new StringListConfigControl(
612 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
615 /* dshow Properties */
616 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
617 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
619 dshowVSizeLine = new QLineEdit;
620 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
621 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
625 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
626 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
627 CuMRL( dshowVSizeLine, textChanged( QString ) );
633 if( module_exists( p_intf, "bda" ) ){
634 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
637 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
639 bdas = new QRadioButton( "DVB-S" );
640 bdas->setChecked( true );
641 bdac = new QRadioButton( "DVB-C" );
642 bdat = new QRadioButton( "DVB-T" );
644 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
645 bdaDevLayout->addWidget( bdas, 0, 1 );
646 bdaDevLayout->addWidget( bdac, 0, 2 );
647 bdaDevLayout->addWidget( bdat, 0, 3 );
650 QLabel *bdaFreqLabel =
651 new QLabel( qtr( "Transponder/multiplex frequency" ) );
652 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
654 bdaFreq = new QSpinBox;
655 bdaFreq->setAlignment( Qt::AlignRight );
656 bdaFreq->setSuffix(" kHz");
657 bdaFreq->setSingleStep( 1000 );
658 setSpinBoxFreq( bdaFreq )
659 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
661 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
662 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
664 bdaSrate = new QSpinBox;
665 bdaSrate->setAlignment( Qt::AlignRight );
666 bdaSrate->setSuffix(" kHz");
667 setSpinBoxFreq( bdaSrate );
668 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
670 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
671 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
673 bdaBandBox = new QComboBox;
674 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
675 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
677 bdaBandLabel->hide();
679 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
683 CuMRL( bdaFreq, valueChanged ( int ) );
684 CuMRL( bdaSrate, valueChanged ( int ) );
685 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
686 BUTTONACT( bdas, updateButtons() );
687 BUTTONACT( bdat, updateButtons() );
688 BUTTONACT( bdac, updateButtons() );
689 BUTTONACT( bdas, updateMRL() );
690 BUTTONACT( bdat, updateMRL() );
691 BUTTONACT( bdac, updateMRL() );
698 if( module_exists( p_intf, "v4l2" ) ){
699 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
702 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
703 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
705 v4l2VideoDevice = new QLineEdit;
706 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
708 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
709 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
711 v4l2AudioDevice = new QLineEdit;
712 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
714 /* v4l2 Props panel */
715 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
716 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
718 v4l2StdBox = new QComboBox;
719 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
720 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
721 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
725 CuMRL( v4l2VideoDevice, textChanged( QString ) );
726 CuMRL( v4l2AudioDevice, textChanged( QString ) );
727 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
733 if( module_exists( p_intf, "v4l" ) ){
734 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
737 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
738 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
740 v4lVideoDevice = new QLineEdit;
741 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
743 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
744 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
746 v4lAudioDevice = new QLineEdit;
747 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
749 /* V4l Props panel */
750 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
751 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
753 v4lNormBox = new QComboBox;
754 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
755 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
757 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
758 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
760 v4lFreq = new QSpinBox;
761 v4lFreq->setAlignment( Qt::AlignRight );
762 v4lFreq->setSuffix(" kHz");
763 setSpinBoxFreq( v4lFreq );
764 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
765 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
769 CuMRL( v4lVideoDevice, textChanged( QString ) );
770 CuMRL( v4lAudioDevice, textChanged( QString ) );
771 CuMRL( v4lFreq, valueChanged ( int ) );
772 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
778 if( module_exists( p_intf, "jack" ) ){
779 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
781 /* Jack Main panel */
783 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
784 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
786 jackChannels = new QSpinBox;
787 setSpinBoxFreq( jackChannels );
788 jackChannels->setMaximum(255);
789 jackChannels->setValue(2);
790 jackChannels->setAlignment( Qt::AlignRight );
791 jackDevLayout->addWidget( jackChannels, 1, 1 );
793 /* Jack Props panel */
796 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
797 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
799 jackPortsSelected = new QLineEdit( qtr( ".*") );
800 jackPortsSelected->setAlignment( Qt::AlignRight );
801 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
804 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
805 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
806 jackCaching = new QSpinBox;
807 setSpinBoxFreq( jackCaching );
808 jackCaching->setSuffix( " ms" );
809 jackCaching->setValue(1000);
810 jackCaching->setAlignment( Qt::AlignRight );
811 jackPropLayout->addWidget( jackCaching, 1 , 1 );
814 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
815 jackPropLayout->addWidget( jackPace, 2, 1 );
818 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
819 jackPropLayout->addWidget( jackConnect, 3, 1 );
822 CuMRL( jackChannels, valueChanged( int ) );
823 CuMRL( jackCaching, valueChanged( int ) );
824 CuMRL( jackPace, stateChanged( int ) );
825 CuMRL( jackConnect, stateChanged( int ) );
826 CuMRL( jackPortsSelected, textChanged( QString ) );
832 if( module_exists( p_intf, "pvr" ) ){
833 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
836 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
837 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
839 pvrDevice = new QLineEdit;
840 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
842 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
843 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
845 pvrRadioDevice = new QLineEdit;
846 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
848 /* PVR props panel */
849 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
850 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
852 pvrNormBox = new QComboBox;
853 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
854 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
856 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
857 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
859 pvrFreq = new QSpinBox;
860 pvrFreq->setAlignment( Qt::AlignRight );
861 pvrFreq->setSuffix(" kHz");
862 setSpinBoxFreq( pvrFreq );
863 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
865 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
866 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
868 pvrBitr = new QSpinBox;
869 pvrBitr->setAlignment( Qt::AlignRight );
870 pvrBitr->setSuffix(" kHz");
871 setSpinBoxFreq( pvrBitr );
872 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
873 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
877 CuMRL( pvrDevice, textChanged( QString ) );
878 CuMRL( pvrRadioDevice, textChanged( QString ) );
880 CuMRL( pvrFreq, valueChanged ( int ) );
881 CuMRL( pvrBitr, valueChanged ( int ) );
882 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
888 if( module_exists( p_intf, "dvb" ) ){
889 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
892 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
893 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
895 dvbCard = new QSpinBox;
896 dvbCard->setAlignment( Qt::AlignRight );
897 dvbCard->setPrefix( "/dev/dvb/adapter" );
899 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
900 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
902 dvbs = new QRadioButton( "DVB-S" );
903 dvbs->setChecked( true );
904 dvbc = new QRadioButton( "DVB-C" );
905 dvbt = new QRadioButton( "DVB-T" );
907 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
908 dvbDevLayout->addWidget( dvbs, 1, 1 );
909 dvbDevLayout->addWidget( dvbc, 1, 2 );
910 dvbDevLayout->addWidget( dvbt, 1, 3 );
912 /* DVB Props panel */
913 QLabel *dvbFreqLabel =
914 new QLabel( qtr( "Transponder/multiplex frequency" ) );
915 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
917 dvbFreq = new QSpinBox;
918 dvbFreq->setAlignment( Qt::AlignRight );
919 dvbFreq->setSuffix(" kHz");
920 setSpinBoxFreq( dvbFreq );
921 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
923 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
924 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
926 dvbSrate = new QSpinBox;
927 dvbSrate->setAlignment( Qt::AlignRight );
928 dvbSrate->setSuffix(" kHz");
929 setSpinBoxFreq( dvbSrate );
930 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
931 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
935 CuMRL( dvbCard, valueChanged ( int ) );
936 CuMRL( dvbFreq, valueChanged ( int ) );
937 CuMRL( dvbSrate, valueChanged ( int ) );
939 BUTTONACT( dvbs, updateButtons() );
940 BUTTONACT( dvbt, updateButtons() );
941 BUTTONACT( dvbc, updateButtons() );
950 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
951 QLabel *screenLabel = new QLabel( "This option will open your own "
952 "desktop in order to save or stream it.");
953 screenLabel->setWordWrap( true );
954 screenDevLayout->addWidget( screenLabel, 0, 0 );
956 QLabel *screenFPSLabel = new QLabel(
957 qtr( "Desired frame rate for the capture." ) );
958 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
960 screenFPS = new QSpinBox;
961 screenFPS->setValue( 1 );
962 screenFPS->setAlignment( Qt::AlignRight );
963 screenPropLayout->addWidget( screenFPS, 0, 1 );
965 /* General connects */
966 CONNECT( ui.deviceCombo, activated( int ) ,
967 stackedDevLayout, setCurrentIndex( int ) );
968 CONNECT( ui.deviceCombo, activated( int ),
969 stackedPropLayout, setCurrentIndex( int ) );
970 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
971 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
976 CaptureOpenPanel::~CaptureOpenPanel()
980 void CaptureOpenPanel::clear()
985 void CaptureOpenPanel::updateMRL()
988 int i_devicetype = ui.deviceCombo->itemData(
989 ui.deviceCombo->currentIndex() ).toInt();
990 switch( i_devicetype )
994 if( bdas->isChecked() ) mrl = "dvb-s://";
995 else if( bdat->isChecked() ) mrl = "dvb-t://";
996 else if( bdac->isChecked() ) mrl = "dvb-c://";
998 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
999 if( bdas->isChecked() || bdac->isChecked() )
1000 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1002 mrl += " :dvb-bandwidth=" +
1003 QString("%1").arg( bdaBandBox->itemData(
1004 bdaBandBox->currentIndex() ).toInt() );
1008 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1009 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1010 if( dshowVSizeLine->isModified() )
1011 mrl += " :dshow-size=" + dshowVSizeLine->text();
1016 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1017 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1018 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1019 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1023 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1024 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1025 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1029 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1030 mrl += ":ports=" + jackPortsSelected->text();
1031 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1032 if ( jackPace->isChecked() )
1034 mrl += " --jack-input-use-vlc-pace";
1036 if ( jackConnect->isChecked() )
1038 mrl += " --jack-input-auto-connect";
1043 mrl += " :pvr-device=" + pvrDevice->text();
1044 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1045 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1046 if( pvrFreq->value() )
1047 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1048 if( pvrBitr->value() )
1049 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1053 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1054 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1055 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1060 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1065 if( !advMRL.isEmpty() ) mrl += advMRL;
1067 emit mrlUpdated( mrl );
1071 * Update the Buttons (show/hide) for the GUI as all device type don't
1072 * use the same ui. elements.
1074 void CaptureOpenPanel::updateButtons()
1076 /* Be sure to display the ui Elements in case they were hidden by
1077 * some Device Type (like Screen://) */
1078 ui.optionsBox->show();
1079 ui.advancedButton->show();
1080 /* Get the current Device Number */
1081 int i_devicetype = ui.deviceCombo->itemData(
1082 ui.deviceCombo->currentIndex() ).toInt();
1083 switch( i_devicetype )
1087 if( bdas->isChecked() || bdac->isChecked() )
1090 bdaSrateLabel->show();
1092 bdaBandLabel->hide();
1097 bdaSrateLabel->hide();
1099 bdaBandLabel->show();
1104 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1105 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1109 //ui.optionsBox->hide();
1110 ui.advancedButton->hide();
1117 void CaptureOpenPanel::advancedDialog()
1119 /* Get selected device type */
1120 int i_devicetype = ui.deviceCombo->itemData(
1121 ui.deviceCombo->currentIndex() ).toInt();
1123 /* Get the corresponding module */
1124 module_t *p_module =
1125 module_find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1126 if( NULL == p_module ) return;
1129 QList<ConfigControl *> controls;
1131 /* Get the confsize */
1132 unsigned int i_confsize;
1133 module_config_t *p_config;
1134 p_config = module_config_get( p_module, &i_confsize );
1136 /* New Adv Prop dialog */
1137 adv = new QDialog( this );
1138 adv->setWindowTitle( qtr( "Advanced Options" ) );
1140 /* A main Layout with a Frame */
1141 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1142 QScrollArea *scroll = new QScrollArea;
1143 mainLayout->addWidget( scroll );
1145 QFrame *advFrame = new QFrame;
1146 /* GridLayout inside the Frame */
1147 QGridLayout *gLayout = new QGridLayout( advFrame );
1149 scroll->setWidgetResizable( true );
1150 scroll->setWidget( advFrame );
1152 /* Create the options inside the FrameLayout */
1153 for( int n = 0; n < i_confsize; n++ )
1155 module_config_t *p_item = p_config + n;
1156 ConfigControl *config = ConfigControl::createControl(
1157 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1158 controls.append( config );
1162 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1163 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1164 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1166 CONNECT( closeButton, clicked(), adv, accept() );
1167 CONNECT( cancelButton, clicked(), adv, reject() );
1169 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1170 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1172 mainLayout->addWidget( advButtonBox );
1174 /* Creation of the MRL */
1177 QString tempMRL = "";
1178 for( int i = 0; i < controls.size(); i++ )
1180 ConfigControl *control = controls[i];
1183 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1187 tempMRL += (i ? " :" : ":");
1189 if( control->getType() == CONFIG_ITEM_BOOL )
1190 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1193 tempMRL += control->getName();
1195 switch( control->getType() )
1197 case CONFIG_ITEM_STRING:
1198 case CONFIG_ITEM_FILE:
1199 case CONFIG_ITEM_DIRECTORY:
1200 case CONFIG_ITEM_MODULE:
1201 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1203 case CONFIG_ITEM_INTEGER:
1204 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1206 case CONFIG_ITEM_FLOAT:
1207 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1213 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1216 module_config_free( p_config );
1217 module_release (p_module);