1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
5 * Copyright (C) 2007 Société des arts technologiques
6 * Copyright (C) 2007 Savoir-faire Linux
10 * Authors: Clément Stenac <zorglub@videolan.org>
11 * Jean-Baptiste Kempf <jb@videolan.org>
12 * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 *****************************************************************************/
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 /**************************************************************************
49 * Open Files and subtitles *
50 **************************************************************************/
51 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
52 OpenPanel( _parent, _p_intf )
54 /* Classic UI Setup */
57 /** BEGIN QFileDialog tweaking **/
58 /* Use a QFileDialog and customize it because we don't want to
59 rewrite it all. Be careful to your eyes cause there are a few hacks.
60 Be very careful and test correctly when you modify this. */
62 /* Set Filters for file selection */
63 QString fileTypes = "";
64 ADD_FILTER_MEDIA( fileTypes );
65 ADD_FILTER_VIDEO( fileTypes );
66 ADD_FILTER_AUDIO( fileTypes );
67 ADD_FILTER_PLAYLIST( fileTypes );
68 ADD_FILTER_ALL( fileTypes );
69 fileTypes.replace( QString(";*"), QString(" *"));
71 // Make this QFileDialog a child of tempWidget from the ui.
72 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
73 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
75 dialogBox->setFileMode( QFileDialog::ExistingFiles );
76 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
77 dialogBox->setViewMode( config_GetInt( p_intf, "qt-open-detail" ) ?
78 QFileDialog::Detail : QFileDialog::List );
80 /* We don't want to see a grip in the middle of the window, do we? */
81 dialogBox->setSizeGripEnabled( false );
84 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
86 // But hide the two OK/Cancel buttons. Enable them for debug.
87 QDialogButtonBox *fileDialogAcceptBox =
88 dialogBox->findChildren<QDialogButtonBox*>()[0];
89 fileDialogAcceptBox->hide();
91 /* Ugly hacks to get the good Widget */
92 //This lineEdit is the normal line in the fileDialog.
94 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
96 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
98 /* Make a list of QLabel inside the QFileDialog to access the good ones */
99 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
101 /* Hide the FileNames one. Enable it for debug */
102 listLabel[1]->setText( qtr( "File names:" ) );
103 /* Change the text that was uncool in the usual box */
104 listLabel[2]->setText( qtr( "Filter:" ) );
106 dialogBox->layout()->setMargin( 0 );
107 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
109 /** END of QFileDialog tweaking **/
111 // Add the DialogBox to the layout
112 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
114 //TODO later: fill the fileCompleteList with previous items played.
115 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
116 fileCompleter->setModel( new QDirModel( fileCompleter ) );
117 lineFileEdit->setCompleter( fileCompleter );
119 // Hide the subtitles control by default.
122 /* Build the subs size combo box */
123 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
124 ui.sizeSubComboBox );
126 /* Build the subs align combo box */
127 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
130 BUTTONACT( ui.subBrowseButton, browseFileSub() );
131 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
133 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
134 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
135 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
136 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
139 FileOpenPanel::~FileOpenPanel()
143 /* Show a fileBrowser to select a subtitle */
144 void FileOpenPanel::browseFileSub()
146 // TODO Handle selection of more than one subtitles file
147 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
149 dialogBox->directory().absolutePath() );
150 if( files.isEmpty() ) return;
151 ui.subInput->setText( files.join(" ") );
155 /* Update the current MRL */
156 void FileOpenPanel::updateMRL()
159 foreach( QString file, dialogBox->selectedFiles() ) {
160 mrl += "\"" + file + "\" ";
163 if( ui.subCheckBox->isChecked() ) {
164 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
165 int align = ui.alignSubComboBox->itemData(
166 ui.alignSubComboBox->currentIndex() ).toInt();
167 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
168 int size = ui.sizeSubComboBox->itemData(
169 ui.sizeSubComboBox->currentIndex() ).toInt();
170 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
173 emit mrlUpdated( mrl );
174 emit methodChanged( "file-caching" );
177 /* Function called by Open Dialog when clicke on Play/Enqueue */
178 void FileOpenPanel::accept()
180 //TODO set the completer
181 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
184 void FileOpenBox::accept()
186 OpenDialog::getInstance( NULL, NULL )->play();
189 /* Function called by Open Dialog when clicked on cancel */
190 void FileOpenPanel::clear()
192 lineFileEdit->clear();
193 ui.subInput->clear();
196 void FileOpenPanel::toggleSubtitleFrame()
198 TOGGLEV( ui.subFrame );
204 /**************************************************************************
205 * Open Discs ( DVD, CD, VCD and similar devices ) *
206 **************************************************************************/
207 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
208 OpenPanel( _parent, _p_intf )
212 /* Get the default configuration path for the devices */
213 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
214 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
215 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
217 /* State to avoid overwritting the users changes with the configuration */
222 #if WIN32 /* Disc drives probing for Windows */
225 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
227 char *drive = szDrives;
228 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
231 if( GetDriveTypeA(drive) == DRIVE_CDROM )
232 ui.deviceCombo->addItem( drive );
234 /* go to next drive */
237 SetErrorMode(oldMode);
239 #else /* Use a Completer under Linux */
240 QCompleter *discCompleter = new QCompleter( this );
241 discCompleter->setModel( new QDirModel( discCompleter ) );
242 ui.deviceCombo->setCompleter( discCompleter );
246 BUTTONACT( ui.dvdRadioButton, updateButtons() );
247 BUTTONACT( ui.vcdRadioButton, updateButtons() );
248 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
249 BUTTONACT( ui.dvdsimple, updateButtons() );
250 BUTTONACT( ui.browseDiscButton, browseDevice() );
251 BUTTONACT( ui.ejectButton, eject() );
253 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
254 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
255 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
256 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
257 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
259 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
263 DiscOpenPanel::~DiscOpenPanel()
265 delete psz_dvddiscpath;
266 delete psz_vcddiscpath;
267 delete psz_cddadiscpath;
270 void DiscOpenPanel::clear()
272 ui.titleSpin->setValue( 0 );
273 ui.chapterSpin->setValue( 0 );
280 #define setDrive( psz_name ) {\
281 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
282 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
284 #define setDrive( psz_name ) {\
285 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
288 /* update the buttons according the type of device */
289 void DiscOpenPanel::updateButtons()
291 if ( ui.dvdRadioButton->isChecked() )
295 setDrive( psz_dvddiscpath );
298 ui.titleLabel->setText( qtr("Title") );
299 ui.chapterLabel->show();
300 ui.chapterSpin->show();
301 ui.diskOptionBox_2->show();
302 ui.dvdsimple->setEnabled( true );
304 else if ( ui.vcdRadioButton->isChecked() )
308 setDrive( psz_vcddiscpath );
311 ui.titleLabel->setText( qtr("Entry") );
312 ui.chapterLabel->hide();
313 ui.chapterSpin->hide();
314 ui.diskOptionBox_2->show();
315 ui.dvdsimple->setEnabled( false );
321 setDrive( psz_cddadiscpath );
324 ui.titleLabel->setText( qtr("Track") );
325 ui.chapterLabel->hide();
326 ui.chapterSpin->hide();
327 ui.diskOptionBox_2->hide();
328 ui.dvdsimple->setEnabled( false );
334 /* Update the current MRL */
335 void DiscOpenPanel::updateMRL()
339 /* CDDAX and VCDX not implemented. TODO ? */
341 if( ui.dvdRadioButton->isChecked() ) {
342 if( !ui.dvdsimple->isChecked() )
345 mrl = "\"dvdsimple://";
346 mrl += ui.deviceCombo->currentText();
347 emit methodChanged( "dvdnav-caching" );
349 if ( ui.titleSpin->value() > 0 ) {
350 mrl += QString("@%1").arg( ui.titleSpin->value() );
351 if ( ui.chapterSpin->value() > 0 ) {
352 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
357 } else if ( ui.vcdRadioButton->isChecked() ) {
358 mrl = "\"vcd://" + ui.deviceCombo->currentText();
359 emit methodChanged( "vcd-caching" );
361 if( ui.titleSpin->value() > 0 ) {
362 mrl += QString("@E%1").arg( ui.titleSpin->value() );
367 mrl = "\"cdda://" + ui.deviceCombo->currentText();
368 if( ui.titleSpin->value() > 0 ) {
369 QString("@%1").arg( ui.titleSpin->value() );
375 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
377 if ( ui.audioSpin->value() >= 0 ) {
378 mrl += " :audio-track=" +
379 QString("%1").arg( ui.audioSpin->value() );
381 if ( ui.subtitlesSpin->value() >= 0 ) {
382 mrl += " :sub-track=" +
383 QString("%1").arg( ui.subtitlesSpin->value() );
386 emit mrlUpdated( mrl );
389 void DiscOpenPanel::browseDevice()
391 QString dir = QFileDialog::getExistingDirectory( 0,
392 qtr("Open a device or a VIDEO_TS directory") );
393 if (!dir.isEmpty()) {
394 ui.deviceCombo->setEditText( dir );
399 void DiscOpenPanel::eject()
401 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
404 void DiscOpenPanel::accept()
407 /**************************************************************************
408 * Open Network streams and URL pages *
409 **************************************************************************/
410 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
411 OpenPanel( _parent, _p_intf )
416 CONNECT( ui.protocolCombo, activated( int ),
417 this, updateProtocol( int ) );
418 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
419 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
420 CONNECT( ui.timeShift, clicked(), this, updateMRL());
421 CONNECT( ui.ipv6, clicked(), this, updateMRL());
423 ui.protocolCombo->addItem( "" );
424 ui.protocolCombo->addItem("HTTP", QVariant("http"));
425 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
426 ui.protocolCombo->addItem("MMS", QVariant("mms"));
427 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
428 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
429 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
430 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
431 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
433 updateProtocol( ui.protocolCombo->currentIndex() );
436 NetOpenPanel::~NetOpenPanel()
439 void NetOpenPanel::clear()
442 /* update the widgets according the type of protocol */
443 void NetOpenPanel::updateProtocol( int idx_proto ) {
444 QString addr = ui.addressText->text();
445 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
447 ui.timeShift->setEnabled( idx_proto == UDP_PROTO ||
448 idx_proto == UDPM_PROTO );
449 ui.ipv6->setEnabled( idx_proto == UDP_PROTO );
450 ui.addressText->setEnabled( idx_proto != UDP_PROTO );
451 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
452 idx_proto == UDPM_PROTO );
454 if( idx_proto == NO_PROTO ) return;
456 /* If we already have a protocol in the address, replace it */
457 if( addr.contains( "://"))
459 if( idx_proto != UDPM_PROTO )
460 addr.replace( QRegExp("^.*://@*"), proto + "://");
462 addr.replace( QRegExp("^.*://"), proto + "://@");
463 ui.addressText->setText( addr );
468 void NetOpenPanel::updateMRL() {
470 QString addr = ui.addressText->text();
471 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
472 int idx_proto = ui.protocolCombo->currentIndex();
474 if( addr.contains( "://"))
476 /* Match the correct item in the comboBox */
477 ui.protocolCombo->setCurrentIndex(
478 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
480 if( idx_proto != UDP_PROTO || idx_proto != UDPM_PROTO )
485 switch( idx_proto ) {
487 mrl = "http://" + addr;
488 emit methodChanged("http-caching");
491 mrl = "https://" + addr;
492 emit methodChanged("http-caching");
495 mrl = "mms://" + addr;
496 emit methodChanged("mms-caching");
499 mrl = "ftp://" + addr;
500 emit methodChanged("ftp-caching");
503 mrl = "rtsp://" + addr;
504 emit methodChanged("rtsp-caching");
508 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() )
512 mrl += QString(":%1").arg( ui.portSpin->value() );
513 emit methodChanged("udp-caching");
515 case UDPM_PROTO: /* UDP multicast */
518 if ( addr.contains(':') && !addr.contains('[') )
520 mrl += "[" + addr + "]";
523 mrl += QString(":%1").arg( ui.portSpin->value() );
524 emit methodChanged("udp-caching");
527 mrl = "rtmp://" + addr;
528 emit methodChanged("rtmp-caching");
533 // Encode the boring stuffs
535 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
536 mrl += " :access-filter=timeshift";
538 emit mrlUpdated( mrl );
541 /**************************************************************************
542 * Open Capture device ( DVB, PVR, V4L, and similar ) *
543 **************************************************************************/
544 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
545 OpenPanel( _parent, _p_intf )
549 BUTTONACT( ui.advancedButton, advancedDialog() );
551 /* Create two stacked layouts in the main comboBoxes */
552 QStackedLayout *stackedDevLayout = new QStackedLayout;
553 ui.cardBox->setLayout( stackedDevLayout );
555 QStackedLayout *stackedPropLayout = new QStackedLayout;
556 ui.optionsBox->setLayout( stackedPropLayout );
558 /* Creation and connections of the WIdgets in the stacked layout */
559 #define addModuleAndLayouts( number, name, label ) \
560 QWidget * name ## DevPage = new QWidget( this ); \
561 QWidget * name ## PropPage = new QWidget( this ); \
562 stackedDevLayout->addWidget( name ## DevPage ); \
563 stackedPropLayout->addWidget( name ## PropPage ); \
564 QGridLayout * name ## DevLayout = new QGridLayout; \
565 QGridLayout * name ## PropLayout = new QGridLayout; \
566 name ## DevPage->setLayout( name ## DevLayout ); \
567 name ## PropPage->setLayout( name ## PropLayout ); \
568 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
570 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
573 /*********************
574 * DirectShow Stuffs *
575 *********************/
576 if( module_Exists( p_intf, "dshow" ) ){
577 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
581 module_config_t *p_config =
582 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
583 vdevDshowW = new StringListConfigControl(
584 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
587 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
588 adevDshowW = new StringListConfigControl(
589 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
592 /* dshow Properties */
593 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
594 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
596 dshowVSizeLine = new QLineEdit;
597 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
598 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
602 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
603 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
604 CuMRL( dshowVSizeLine, textChanged( QString ) );
610 if( module_Exists( p_intf, "bda" ) ){
611 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
614 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
616 bdas = new QRadioButton( "DVB-S" );
617 bdas->setChecked( true );
618 bdac = new QRadioButton( "DVB-C" );
619 bdat = new QRadioButton( "DVB-T" );
621 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
622 bdaDevLayout->addWidget( bdas, 0, 1 );
623 bdaDevLayout->addWidget( bdac, 0, 2 );
624 bdaDevLayout->addWidget( bdat, 0, 3 );
627 QLabel *bdaFreqLabel =
628 new QLabel( qtr( "Transponder/multiplex frequency" ) );
629 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
631 bdaFreq = new QSpinBox;
632 bdaFreq->setAlignment( Qt::AlignRight );
633 bdaFreq->setSuffix(" kHz");
634 bdaFreq->setSingleStep( 1000 );
635 setSpinBoxFreq( bdaFreq )
636 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
638 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
639 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
641 bdaSrate = new QSpinBox;
642 bdaSrate->setAlignment( Qt::AlignRight );
643 bdaSrate->setSuffix(" kHz");
644 setSpinBoxFreq( bdaSrate );
645 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
647 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
648 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
650 bdaBandBox = new QComboBox;
651 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
652 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
654 bdaBandLabel->hide();
656 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
660 CuMRL( bdaFreq, valueChanged ( int ) );
661 CuMRL( bdaSrate, valueChanged ( int ) );
662 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
663 BUTTONACT( bdas, updateButtons() );
664 BUTTONACT( bdat, updateButtons() );
665 BUTTONACT( bdac, updateButtons() );
666 BUTTONACT( bdas, updateMRL() );
667 BUTTONACT( bdat, updateMRL() );
668 BUTTONACT( bdac, updateMRL() );
675 if( module_Exists( p_intf, "v4l2" ) ){
676 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
679 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
680 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
682 v4l2VideoDevice = new QLineEdit;
683 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
685 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
686 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
688 v4l2AudioDevice = new QLineEdit;
689 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
691 /* v4l2 Props panel */
692 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
693 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
695 v4l2StdBox = new QComboBox;
696 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
697 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
698 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
702 CuMRL( v4l2VideoDevice, textChanged( QString ) );
703 CuMRL( v4l2AudioDevice, textChanged( QString ) );
704 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
710 if( module_Exists( p_intf, "v4l" ) ){
711 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
714 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
715 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
717 v4lVideoDevice = new QLineEdit;
718 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
720 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
721 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
723 v4lAudioDevice = new QLineEdit;
724 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
726 /* V4l Props panel */
727 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
728 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
730 v4lNormBox = new QComboBox;
731 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
732 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
734 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
735 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
737 v4lFreq = new QSpinBox;
738 v4lFreq->setAlignment( Qt::AlignRight );
739 v4lFreq->setSuffix(" kHz");
740 setSpinBoxFreq( v4lFreq );
741 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
742 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
746 CuMRL( v4lVideoDevice, textChanged( QString ) );
747 CuMRL( v4lAudioDevice, textChanged( QString ) );
748 CuMRL( v4lFreq, valueChanged ( int ) );
749 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
755 if( module_Exists( p_intf, "jack" ) ){
756 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
758 /* Jack Main panel */
760 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
761 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
763 jackChannels = new QSpinBox;
764 setSpinBoxFreq( jackChannels );
765 jackChannels->setMaximum(255);
766 jackChannels->setValue(2);
767 jackChannels->setAlignment( Qt::AlignRight );
768 jackDevLayout->addWidget( jackChannels, 1, 1 );
770 /* Jack Props panel */
773 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
774 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
776 jackPortsSelected = new QLineEdit( qtr( ".*") );
777 jackPortsSelected->setAlignment( Qt::AlignRight );
778 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
781 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
782 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
783 jackCaching = new QSpinBox;
784 setSpinBoxFreq( jackCaching );
785 jackCaching->setSuffix( " ms" );
786 jackCaching->setValue(1000);
787 jackCaching->setAlignment( Qt::AlignRight );
788 jackPropLayout->addWidget( jackCaching, 1 , 1 );
791 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
792 jackPropLayout->addWidget( jackPace, 2, 1 );
795 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
796 jackPropLayout->addWidget( jackConnect, 3, 1 );
799 CuMRL( jackChannels, valueChanged( int ) );
800 CuMRL( jackCaching, valueChanged( int ) );
801 CuMRL( jackPace, stateChanged( int ) );
802 CuMRL( jackConnect, stateChanged( int ) );
803 CuMRL( jackPortsSelected, textChanged( QString ) );
809 if( module_Exists( p_intf, "pvr" ) ){
810 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
813 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
814 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
816 pvrDevice = new QLineEdit;
817 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
819 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
820 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
822 pvrRadioDevice = new QLineEdit;
823 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
825 /* PVR props panel */
826 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
827 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
829 pvrNormBox = new QComboBox;
830 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
831 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
833 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
834 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
836 pvrFreq = new QSpinBox;
837 pvrFreq->setAlignment( Qt::AlignRight );
838 pvrFreq->setSuffix(" kHz");
839 setSpinBoxFreq( pvrFreq );
840 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
842 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
843 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
845 pvrBitr = new QSpinBox;
846 pvrBitr->setAlignment( Qt::AlignRight );
847 pvrBitr->setSuffix(" kHz");
848 setSpinBoxFreq( pvrBitr );
849 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
850 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
854 CuMRL( pvrDevice, textChanged( QString ) );
855 CuMRL( pvrRadioDevice, textChanged( QString ) );
857 CuMRL( pvrFreq, valueChanged ( int ) );
858 CuMRL( pvrBitr, valueChanged ( int ) );
859 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
865 if( module_Exists( p_intf, "dvb" ) ){
866 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
869 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
870 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
872 dvbCard = new QSpinBox;
873 dvbCard->setAlignment( Qt::AlignRight );
874 dvbCard->setPrefix( "/dev/dvb/adapter" );
876 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
877 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
879 dvbs = new QRadioButton( "DVB-S" );
880 dvbs->setChecked( true );
881 dvbc = new QRadioButton( "DVB-C" );
882 dvbt = new QRadioButton( "DVB-T" );
884 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
885 dvbDevLayout->addWidget( dvbs, 1, 1 );
886 dvbDevLayout->addWidget( dvbc, 1, 2 );
887 dvbDevLayout->addWidget( dvbt, 1, 3 );
889 /* DVB Props panel */
890 QLabel *dvbFreqLabel =
891 new QLabel( qtr( "Transponder/multiplex frequency" ) );
892 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
894 dvbFreq = new QSpinBox;
895 dvbFreq->setAlignment( Qt::AlignRight );
896 dvbFreq->setSuffix(" kHz");
897 setSpinBoxFreq( dvbFreq );
898 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
900 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
901 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
903 dvbSrate = new QSpinBox;
904 dvbSrate->setAlignment( Qt::AlignRight );
905 dvbSrate->setSuffix(" kHz");
906 setSpinBoxFreq( dvbSrate );
907 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
908 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
912 CuMRL( dvbCard, valueChanged ( int ) );
913 CuMRL( dvbFreq, valueChanged ( int ) );
914 CuMRL( dvbSrate, valueChanged ( int ) );
916 BUTTONACT( dvbs, updateButtons() );
917 BUTTONACT( dvbt, updateButtons() );
918 BUTTONACT( dvbc, updateButtons() );
927 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
928 QLabel *screenLabel = new QLabel( "This option will open your own "
929 "desktop in order to save or stream it.");
930 screenLabel->setWordWrap( true );
931 screenDevLayout->addWidget( screenLabel, 0, 0 );
933 /* General connects */
934 CONNECT( ui.deviceCombo, activated( int ) ,
935 stackedDevLayout, setCurrentIndex( int ) );
936 CONNECT( ui.deviceCombo, activated( int ),
937 stackedPropLayout, setCurrentIndex( int ) );
938 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
939 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
944 CaptureOpenPanel::~CaptureOpenPanel()
948 void CaptureOpenPanel::clear()
953 void CaptureOpenPanel::updateMRL()
956 int i_devicetype = ui.deviceCombo->itemData(
957 ui.deviceCombo->currentIndex() ).toInt();
958 switch( i_devicetype )
962 if( bdas->isChecked() ) mrl = "dvb-s://";
963 else if( bdat->isChecked() ) mrl = "dvb-t://";
964 else if( bdac->isChecked() ) mrl = "dvb-c://";
966 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
967 if( bdas->isChecked() || bdac->isChecked() )
968 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
970 mrl += " :dvb-bandwidth=" +
971 QString("%1").arg( bdaBandBox->itemData(
972 bdaBandBox->currentIndex() ).toInt() );
976 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
977 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
978 if( dshowVSizeLine->isModified() )
979 mrl += " :dshow-size=" + dshowVSizeLine->text();
984 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
985 mrl += " :v4l-adev=" + v4lAudioDevice->text();
986 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
987 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
991 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
992 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
993 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
997 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
998 mrl += ":ports=" + jackPortsSelected->text();
999 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1000 if ( jackPace->isChecked() )
1002 mrl += " --jack-input-use-vlc-pace";
1004 if ( jackConnect->isChecked() )
1006 mrl += " --jack-input-auto-connect";
1011 mrl += " :pvr-device=" + pvrDevice->text();
1012 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1013 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1014 if( pvrFreq->value() )
1015 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1016 if( pvrBitr->value() )
1017 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1021 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1022 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1023 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1032 if( !advMRL.isEmpty() ) mrl += advMRL;
1034 emit mrlUpdated( mrl );
1038 * Update the Buttons (show/hide) for the GUI as all device type don't
1039 * use the same ui. elements.
1041 void CaptureOpenPanel::updateButtons()
1043 /* Be sure to display the ui Elements in case they were hidden by
1044 * some Device Type (like Screen://) */
1045 ui.optionsBox->show();
1046 ui.advancedButton->show();
1047 /* Get the current Device Number */
1048 int i_devicetype = ui.deviceCombo->itemData(
1049 ui.deviceCombo->currentIndex() ).toInt();
1050 switch( i_devicetype )
1054 if( bdas->isChecked() || bdac->isChecked() )
1057 bdaSrateLabel->show();
1059 bdaBandLabel->hide();
1064 bdaSrateLabel->hide();
1066 bdaBandLabel->show();
1071 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1072 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1076 ui.optionsBox->hide();
1077 ui.advancedButton->hide();
1084 void CaptureOpenPanel::advancedDialog()
1086 /* Get selected device type */
1087 int i_devicetype = ui.deviceCombo->itemData(
1088 ui.deviceCombo->currentIndex() ).toInt();
1090 /* Get the corresponding module */
1091 module_t *p_module =
1092 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1093 if( NULL == p_module ) return;
1096 QList<ConfigControl *> controls;
1098 /* Get the confsize */
1099 unsigned int i_confsize;
1100 module_config_t *p_config;
1101 p_config = module_GetConfig( p_module, &i_confsize );
1103 /* New Adv Prop dialog */
1104 adv = new QDialog( this );
1105 adv->setWindowTitle( qtr( "Advanced Options" ) );
1107 /* A main Layout with a Frame */
1108 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1109 QFrame *advFrame = new QFrame;
1110 QScrollArea *scroll = new QScrollArea;
1111 mainLayout->addWidget( scroll );
1113 /* GridLayout inside the Frame */
1114 QGridLayout *gLayout = new QGridLayout( advFrame );
1115 gLayout->setSizeConstraint( QLayout::SetFixedSize );
1117 scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
1118 scroll->setWidgetResizable( true );
1119 scroll->setWidget( advFrame );
1121 /* Create the options inside the FrameLayout */
1122 for( int n = 0; n < i_confsize; n++ )
1124 module_config_t *p_item = p_config + n;
1125 ConfigControl *config = ConfigControl::createControl(
1126 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1127 controls.append( config );
1131 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1132 QPushButton *closeButton = new QPushButton( qtr( "Ok" ) );
1133 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1135 CONNECT( closeButton, clicked(), adv, accept() );
1136 CONNECT( cancelButton, clicked(), adv, reject() );
1138 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1139 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1141 mainLayout->addWidget( advButtonBox );
1143 /* Creation of the MRL */
1146 QString tempMRL = "";
1147 for( int i = 0; i < controls.size(); i++ )
1149 ConfigControl *control = controls[i];
1152 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1156 tempMRL += (i ? " :" : ":");
1158 if( control->getType() == CONFIG_ITEM_BOOL )
1159 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1162 tempMRL += control->getName();
1164 switch( control->getType() )
1166 case CONFIG_ITEM_STRING:
1167 case CONFIG_ITEM_FILE:
1168 case CONFIG_ITEM_DIRECTORY:
1169 case CONFIG_ITEM_MODULE:
1170 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1172 case CONFIG_ITEM_INTEGER:
1173 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1175 case CONFIG_ITEM_FLOAT:
1176 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1182 msg_Dbg( p_intf, "%s", qtu( advMRL ) );