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 "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" ) );
90 // But hide the two OK/Cancel buttons. Enable them for debug.
91 QDialogButtonBox *fileDialogAcceptBox =
92 dialogBox->findChildren<QDialogButtonBox*>()[0];
93 fileDialogAcceptBox->hide();
95 /* Ugly hacks to get the good Widget */
96 //This lineEdit is the normal line in the fileDialog.
98 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
100 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
102 /* Make a list of QLabel inside the QFileDialog to access the good ones */
103 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
105 /* Hide the FileNames one. Enable it for debug */
106 listLabel[1]->setText( qtr( "File names:" ) );
107 /* Change the text that was uncool in the usual box */
108 listLabel[2]->setText( qtr( "Filter:" ) );
110 dialogBox->layout()->setMargin( 0 );
111 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
113 /** END of QFileDialog tweaking **/
115 // Add the DialogBox to the layout
116 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
118 //TODO later: fill the fileCompleteList with previous items played.
119 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
120 fileCompleter->setModel( new QDirModel( fileCompleter ) );
121 lineFileEdit->setCompleter( fileCompleter );
123 // Hide the subtitles control by default.
126 /* Build the subs size combo box */
127 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
128 ui.sizeSubComboBox );
130 /* Build the subs align combo box */
131 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
134 BUTTONACT( ui.subBrowseButton, browseFileSub() );
135 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
137 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
138 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
139 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
140 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
143 FileOpenPanel::~FileOpenPanel()
146 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
150 /* Show a fileBrowser to select a subtitle */
151 void FileOpenPanel::browseFileSub()
153 // TODO Handle selection of more than one subtitles file
154 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
156 dialogBox->directory().absolutePath() );
157 if( files.isEmpty() ) return;
158 ui.subInput->setText( files.join(" ") );
162 /* Update the current MRL */
163 void FileOpenPanel::updateMRL()
166 foreach( QString file, dialogBox->selectedFiles() ) {
167 mrl += "\"" + file + "\" ";
170 if( ui.subCheckBox->isChecked() ) {
171 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
172 int align = ui.alignSubComboBox->itemData(
173 ui.alignSubComboBox->currentIndex() ).toInt();
174 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
175 int size = ui.sizeSubComboBox->itemData(
176 ui.sizeSubComboBox->currentIndex() ).toInt();
177 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
180 emit mrlUpdated( mrl );
181 emit methodChanged( "file-caching" );
184 /* Function called by Open Dialog when clicke on Play/Enqueue */
185 void FileOpenPanel::accept()
187 //TODO set the completer
188 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
191 void FileOpenBox::accept()
193 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
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 ui.browseDiscButton->setToolTip( I_DEVICE_TOOLTIP );
230 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
232 #if WIN32 /* Disc drives probing for Windows */
235 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
237 char *drive = szDrives;
238 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
241 if( GetDriveTypeA(drive) == DRIVE_CDROM )
242 ui.deviceCombo->addItem( drive );
244 /* go to next drive */
247 SetErrorMode(oldMode);
249 #else /* Use a Completer under Linux */
250 QCompleter *discCompleter = new QCompleter( this );
251 discCompleter->setModel( new QDirModel( discCompleter ) );
252 ui.deviceCombo->setCompleter( discCompleter );
256 BUTTONACT( ui.dvdRadioButton, updateButtons() );
257 BUTTONACT( ui.vcdRadioButton, updateButtons() );
258 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
259 BUTTONACT( ui.dvdsimple, updateButtons() );
260 BUTTONACT( ui.browseDiscButton, browseDevice() );
261 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
264 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
265 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
266 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
267 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
268 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
270 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
274 DiscOpenPanel::~DiscOpenPanel()
276 free( psz_dvddiscpath );
277 free( psz_vcddiscpath );
278 free( psz_cddadiscpath );
281 void DiscOpenPanel::clear()
283 ui.titleSpin->setValue( 0 );
284 ui.chapterSpin->setValue( 0 );
291 #define setDrive( psz_name ) {\
292 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
293 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
295 #define setDrive( psz_name ) {\
296 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
299 /* update the buttons according the type of device */
300 void DiscOpenPanel::updateButtons()
302 if ( ui.dvdRadioButton->isChecked() )
306 setDrive( psz_dvddiscpath );
309 ui.titleLabel->setText( qtr("Title") );
310 ui.chapterLabel->show();
311 ui.chapterSpin->show();
312 ui.diskOptionBox_2->show();
313 ui.dvdsimple->setEnabled( true );
315 else if ( ui.vcdRadioButton->isChecked() )
319 setDrive( psz_vcddiscpath );
322 ui.titleLabel->setText( qtr("Entry") );
323 ui.chapterLabel->hide();
324 ui.chapterSpin->hide();
325 ui.diskOptionBox_2->show();
326 ui.dvdsimple->setEnabled( false );
332 setDrive( psz_cddadiscpath );
335 ui.titleLabel->setText( qtr("Track") );
336 ui.chapterLabel->hide();
337 ui.chapterSpin->hide();
338 ui.diskOptionBox_2->hide();
339 ui.dvdsimple->setEnabled( false );
345 /* Update the current MRL */
346 void DiscOpenPanel::updateMRL()
350 /* CDDAX and VCDX not implemented. TODO ? */
352 if( ui.dvdRadioButton->isChecked() ) {
353 if( !ui.dvdsimple->isChecked() )
356 mrl = "\"dvdsimple://";
357 mrl += ui.deviceCombo->currentText();
358 emit methodChanged( "dvdnav-caching" );
360 if ( ui.titleSpin->value() > 0 ) {
361 mrl += QString("@%1").arg( ui.titleSpin->value() );
362 if ( ui.chapterSpin->value() > 0 ) {
363 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
368 } else if ( ui.vcdRadioButton->isChecked() ) {
369 mrl = "\"vcd://" + ui.deviceCombo->currentText();
370 emit methodChanged( "vcd-caching" );
372 if( ui.titleSpin->value() > 0 ) {
373 mrl += QString("@E%1").arg( ui.titleSpin->value() );
378 mrl = "\"cdda://" + ui.deviceCombo->currentText();
379 if( ui.titleSpin->value() > 0 ) {
380 QString("@%1").arg( ui.titleSpin->value() );
386 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
388 if ( ui.audioSpin->value() >= 0 ) {
389 mrl += " :audio-track=" +
390 QString("%1").arg( ui.audioSpin->value() );
392 if ( ui.subtitlesSpin->value() >= 0 ) {
393 mrl += " :sub-track=" +
394 QString("%1").arg( ui.subtitlesSpin->value() );
397 emit mrlUpdated( mrl );
400 void DiscOpenPanel::browseDevice()
402 QString dir = QFileDialog::getExistingDirectory( 0,
403 qtr( I_DEVICE_TOOLTIP ) );
404 if (!dir.isEmpty()) {
405 ui.deviceCombo->setEditText( dir );
410 void DiscOpenPanel::eject()
412 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
415 void DiscOpenPanel::accept()
418 /**************************************************************************
419 * Open Network streams and URL pages *
420 **************************************************************************/
421 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
422 OpenPanel( _parent, _p_intf )
427 CONNECT( ui.protocolCombo, activated( int ),
428 this, updateProtocol( int ) );
429 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
430 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
431 CONNECT( ui.timeShift, clicked(), this, updateMRL());
433 ui.protocolCombo->addItem( "" );
434 ui.protocolCombo->addItem("HTTP", QVariant("http"));
435 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
436 ui.protocolCombo->addItem("MMS", QVariant("mms"));
437 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
438 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
439 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
440 ui.protocolCombo->addItem("UDP", QVariant("udp"));
441 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
443 updateProtocol( ui.protocolCombo->currentIndex() );
446 NetOpenPanel::~NetOpenPanel()
449 void NetOpenPanel::clear()
452 /* update the widgets according the type of protocol */
453 void NetOpenPanel::updateProtocol( int idx_proto ) {
454 QString addr = ui.addressText->text();
455 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
457 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
458 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
459 idx_proto == RTP_PROTO );
461 if( idx_proto == NO_PROTO ) return;
463 /* If we already have a protocol in the address, replace it */
464 if( addr.contains( "://"))
466 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
467 addr.replace( QRegExp("^.*://@*"), proto + "://");
469 addr.replace( QRegExp("^.*://"), proto + "://@");
470 ui.addressText->setText( addr );
475 void NetOpenPanel::updateMRL() {
477 QString addr = ui.addressText->text();
478 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
479 int idx_proto = ui.protocolCombo->currentIndex();
481 if( addr.contains( "://"))
483 /* Match the correct item in the comboBox */
484 ui.protocolCombo->setCurrentIndex(
485 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
487 if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
492 switch( idx_proto ) {
494 mrl = "http://" + addr;
495 emit methodChanged("http-caching");
498 mrl = "https://" + addr;
499 emit methodChanged("http-caching");
502 mrl = "mms://" + addr;
503 emit methodChanged("mms-caching");
506 mrl = "ftp://" + addr;
507 emit methodChanged("ftp-caching");
510 mrl = "rtsp://" + addr;
511 emit methodChanged("rtsp-caching");
516 if ( addr.contains(':') && !addr.contains('[') )
518 mrl += "[" + addr + "]";
521 mrl += QString(":%1").arg( ui.portSpin->value() );
522 emit methodChanged("udp-caching");
526 if ( addr.contains(':') && !addr.contains('[') )
527 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
530 mrl += QString(":%1").arg( ui.portSpin->value() );
531 emit methodChanged("rtp-caching");
534 mrl = "rtmp://" + addr;
535 emit methodChanged("rtmp-caching");
540 // Encode the boring stuffs
542 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
543 mrl += " :access-filter=timeshift";
545 emit mrlUpdated( mrl );
548 /**************************************************************************
549 * Open Capture device ( DVB, PVR, V4L, and similar ) *
550 **************************************************************************/
551 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
552 OpenPanel( _parent, _p_intf )
556 BUTTONACT( ui.advancedButton, advancedDialog() );
558 /* Create two stacked layouts in the main comboBoxes */
559 QStackedLayout *stackedDevLayout = new QStackedLayout;
560 ui.cardBox->setLayout( stackedDevLayout );
562 QStackedLayout *stackedPropLayout = new QStackedLayout;
563 ui.optionsBox->setLayout( stackedPropLayout );
565 /* Creation and connections of the WIdgets in the stacked layout */
566 #define addModuleAndLayouts( number, name, label ) \
567 QWidget * name ## DevPage = new QWidget( this ); \
568 QWidget * name ## PropPage = new QWidget( this ); \
569 stackedDevLayout->addWidget( name ## DevPage ); \
570 stackedPropLayout->addWidget( name ## PropPage ); \
571 QGridLayout * name ## DevLayout = new QGridLayout; \
572 QGridLayout * name ## PropLayout = new QGridLayout; \
573 name ## DevPage->setLayout( name ## DevLayout ); \
574 name ## PropPage->setLayout( name ## PropLayout ); \
575 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
577 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
580 /*********************
581 * DirectShow Stuffs *
582 *********************/
583 if( module_Exists( p_intf, "dshow" ) ){
584 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
588 module_config_t *p_config =
589 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
590 vdevDshowW = new StringListConfigControl(
591 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
594 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
595 adevDshowW = new StringListConfigControl(
596 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
599 /* dshow Properties */
600 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
601 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
603 dshowVSizeLine = new QLineEdit;
604 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
605 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
609 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
610 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
611 CuMRL( dshowVSizeLine, textChanged( QString ) );
617 if( module_Exists( p_intf, "bda" ) ){
618 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
621 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
623 bdas = new QRadioButton( "DVB-S" );
624 bdas->setChecked( true );
625 bdac = new QRadioButton( "DVB-C" );
626 bdat = new QRadioButton( "DVB-T" );
628 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
629 bdaDevLayout->addWidget( bdas, 0, 1 );
630 bdaDevLayout->addWidget( bdac, 0, 2 );
631 bdaDevLayout->addWidget( bdat, 0, 3 );
634 QLabel *bdaFreqLabel =
635 new QLabel( qtr( "Transponder/multiplex frequency" ) );
636 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
638 bdaFreq = new QSpinBox;
639 bdaFreq->setAlignment( Qt::AlignRight );
640 bdaFreq->setSuffix(" kHz");
641 bdaFreq->setSingleStep( 1000 );
642 setSpinBoxFreq( bdaFreq )
643 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
645 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
646 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
648 bdaSrate = new QSpinBox;
649 bdaSrate->setAlignment( Qt::AlignRight );
650 bdaSrate->setSuffix(" kHz");
651 setSpinBoxFreq( bdaSrate );
652 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
654 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
655 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
657 bdaBandBox = new QComboBox;
658 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
659 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
661 bdaBandLabel->hide();
663 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
667 CuMRL( bdaFreq, valueChanged ( int ) );
668 CuMRL( bdaSrate, valueChanged ( int ) );
669 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
670 BUTTONACT( bdas, updateButtons() );
671 BUTTONACT( bdat, updateButtons() );
672 BUTTONACT( bdac, updateButtons() );
673 BUTTONACT( bdas, updateMRL() );
674 BUTTONACT( bdat, updateMRL() );
675 BUTTONACT( bdac, updateMRL() );
682 if( module_Exists( p_intf, "v4l2" ) ){
683 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
686 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
687 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
689 v4l2VideoDevice = new QLineEdit;
690 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
692 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
693 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
695 v4l2AudioDevice = new QLineEdit;
696 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
698 /* v4l2 Props panel */
699 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
700 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
702 v4l2StdBox = new QComboBox;
703 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
704 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
705 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
709 CuMRL( v4l2VideoDevice, textChanged( QString ) );
710 CuMRL( v4l2AudioDevice, textChanged( QString ) );
711 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
717 if( module_Exists( p_intf, "v4l" ) ){
718 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
721 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
722 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
724 v4lVideoDevice = new QLineEdit;
725 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
727 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
728 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
730 v4lAudioDevice = new QLineEdit;
731 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
733 /* V4l Props panel */
734 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
735 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
737 v4lNormBox = new QComboBox;
738 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
739 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
741 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
742 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
744 v4lFreq = new QSpinBox;
745 v4lFreq->setAlignment( Qt::AlignRight );
746 v4lFreq->setSuffix(" kHz");
747 setSpinBoxFreq( v4lFreq );
748 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
749 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
753 CuMRL( v4lVideoDevice, textChanged( QString ) );
754 CuMRL( v4lAudioDevice, textChanged( QString ) );
755 CuMRL( v4lFreq, valueChanged ( int ) );
756 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
762 if( module_Exists( p_intf, "jack" ) ){
763 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
765 /* Jack Main panel */
767 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
768 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
770 jackChannels = new QSpinBox;
771 setSpinBoxFreq( jackChannels );
772 jackChannels->setMaximum(255);
773 jackChannels->setValue(2);
774 jackChannels->setAlignment( Qt::AlignRight );
775 jackDevLayout->addWidget( jackChannels, 1, 1 );
777 /* Jack Props panel */
780 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
781 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
783 jackPortsSelected = new QLineEdit( qtr( ".*") );
784 jackPortsSelected->setAlignment( Qt::AlignRight );
785 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
788 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
789 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
790 jackCaching = new QSpinBox;
791 setSpinBoxFreq( jackCaching );
792 jackCaching->setSuffix( " ms" );
793 jackCaching->setValue(1000);
794 jackCaching->setAlignment( Qt::AlignRight );
795 jackPropLayout->addWidget( jackCaching, 1 , 1 );
798 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
799 jackPropLayout->addWidget( jackPace, 2, 1 );
802 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
803 jackPropLayout->addWidget( jackConnect, 3, 1 );
806 CuMRL( jackChannels, valueChanged( int ) );
807 CuMRL( jackCaching, valueChanged( int ) );
808 CuMRL( jackPace, stateChanged( int ) );
809 CuMRL( jackConnect, stateChanged( int ) );
810 CuMRL( jackPortsSelected, textChanged( QString ) );
816 if( module_Exists( p_intf, "pvr" ) ){
817 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
820 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
821 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
823 pvrDevice = new QLineEdit;
824 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
826 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
827 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
829 pvrRadioDevice = new QLineEdit;
830 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
832 /* PVR props panel */
833 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
834 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
836 pvrNormBox = new QComboBox;
837 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
838 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
840 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
841 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
843 pvrFreq = new QSpinBox;
844 pvrFreq->setAlignment( Qt::AlignRight );
845 pvrFreq->setSuffix(" kHz");
846 setSpinBoxFreq( pvrFreq );
847 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
849 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
850 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
852 pvrBitr = new QSpinBox;
853 pvrBitr->setAlignment( Qt::AlignRight );
854 pvrBitr->setSuffix(" kHz");
855 setSpinBoxFreq( pvrBitr );
856 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
857 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
861 CuMRL( pvrDevice, textChanged( QString ) );
862 CuMRL( pvrRadioDevice, textChanged( QString ) );
864 CuMRL( pvrFreq, valueChanged ( int ) );
865 CuMRL( pvrBitr, valueChanged ( int ) );
866 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
872 if( module_Exists( p_intf, "dvb" ) ){
873 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
876 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
877 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
879 dvbCard = new QSpinBox;
880 dvbCard->setAlignment( Qt::AlignRight );
881 dvbCard->setPrefix( "/dev/dvb/adapter" );
883 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
884 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
886 dvbs = new QRadioButton( "DVB-S" );
887 dvbs->setChecked( true );
888 dvbc = new QRadioButton( "DVB-C" );
889 dvbt = new QRadioButton( "DVB-T" );
891 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
892 dvbDevLayout->addWidget( dvbs, 1, 1 );
893 dvbDevLayout->addWidget( dvbc, 1, 2 );
894 dvbDevLayout->addWidget( dvbt, 1, 3 );
896 /* DVB Props panel */
897 QLabel *dvbFreqLabel =
898 new QLabel( qtr( "Transponder/multiplex frequency" ) );
899 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
901 dvbFreq = new QSpinBox;
902 dvbFreq->setAlignment( Qt::AlignRight );
903 dvbFreq->setSuffix(" kHz");
904 setSpinBoxFreq( dvbFreq );
905 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
907 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
908 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
910 dvbSrate = new QSpinBox;
911 dvbSrate->setAlignment( Qt::AlignRight );
912 dvbSrate->setSuffix(" kHz");
913 setSpinBoxFreq( dvbSrate );
914 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
915 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
919 CuMRL( dvbCard, valueChanged ( int ) );
920 CuMRL( dvbFreq, valueChanged ( int ) );
921 CuMRL( dvbSrate, valueChanged ( int ) );
923 BUTTONACT( dvbs, updateButtons() );
924 BUTTONACT( dvbt, updateButtons() );
925 BUTTONACT( dvbc, updateButtons() );
934 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
935 QLabel *screenLabel = new QLabel( "This option will open your own "
936 "desktop in order to save or stream it.");
937 screenLabel->setWordWrap( true );
938 screenDevLayout->addWidget( screenLabel, 0, 0 );
940 /* General connects */
941 CONNECT( ui.deviceCombo, activated( int ) ,
942 stackedDevLayout, setCurrentIndex( int ) );
943 CONNECT( ui.deviceCombo, activated( int ),
944 stackedPropLayout, setCurrentIndex( int ) );
945 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
946 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
951 CaptureOpenPanel::~CaptureOpenPanel()
955 void CaptureOpenPanel::clear()
960 void CaptureOpenPanel::updateMRL()
963 int i_devicetype = ui.deviceCombo->itemData(
964 ui.deviceCombo->currentIndex() ).toInt();
965 switch( i_devicetype )
969 if( bdas->isChecked() ) mrl = "dvb-s://";
970 else if( bdat->isChecked() ) mrl = "dvb-t://";
971 else if( bdac->isChecked() ) mrl = "dvb-c://";
973 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
974 if( bdas->isChecked() || bdac->isChecked() )
975 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
977 mrl += " :dvb-bandwidth=" +
978 QString("%1").arg( bdaBandBox->itemData(
979 bdaBandBox->currentIndex() ).toInt() );
983 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
984 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
985 if( dshowVSizeLine->isModified() )
986 mrl += " :dshow-size=" + dshowVSizeLine->text();
991 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
992 mrl += " :v4l-adev=" + v4lAudioDevice->text();
993 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
994 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
998 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
999 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1000 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1004 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1005 mrl += ":ports=" + jackPortsSelected->text();
1006 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1007 if ( jackPace->isChecked() )
1009 mrl += " --jack-input-use-vlc-pace";
1011 if ( jackConnect->isChecked() )
1013 mrl += " --jack-input-auto-connect";
1018 mrl += " :pvr-device=" + pvrDevice->text();
1019 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1020 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1021 if( pvrFreq->value() )
1022 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1023 if( pvrBitr->value() )
1024 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1028 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1029 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1030 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1039 if( !advMRL.isEmpty() ) mrl += advMRL;
1041 emit mrlUpdated( mrl );
1045 * Update the Buttons (show/hide) for the GUI as all device type don't
1046 * use the same ui. elements.
1048 void CaptureOpenPanel::updateButtons()
1050 /* Be sure to display the ui Elements in case they were hidden by
1051 * some Device Type (like Screen://) */
1052 ui.optionsBox->show();
1053 ui.advancedButton->show();
1054 /* Get the current Device Number */
1055 int i_devicetype = ui.deviceCombo->itemData(
1056 ui.deviceCombo->currentIndex() ).toInt();
1057 switch( i_devicetype )
1061 if( bdas->isChecked() || bdac->isChecked() )
1064 bdaSrateLabel->show();
1066 bdaBandLabel->hide();
1071 bdaSrateLabel->hide();
1073 bdaBandLabel->show();
1078 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1079 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1083 ui.optionsBox->hide();
1084 ui.advancedButton->hide();
1091 void CaptureOpenPanel::advancedDialog()
1093 /* Get selected device type */
1094 int i_devicetype = ui.deviceCombo->itemData(
1095 ui.deviceCombo->currentIndex() ).toInt();
1097 /* Get the corresponding module */
1098 module_t *p_module =
1099 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1100 if( NULL == p_module ) return;
1103 QList<ConfigControl *> controls;
1105 /* Get the confsize */
1106 unsigned int i_confsize;
1107 module_config_t *p_config;
1108 p_config = module_GetConfig( p_module, &i_confsize );
1110 /* New Adv Prop dialog */
1111 adv = new QDialog( this );
1112 adv->setWindowTitle( qtr( "Advanced Options" ) );
1114 /* A main Layout with a Frame */
1115 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1116 QFrame *advFrame = new QFrame;
1117 QScrollArea *scroll = new QScrollArea;
1118 mainLayout->addWidget( scroll );
1120 /* GridLayout inside the Frame */
1121 QGridLayout *gLayout = new QGridLayout( advFrame );
1122 gLayout->setSizeConstraint( QLayout::SetFixedSize );
1124 scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
1125 scroll->setWidgetResizable( true );
1126 scroll->setWidget( advFrame );
1128 /* Create the options inside the FrameLayout */
1129 for( int n = 0; n < i_confsize; n++ )
1131 module_config_t *p_item = p_config + n;
1132 ConfigControl *config = ConfigControl::createControl(
1133 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1134 controls.append( config );
1138 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1139 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1140 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1142 CONNECT( closeButton, clicked(), adv, accept() );
1143 CONNECT( cancelButton, clicked(), adv, reject() );
1145 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1146 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1148 mainLayout->addWidget( advButtonBox );
1150 /* Creation of the MRL */
1153 QString tempMRL = "";
1154 for( int i = 0; i < controls.size(); i++ )
1156 ConfigControl *control = controls[i];
1159 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1163 tempMRL += (i ? " :" : ":");
1165 if( control->getType() == CONFIG_ITEM_BOOL )
1166 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1169 tempMRL += control->getName();
1171 switch( control->getType() )
1173 case CONFIG_ITEM_STRING:
1174 case CONFIG_ITEM_FILE:
1175 case CONFIG_ITEM_DIRECTORY:
1176 case CONFIG_ITEM_MODULE:
1177 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1179 case CONFIG_ITEM_INTEGER:
1180 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1182 case CONFIG_ITEM_FLOAT:
1183 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1189 msg_Dbg( p_intf, "%s", qtu( advMRL ) );