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 /**************************************************************************
50 * Open Files and subtitles *
51 **************************************************************************/
52 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
53 OpenPanel( _parent, _p_intf )
55 /* Classic UI Setup */
58 /** BEGIN QFileDialog tweaking **/
59 /* Use a QFileDialog and customize it because we don't want to
60 rewrite it all. Be careful to your eyes cause there are a few hacks.
61 Be very careful and test correctly when you modify this. */
63 /* Set Filters for file selection */
64 QString fileTypes = "";
65 ADD_FILTER_MEDIA( fileTypes );
66 ADD_FILTER_VIDEO( fileTypes );
67 ADD_FILTER_AUDIO( fileTypes );
68 ADD_FILTER_PLAYLIST( fileTypes );
69 ADD_FILTER_ALL( fileTypes );
70 fileTypes.replace( QString(";*"), QString(" *"));
72 // Make this QFileDialog a child of tempWidget from the ui.
73 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
74 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
76 dialogBox->setFileMode( QFileDialog::ExistingFiles );
77 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
79 QSettings settings( "vlc", "vlc-qt-interface" );
80 dialogBox->restoreState(
81 settings.value( "file-dialog-state" ).toByteArray() );
83 dialogBox->setViewMode( config_GetInt( p_intf, "qt-open-detail" ) ?
84 QFileDialog::Detail : QFileDialog::List );
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 #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 BUTTONACT( ui.ejectButton, eject() );
263 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
264 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
265 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
266 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
267 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
269 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
273 DiscOpenPanel::~DiscOpenPanel()
275 delete psz_dvddiscpath;
276 delete psz_vcddiscpath;
277 delete psz_cddadiscpath;
280 void DiscOpenPanel::clear()
282 ui.titleSpin->setValue( 0 );
283 ui.chapterSpin->setValue( 0 );
290 #define setDrive( psz_name ) {\
291 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
292 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
294 #define setDrive( psz_name ) {\
295 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
298 /* update the buttons according the type of device */
299 void DiscOpenPanel::updateButtons()
301 if ( ui.dvdRadioButton->isChecked() )
305 setDrive( psz_dvddiscpath );
308 ui.titleLabel->setText( qtr("Title") );
309 ui.chapterLabel->show();
310 ui.chapterSpin->show();
311 ui.diskOptionBox_2->show();
312 ui.dvdsimple->setEnabled( true );
314 else if ( ui.vcdRadioButton->isChecked() )
318 setDrive( psz_vcddiscpath );
321 ui.titleLabel->setText( qtr("Entry") );
322 ui.chapterLabel->hide();
323 ui.chapterSpin->hide();
324 ui.diskOptionBox_2->show();
325 ui.dvdsimple->setEnabled( false );
331 setDrive( psz_cddadiscpath );
334 ui.titleLabel->setText( qtr("Track") );
335 ui.chapterLabel->hide();
336 ui.chapterSpin->hide();
337 ui.diskOptionBox_2->hide();
338 ui.dvdsimple->setEnabled( false );
344 /* Update the current MRL */
345 void DiscOpenPanel::updateMRL()
349 /* CDDAX and VCDX not implemented. TODO ? */
351 if( ui.dvdRadioButton->isChecked() ) {
352 if( !ui.dvdsimple->isChecked() )
355 mrl = "\"dvdsimple://";
356 mrl += ui.deviceCombo->currentText();
357 emit methodChanged( "dvdnav-caching" );
359 if ( ui.titleSpin->value() > 0 ) {
360 mrl += QString("@%1").arg( ui.titleSpin->value() );
361 if ( ui.chapterSpin->value() > 0 ) {
362 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
367 } else if ( ui.vcdRadioButton->isChecked() ) {
368 mrl = "\"vcd://" + ui.deviceCombo->currentText();
369 emit methodChanged( "vcd-caching" );
371 if( ui.titleSpin->value() > 0 ) {
372 mrl += QString("@E%1").arg( ui.titleSpin->value() );
377 mrl = "\"cdda://" + ui.deviceCombo->currentText();
378 if( ui.titleSpin->value() > 0 ) {
379 QString("@%1").arg( ui.titleSpin->value() );
385 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
387 if ( ui.audioSpin->value() >= 0 ) {
388 mrl += " :audio-track=" +
389 QString("%1").arg( ui.audioSpin->value() );
391 if ( ui.subtitlesSpin->value() >= 0 ) {
392 mrl += " :sub-track=" +
393 QString("%1").arg( ui.subtitlesSpin->value() );
396 emit mrlUpdated( mrl );
399 void DiscOpenPanel::browseDevice()
401 QString dir = QFileDialog::getExistingDirectory( 0,
402 qtr("Open a device or a VIDEO_TS directory") );
403 if (!dir.isEmpty()) {
404 ui.deviceCombo->setEditText( dir );
409 void DiscOpenPanel::eject()
411 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
414 void DiscOpenPanel::accept()
417 /**************************************************************************
418 * Open Network streams and URL pages *
419 **************************************************************************/
420 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
421 OpenPanel( _parent, _p_intf )
426 CONNECT( ui.protocolCombo, activated( int ),
427 this, updateProtocol( int ) );
428 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
429 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
430 CONNECT( ui.timeShift, clicked(), this, updateMRL());
432 ui.protocolCombo->addItem( "" );
433 ui.protocolCombo->addItem("HTTP", QVariant("http"));
434 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
435 ui.protocolCombo->addItem("MMS", QVariant("mms"));
436 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
437 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
438 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
439 ui.protocolCombo->addItem("UDP", QVariant("udp"));
440 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
442 updateProtocol( ui.protocolCombo->currentIndex() );
445 NetOpenPanel::~NetOpenPanel()
448 void NetOpenPanel::clear()
451 /* update the widgets according the type of protocol */
452 void NetOpenPanel::updateProtocol( int idx_proto ) {
453 QString addr = ui.addressText->text();
454 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
456 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
457 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
458 idx_proto == RTP_PROTO );
460 if( idx_proto == NO_PROTO ) return;
462 /* If we already have a protocol in the address, replace it */
463 if( addr.contains( "://"))
465 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
466 addr.replace( QRegExp("^.*://@*"), proto + "://");
468 addr.replace( QRegExp("^.*://"), proto + "://@");
469 ui.addressText->setText( addr );
474 void NetOpenPanel::updateMRL() {
476 QString addr = ui.addressText->text();
477 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
478 int idx_proto = ui.protocolCombo->currentIndex();
480 if( addr.contains( "://"))
482 /* Match the correct item in the comboBox */
483 ui.protocolCombo->setCurrentIndex(
484 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
486 if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
491 switch( idx_proto ) {
493 mrl = "http://" + addr;
494 emit methodChanged("http-caching");
497 mrl = "https://" + addr;
498 emit methodChanged("http-caching");
501 mrl = "mms://" + addr;
502 emit methodChanged("mms-caching");
505 mrl = "ftp://" + addr;
506 emit methodChanged("ftp-caching");
509 mrl = "rtsp://" + addr;
510 emit methodChanged("rtsp-caching");
515 if ( addr.contains(':') && !addr.contains('[') )
517 mrl += "[" + addr + "]";
520 mrl += QString(":%1").arg( ui.portSpin->value() );
521 emit methodChanged("udp-caching");
525 if ( addr.contains(':') && !addr.contains('[') )
526 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
529 mrl += QString(":%1").arg( ui.portSpin->value() );
530 emit methodChanged("rtp-caching");
533 mrl = "rtmp://" + addr;
534 emit methodChanged("rtmp-caching");
539 // Encode the boring stuffs
541 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
542 mrl += " :access-filter=timeshift";
544 emit mrlUpdated( mrl );
547 /**************************************************************************
548 * Open Capture device ( DVB, PVR, V4L, and similar ) *
549 **************************************************************************/
550 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
551 OpenPanel( _parent, _p_intf )
555 BUTTONACT( ui.advancedButton, advancedDialog() );
557 /* Create two stacked layouts in the main comboBoxes */
558 QStackedLayout *stackedDevLayout = new QStackedLayout;
559 ui.cardBox->setLayout( stackedDevLayout );
561 QStackedLayout *stackedPropLayout = new QStackedLayout;
562 ui.optionsBox->setLayout( stackedPropLayout );
564 /* Creation and connections of the WIdgets in the stacked layout */
565 #define addModuleAndLayouts( number, name, label ) \
566 QWidget * name ## DevPage = new QWidget( this ); \
567 QWidget * name ## PropPage = new QWidget( this ); \
568 stackedDevLayout->addWidget( name ## DevPage ); \
569 stackedPropLayout->addWidget( name ## PropPage ); \
570 QGridLayout * name ## DevLayout = new QGridLayout; \
571 QGridLayout * name ## PropLayout = new QGridLayout; \
572 name ## DevPage->setLayout( name ## DevLayout ); \
573 name ## PropPage->setLayout( name ## PropLayout ); \
574 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
576 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
579 /*********************
580 * DirectShow Stuffs *
581 *********************/
582 if( module_Exists( p_intf, "dshow" ) ){
583 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
587 module_config_t *p_config =
588 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
589 vdevDshowW = new StringListConfigControl(
590 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
593 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
594 adevDshowW = new StringListConfigControl(
595 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
598 /* dshow Properties */
599 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
600 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
602 dshowVSizeLine = new QLineEdit;
603 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
604 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
608 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
609 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
610 CuMRL( dshowVSizeLine, textChanged( QString ) );
616 if( module_Exists( p_intf, "bda" ) ){
617 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
620 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
622 bdas = new QRadioButton( "DVB-S" );
623 bdas->setChecked( true );
624 bdac = new QRadioButton( "DVB-C" );
625 bdat = new QRadioButton( "DVB-T" );
627 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
628 bdaDevLayout->addWidget( bdas, 0, 1 );
629 bdaDevLayout->addWidget( bdac, 0, 2 );
630 bdaDevLayout->addWidget( bdat, 0, 3 );
633 QLabel *bdaFreqLabel =
634 new QLabel( qtr( "Transponder/multiplex frequency" ) );
635 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
637 bdaFreq = new QSpinBox;
638 bdaFreq->setAlignment( Qt::AlignRight );
639 bdaFreq->setSuffix(" kHz");
640 bdaFreq->setSingleStep( 1000 );
641 setSpinBoxFreq( bdaFreq )
642 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
644 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
645 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
647 bdaSrate = new QSpinBox;
648 bdaSrate->setAlignment( Qt::AlignRight );
649 bdaSrate->setSuffix(" kHz");
650 setSpinBoxFreq( bdaSrate );
651 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
653 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
654 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
656 bdaBandBox = new QComboBox;
657 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
658 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
660 bdaBandLabel->hide();
662 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
666 CuMRL( bdaFreq, valueChanged ( int ) );
667 CuMRL( bdaSrate, valueChanged ( int ) );
668 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
669 BUTTONACT( bdas, updateButtons() );
670 BUTTONACT( bdat, updateButtons() );
671 BUTTONACT( bdac, updateButtons() );
672 BUTTONACT( bdas, updateMRL() );
673 BUTTONACT( bdat, updateMRL() );
674 BUTTONACT( bdac, updateMRL() );
681 if( module_Exists( p_intf, "v4l2" ) ){
682 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
685 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
686 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
688 v4l2VideoDevice = new QLineEdit;
689 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
691 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
692 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
694 v4l2AudioDevice = new QLineEdit;
695 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
697 /* v4l2 Props panel */
698 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
699 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
701 v4l2StdBox = new QComboBox;
702 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
703 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
704 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
708 CuMRL( v4l2VideoDevice, textChanged( QString ) );
709 CuMRL( v4l2AudioDevice, textChanged( QString ) );
710 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
716 if( module_Exists( p_intf, "v4l" ) ){
717 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
720 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
721 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
723 v4lVideoDevice = new QLineEdit;
724 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
726 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
727 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
729 v4lAudioDevice = new QLineEdit;
730 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
732 /* V4l Props panel */
733 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
734 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
736 v4lNormBox = new QComboBox;
737 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
738 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
740 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
741 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
743 v4lFreq = new QSpinBox;
744 v4lFreq->setAlignment( Qt::AlignRight );
745 v4lFreq->setSuffix(" kHz");
746 setSpinBoxFreq( v4lFreq );
747 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
748 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
752 CuMRL( v4lVideoDevice, textChanged( QString ) );
753 CuMRL( v4lAudioDevice, textChanged( QString ) );
754 CuMRL( v4lFreq, valueChanged ( int ) );
755 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
761 if( module_Exists( p_intf, "jack" ) ){
762 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
764 /* Jack Main panel */
766 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
767 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
769 jackChannels = new QSpinBox;
770 setSpinBoxFreq( jackChannels );
771 jackChannels->setMaximum(255);
772 jackChannels->setValue(2);
773 jackChannels->setAlignment( Qt::AlignRight );
774 jackDevLayout->addWidget( jackChannels, 1, 1 );
776 /* Jack Props panel */
779 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
780 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
782 jackPortsSelected = new QLineEdit( qtr( ".*") );
783 jackPortsSelected->setAlignment( Qt::AlignRight );
784 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
787 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
788 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
789 jackCaching = new QSpinBox;
790 setSpinBoxFreq( jackCaching );
791 jackCaching->setSuffix( " ms" );
792 jackCaching->setValue(1000);
793 jackCaching->setAlignment( Qt::AlignRight );
794 jackPropLayout->addWidget( jackCaching, 1 , 1 );
797 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
798 jackPropLayout->addWidget( jackPace, 2, 1 );
801 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
802 jackPropLayout->addWidget( jackConnect, 3, 1 );
805 CuMRL( jackChannels, valueChanged( int ) );
806 CuMRL( jackCaching, valueChanged( int ) );
807 CuMRL( jackPace, stateChanged( int ) );
808 CuMRL( jackConnect, stateChanged( int ) );
809 CuMRL( jackPortsSelected, textChanged( QString ) );
815 if( module_Exists( p_intf, "pvr" ) ){
816 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
819 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
820 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
822 pvrDevice = new QLineEdit;
823 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
825 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
826 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
828 pvrRadioDevice = new QLineEdit;
829 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
831 /* PVR props panel */
832 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
833 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
835 pvrNormBox = new QComboBox;
836 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
837 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
839 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
840 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
842 pvrFreq = new QSpinBox;
843 pvrFreq->setAlignment( Qt::AlignRight );
844 pvrFreq->setSuffix(" kHz");
845 setSpinBoxFreq( pvrFreq );
846 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
848 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
849 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
851 pvrBitr = new QSpinBox;
852 pvrBitr->setAlignment( Qt::AlignRight );
853 pvrBitr->setSuffix(" kHz");
854 setSpinBoxFreq( pvrBitr );
855 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
856 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
860 CuMRL( pvrDevice, textChanged( QString ) );
861 CuMRL( pvrRadioDevice, textChanged( QString ) );
863 CuMRL( pvrFreq, valueChanged ( int ) );
864 CuMRL( pvrBitr, valueChanged ( int ) );
865 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
871 if( module_Exists( p_intf, "dvb" ) ){
872 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
875 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
876 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
878 dvbCard = new QSpinBox;
879 dvbCard->setAlignment( Qt::AlignRight );
880 dvbCard->setPrefix( "/dev/dvb/adapter" );
882 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
883 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
885 dvbs = new QRadioButton( "DVB-S" );
886 dvbs->setChecked( true );
887 dvbc = new QRadioButton( "DVB-C" );
888 dvbt = new QRadioButton( "DVB-T" );
890 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
891 dvbDevLayout->addWidget( dvbs, 1, 1 );
892 dvbDevLayout->addWidget( dvbc, 1, 2 );
893 dvbDevLayout->addWidget( dvbt, 1, 3 );
895 /* DVB Props panel */
896 QLabel *dvbFreqLabel =
897 new QLabel( qtr( "Transponder/multiplex frequency" ) );
898 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
900 dvbFreq = new QSpinBox;
901 dvbFreq->setAlignment( Qt::AlignRight );
902 dvbFreq->setSuffix(" kHz");
903 setSpinBoxFreq( dvbFreq );
904 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
906 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
907 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
909 dvbSrate = new QSpinBox;
910 dvbSrate->setAlignment( Qt::AlignRight );
911 dvbSrate->setSuffix(" kHz");
912 setSpinBoxFreq( dvbSrate );
913 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
914 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
918 CuMRL( dvbCard, valueChanged ( int ) );
919 CuMRL( dvbFreq, valueChanged ( int ) );
920 CuMRL( dvbSrate, valueChanged ( int ) );
922 BUTTONACT( dvbs, updateButtons() );
923 BUTTONACT( dvbt, updateButtons() );
924 BUTTONACT( dvbc, updateButtons() );
933 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
934 QLabel *screenLabel = new QLabel( "This option will open your own "
935 "desktop in order to save or stream it.");
936 screenLabel->setWordWrap( true );
937 screenDevLayout->addWidget( screenLabel, 0, 0 );
939 /* General connects */
940 CONNECT( ui.deviceCombo, activated( int ) ,
941 stackedDevLayout, setCurrentIndex( int ) );
942 CONNECT( ui.deviceCombo, activated( int ),
943 stackedPropLayout, setCurrentIndex( int ) );
944 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
945 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
950 CaptureOpenPanel::~CaptureOpenPanel()
954 void CaptureOpenPanel::clear()
959 void CaptureOpenPanel::updateMRL()
962 int i_devicetype = ui.deviceCombo->itemData(
963 ui.deviceCombo->currentIndex() ).toInt();
964 switch( i_devicetype )
968 if( bdas->isChecked() ) mrl = "dvb-s://";
969 else if( bdat->isChecked() ) mrl = "dvb-t://";
970 else if( bdac->isChecked() ) mrl = "dvb-c://";
972 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
973 if( bdas->isChecked() || bdac->isChecked() )
974 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
976 mrl += " :dvb-bandwidth=" +
977 QString("%1").arg( bdaBandBox->itemData(
978 bdaBandBox->currentIndex() ).toInt() );
982 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
983 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
984 if( dshowVSizeLine->isModified() )
985 mrl += " :dshow-size=" + dshowVSizeLine->text();
990 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
991 mrl += " :v4l-adev=" + v4lAudioDevice->text();
992 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
993 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
997 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
998 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
999 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1003 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1004 mrl += ":ports=" + jackPortsSelected->text();
1005 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1006 if ( jackPace->isChecked() )
1008 mrl += " --jack-input-use-vlc-pace";
1010 if ( jackConnect->isChecked() )
1012 mrl += " --jack-input-auto-connect";
1017 mrl += " :pvr-device=" + pvrDevice->text();
1018 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1019 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1020 if( pvrFreq->value() )
1021 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1022 if( pvrBitr->value() )
1023 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1027 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1028 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1029 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1038 if( !advMRL.isEmpty() ) mrl += advMRL;
1040 emit mrlUpdated( mrl );
1044 * Update the Buttons (show/hide) for the GUI as all device type don't
1045 * use the same ui. elements.
1047 void CaptureOpenPanel::updateButtons()
1049 /* Be sure to display the ui Elements in case they were hidden by
1050 * some Device Type (like Screen://) */
1051 ui.optionsBox->show();
1052 ui.advancedButton->show();
1053 /* Get the current Device Number */
1054 int i_devicetype = ui.deviceCombo->itemData(
1055 ui.deviceCombo->currentIndex() ).toInt();
1056 switch( i_devicetype )
1060 if( bdas->isChecked() || bdac->isChecked() )
1063 bdaSrateLabel->show();
1065 bdaBandLabel->hide();
1070 bdaSrateLabel->hide();
1072 bdaBandLabel->show();
1077 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1078 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1082 ui.optionsBox->hide();
1083 ui.advancedButton->hide();
1090 void CaptureOpenPanel::advancedDialog()
1092 /* Get selected device type */
1093 int i_devicetype = ui.deviceCombo->itemData(
1094 ui.deviceCombo->currentIndex() ).toInt();
1096 /* Get the corresponding module */
1097 module_t *p_module =
1098 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1099 if( NULL == p_module ) return;
1102 QList<ConfigControl *> controls;
1104 /* Get the confsize */
1105 unsigned int i_confsize;
1106 module_config_t *p_config;
1107 p_config = module_GetConfig( p_module, &i_confsize );
1109 /* New Adv Prop dialog */
1110 adv = new QDialog( this );
1111 adv->setWindowTitle( qtr( "Advanced Options" ) );
1113 /* A main Layout with a Frame */
1114 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1115 QFrame *advFrame = new QFrame;
1116 QScrollArea *scroll = new QScrollArea;
1117 mainLayout->addWidget( scroll );
1119 /* GridLayout inside the Frame */
1120 QGridLayout *gLayout = new QGridLayout( advFrame );
1121 gLayout->setSizeConstraint( QLayout::SetFixedSize );
1123 scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
1124 scroll->setWidgetResizable( true );
1125 scroll->setWidget( advFrame );
1127 /* Create the options inside the FrameLayout */
1128 for( int n = 0; n < i_confsize; n++ )
1130 module_config_t *p_item = p_config + n;
1131 ConfigControl *config = ConfigControl::createControl(
1132 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1133 controls.append( config );
1137 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1138 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1139 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1141 CONNECT( closeButton, clicked(), adv, accept() );
1142 CONNECT( cancelButton, clicked(), adv, reject() );
1144 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1145 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1147 mainLayout->addWidget( advButtonBox );
1149 /* Creation of the MRL */
1152 QString tempMRL = "";
1153 for( int i = 0; i < controls.size(); i++ )
1155 ConfigControl *control = controls[i];
1158 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1162 tempMRL += (i ? " :" : ":");
1164 if( control->getType() == CONFIG_ITEM_BOOL )
1165 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1168 tempMRL += control->getName();
1170 switch( control->getType() )
1172 case CONFIG_ITEM_STRING:
1173 case CONFIG_ITEM_FILE:
1174 case CONFIG_ITEM_DIRECTORY:
1175 case CONFIG_ITEM_MODULE:
1176 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1178 case CONFIG_ITEM_INTEGER:
1179 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1181 case CONFIG_ITEM_FLOAT:
1182 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1188 msg_Dbg( p_intf, "%s", qtu( advMRL ) );