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" /* Open Subtitle file */
37 #include "util/qt_dirs.hpp"
39 #include <QFileDialog>
40 #include <QDialogButtonBox>
42 #include <QStackedLayout>
46 #include <QScrollArea>
48 #include <QStringListModel>
50 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
52 static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
53 "dshow", "screen", "jack" };
55 /**************************************************************************
56 * Open Files and subtitles *
57 **************************************************************************/
58 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
59 OpenPanel( _parent, _p_intf )
61 /* Classic UI Setup */
64 /** BEGIN QFileDialog tweaking **/
65 /* Use a QFileDialog and customize it because we don't want to
66 rewrite it all. Be careful to your eyes cause there are a few hacks.
67 Be very careful and test correctly when you modify this. */
69 /* Set Filters for file selection */
70 QString fileTypes = "";
71 ADD_FILTER_MEDIA( fileTypes );
72 ADD_FILTER_VIDEO( fileTypes );
73 ADD_FILTER_AUDIO( fileTypes );
74 ADD_FILTER_PLAYLIST( fileTypes );
75 ADD_FILTER_ALL( fileTypes );
76 fileTypes.replace( QString(";*"), QString(" *"));
78 // Make this QFileDialog a child of tempWidget from the ui.
79 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
80 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
82 dialogBox->setFileMode( QFileDialog::ExistingFiles );
83 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
84 dialogBox->restoreState(
85 getSettings()->value( "file-dialog-state" ).toByteArray() );
87 /* We don't want to see a grip in the middle of the window, do we? */
88 dialogBox->setSizeGripEnabled( false );
91 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
92 dialogBox->setMinimumHeight( 250 );
94 // But hide the two OK/Cancel buttons. Enable them for debug.
95 QDialogButtonBox *fileDialogAcceptBox =
96 dialogBox->findChildren<QDialogButtonBox*>()[0];
97 fileDialogAcceptBox->hide();
99 /* Ugly hacks to get the good Widget */
100 //This lineEdit is the normal line in the fileDialog.
101 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
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()
145 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
148 /* Show a fileBrowser to select a subtitle */
149 void FileOpenPanel::browseFileSub()
151 // TODO Handle selection of more than one subtitles file
152 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
154 dialogBox->directory().absolutePath() );
155 if( files.isEmpty() ) return;
156 ui.subInput->setText( files.join(" ") );
160 /* Update the current MRL */
161 void FileOpenPanel::updateMRL()
164 foreach( const QString &file, dialogBox->selectedFiles() ) {
165 mrl += "\"" + file + "\" ";
168 if( ui.subCheckBox->isChecked() ) {
169 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
170 int align = ui.alignSubComboBox->itemData(
171 ui.alignSubComboBox->currentIndex() ).toInt();
172 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
173 int size = ui.sizeSubComboBox->itemData(
174 ui.sizeSubComboBox->currentIndex() ).toInt();
175 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
178 emit mrlUpdated( mrl );
179 emit methodChanged( "file-caching" );
182 /* Function called by Open Dialog when clicke on Play/Enqueue */
183 void FileOpenPanel::accept()
185 //TODO set the completer
186 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
189 void FileOpenBox::accept()
191 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
194 void FileOpenBox::reject()
196 OpenDialog::getInstance( NULL, NULL, true )->cancel();
199 /* Function called by Open Dialog when clicked on cancel */
200 void FileOpenPanel::clear()
202 lineFileEdit->clear();
203 ui.subInput->clear();
206 void FileOpenPanel::toggleSubtitleFrame()
208 TOGGLEV( ui.subFrame );
214 /**************************************************************************
215 * Open Discs ( DVD, CD, VCD and similar devices ) *
216 **************************************************************************/
217 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
218 OpenPanel( _parent, _p_intf )
222 /* Get the default configuration path for the devices */
223 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
224 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
225 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
227 /* State to avoid overwritting the users changes with the configuration */
232 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
233 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
235 #ifdef WIN32 /* Disc drives probing for Windows */
238 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
240 char *drive = szDrives;
241 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
244 if( GetDriveTypeA(drive) == DRIVE_CDROM )
245 ui.deviceCombo->addItem( drive );
247 /* go to next drive */
250 SetErrorMode(oldMode);
252 #else /* Use a Completer under Linux */
253 QCompleter *discCompleter = new QCompleter( this );
254 discCompleter->setModel( new QDirModel( discCompleter ) );
255 ui.deviceCombo->setCompleter( discCompleter );
259 BUTTONACT( ui.dvdRadioButton, updateButtons() );
260 BUTTONACT( ui.vcdRadioButton, updateButtons() );
261 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
262 BUTTONACT( ui.dvdsimple, updateButtons() );
263 BUTTONACT( ui.browseDiscButton, browseDevice() );
264 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
267 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
268 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
269 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
270 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
271 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
273 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
277 DiscOpenPanel::~DiscOpenPanel()
279 free( psz_dvddiscpath );
280 free( psz_vcddiscpath );
281 free( psz_cddadiscpath );
284 void DiscOpenPanel::clear()
286 ui.titleSpin->setValue( 0 );
287 ui.chapterSpin->setValue( 0 );
294 #define setDrive( psz_name ) {\
295 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
296 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
298 #define setDrive( psz_name ) {\
299 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
302 /* update the buttons according the type of device */
303 void DiscOpenPanel::updateButtons()
305 if ( ui.dvdRadioButton->isChecked() )
309 setDrive( psz_dvddiscpath );
312 ui.titleLabel->setText( qtr("Title") );
313 ui.chapterLabel->show();
314 ui.chapterSpin->show();
315 ui.diskOptionBox_2->show();
316 ui.dvdsimple->setEnabled( true );
318 else if ( ui.vcdRadioButton->isChecked() )
322 setDrive( psz_vcddiscpath );
325 ui.titleLabel->setText( qtr("Entry") );
326 ui.chapterLabel->hide();
327 ui.chapterSpin->hide();
328 ui.diskOptionBox_2->show();
329 ui.dvdsimple->setEnabled( false );
335 setDrive( psz_cddadiscpath );
338 ui.titleLabel->setText( qtr("Track") );
339 ui.chapterLabel->hide();
340 ui.chapterSpin->hide();
341 ui.diskOptionBox_2->hide();
342 ui.dvdsimple->setEnabled( false );
348 /* Update the current MRL */
349 void DiscOpenPanel::updateMRL()
353 /* CDDAX and VCDX not implemented. TODO ? */
355 if( ui.dvdRadioButton->isChecked() ) {
356 if( !ui.dvdsimple->isChecked() )
359 mrl = "\"dvdsimple://";
360 mrl += ui.deviceCombo->currentText();
361 emit methodChanged( "dvdnav-caching" );
363 if ( ui.titleSpin->value() > 0 ) {
364 mrl += QString("@%1").arg( ui.titleSpin->value() );
365 if ( ui.chapterSpin->value() > 0 ) {
366 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
371 } else if ( ui.vcdRadioButton->isChecked() ) {
372 mrl = "\"vcd://" + ui.deviceCombo->currentText();
373 emit methodChanged( "vcd-caching" );
375 if( ui.titleSpin->value() > 0 ) {
376 mrl += QString("@E%1").arg( ui.titleSpin->value() );
381 mrl = "\"cdda://" + ui.deviceCombo->currentText();
382 if( ui.titleSpin->value() > 0 ) {
383 QString("@%1").arg( ui.titleSpin->value() );
389 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
391 if ( ui.audioSpin->value() >= 0 ) {
392 mrl += " :audio-track=" +
393 QString("%1").arg( ui.audioSpin->value() );
395 if ( ui.subtitlesSpin->value() >= 0 ) {
396 mrl += " :sub-track=" +
397 QString("%1").arg( ui.subtitlesSpin->value() );
400 emit mrlUpdated( mrl );
403 void DiscOpenPanel::browseDevice()
405 QString dir = QFileDialog::getExistingDirectory( this,
406 qtr( I_DEVICE_TOOLTIP ) );
408 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
413 void DiscOpenPanel::eject()
415 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
418 void DiscOpenPanel::accept()
421 /**************************************************************************
422 * Open Network streams and URL pages *
423 **************************************************************************/
424 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
425 OpenPanel( _parent, _p_intf )
430 CONNECT( ui.protocolCombo, activated( int ),
431 this, updateProtocol( int ) );
432 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
433 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
434 CONNECT( ui.timeShift, clicked(), this, updateMRL());
436 ui.protocolCombo->addItem( "" );
437 ui.protocolCombo->addItem("HTTP", QVariant("http"));
438 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
439 ui.protocolCombo->addItem("MMS", QVariant("mms"));
440 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
441 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
442 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
443 ui.protocolCombo->addItem("UDP", QVariant("udp"));
444 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
446 updateProtocol( ui.protocolCombo->currentIndex() );
448 if( config_GetInt( p_intf, "qt-recentplay" ) )
450 mrlList = new QStringListModel(
451 getSettings()->value( "Open/netMRL" ).toStringList() );
452 QCompleter *completer = new QCompleter( mrlList, this );
453 ui.addressText->setCompleter( completer );
455 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
461 NetOpenPanel::~NetOpenPanel()
463 if( !mrlList ) return;
465 QStringList tempL = mrlList->stringList();
466 while( tempL.size() > 8 ) tempL.removeFirst();
468 getSettings()->setValue( "Open/netMRL", tempL );
471 void NetOpenPanel::clear()
474 /* update the widgets according the type of protocol */
475 void NetOpenPanel::updateProtocol( int idx_proto ) {
476 QString addr = ui.addressText->text();
477 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
479 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
480 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
481 idx_proto == RTP_PROTO );
483 if( idx_proto == NO_PROTO ) return;
485 /* If we already have a protocol in the address, replace it */
486 if( addr.contains( "://"))
488 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
489 addr.replace( QRegExp("^.*://@*"), proto + "://");
490 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
491 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
492 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
493 addr.replace( QRegExp("^.*://"), proto + "://@");
495 addr.replace( QRegExp("^.*://"), proto + "://");
496 addr.replace( QRegExp("@+"), "@");
497 ui.addressText->setText( addr );
502 void NetOpenPanel::updateMRL() {
504 QString addr = ui.addressText->text();
505 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
506 int idx_proto = ui.protocolCombo->currentIndex();
507 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
508 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
509 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
510 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
511 if( addr.contains( "://"))
513 /* Match the correct item in the comboBox */
514 ui.protocolCombo->setCurrentIndex(
515 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
520 switch( idx_proto ) {
522 mrl = "http://" + addr;
523 emit methodChanged("http-caching");
526 mrl = "https://" + addr;
527 emit methodChanged("http-caching");
530 mrl = "mms://" + addr;
531 emit methodChanged("mms-caching");
534 mrl = "ftp://" + addr;
535 emit methodChanged("ftp-caching");
538 mrl = "rtsp://" + addr;
539 emit methodChanged("rtsp-caching");
542 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
547 if ( addr_is_ipv6 && !addr.contains('[') )
549 mrl += "[" + addr + "]";
553 mrl += QString(":%1").arg( ui.portSpin->value() );
554 emit methodChanged("udp-caching");
557 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
561 if ( addr_is_ipv6 && !addr.contains('[') )
562 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
566 mrl += QString(":%1").arg( ui.portSpin->value() );
567 emit methodChanged("rtp-caching");
570 mrl = "rtmp://" + addr;
571 emit methodChanged("rtmp-caching");
576 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
577 mrl += " :access-filter=timeshift";
579 emit mrlUpdated( mrl );
582 void NetOpenPanel::updateCompleter()
585 QStringList tempL = mrlList->stringList();
586 tempL.append( ui.addressText->text() );
587 mrlList->setStringList( tempL );
590 /**************************************************************************
591 * Open Capture device ( DVB, PVR, V4L, and similar ) *
592 **************************************************************************/
593 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
594 OpenPanel( _parent, _p_intf )
596 isInitialized = false;
599 void CaptureOpenPanel::initialize()
601 if( isInitialized ) return;
603 msg_Dbg( p_intf, "Initialization of Capture device panel" );
604 isInitialized = true;
608 BUTTONACT( ui.advancedButton, advancedDialog() );
610 /* Create two stacked layouts in the main comboBoxes */
611 QStackedLayout *stackedDevLayout = new QStackedLayout;
612 ui.cardBox->setLayout( stackedDevLayout );
614 QStackedLayout *stackedPropLayout = new QStackedLayout;
615 ui.optionsBox->setLayout( stackedPropLayout );
617 /* Creation and connections of the WIdgets in the stacked layout */
618 #define addModuleAndLayouts( number, name, label ) \
619 QWidget * name ## DevPage = new QWidget( this ); \
620 QWidget * name ## PropPage = new QWidget( this ); \
621 stackedDevLayout->addWidget( name ## DevPage ); \
622 stackedPropLayout->addWidget( name ## PropPage ); \
623 QGridLayout * name ## DevLayout = new QGridLayout; \
624 QGridLayout * name ## PropLayout = new QGridLayout; \
625 name ## DevPage->setLayout( name ## DevLayout ); \
626 name ## PropPage->setLayout( name ## PropLayout ); \
627 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
629 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
632 /*********************
633 * DirectShow Stuffs *
634 *********************/
635 if( module_exists( "dshow" ) ){
636 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
640 module_config_t *p_config =
641 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
642 vdevDshowW = new StringListConfigControl(
643 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
646 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
647 adevDshowW = new StringListConfigControl(
648 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
651 /* dshow Properties */
652 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
653 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
655 dshowVSizeLine = new QLineEdit;
656 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
657 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
661 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
662 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
663 CuMRL( dshowVSizeLine, textChanged( QString ) );
669 if( module_exists( "bda" ) ){
670 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
673 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
675 bdas = new QRadioButton( "DVB-S" );
676 bdas->setChecked( true );
677 bdac = new QRadioButton( "DVB-C" );
678 bdat = new QRadioButton( "DVB-T" );
679 bdaa = new QRadioButton( "ATSC" );
681 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
682 bdaDevLayout->addWidget( bdas, 0, 1 );
683 bdaDevLayout->addWidget( bdac, 0, 2 );
684 bdaDevLayout->addWidget( bdat, 0, 3 );
685 bdaDevLayout->addWidget( bdaa, 0, 4 );
688 QLabel *bdaFreqLabel =
689 new QLabel( qtr( "Transponder/multiplex frequency" ) );
690 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
692 bdaFreq = new QSpinBox;
693 bdaFreq->setAlignment( Qt::AlignRight );
694 bdaFreq->setSuffix(" kHz");
695 bdaFreq->setSingleStep( 1000 );
696 setSpinBoxFreq( bdaFreq )
697 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
699 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
700 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
702 bdaSrate = new QSpinBox;
703 bdaSrate->setAlignment( Qt::AlignRight );
704 bdaSrate->setSuffix(" kHz");
705 setSpinBoxFreq( bdaSrate );
706 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
708 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
709 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
711 bdaBandBox = new QComboBox;
712 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
713 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
715 bdaBandLabel->hide();
717 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
721 CuMRL( bdaFreq, valueChanged ( int ) );
722 CuMRL( bdaSrate, valueChanged ( int ) );
723 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
724 BUTTONACT( bdas, updateButtons() );
725 BUTTONACT( bdat, updateButtons() );
726 BUTTONACT( bdac, updateButtons() );
727 BUTTONACT( bdaa, updateButtons() );
728 BUTTONACT( bdas, updateMRL() );
729 BUTTONACT( bdat, updateMRL() );
730 BUTTONACT( bdac, updateMRL() );
731 BUTTONACT( bdaa, updateMRL() );
738 if( module_exists( "v4l2" ) ){
739 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
742 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
743 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
745 v4l2VideoDevice = new QLineEdit;
746 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
748 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
749 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
751 v4l2AudioDevice = new QLineEdit;
752 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
754 /* v4l2 Props panel */
755 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
756 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
758 v4l2StdBox = new QComboBox;
759 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
760 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
761 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
765 CuMRL( v4l2VideoDevice, textChanged( QString ) );
766 CuMRL( v4l2AudioDevice, textChanged( QString ) );
767 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
773 if( module_exists( "v4l" ) ){
774 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
777 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
778 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
780 v4lVideoDevice = new QLineEdit;
781 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
783 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
784 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
786 v4lAudioDevice = new QLineEdit;
787 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
789 /* V4l Props panel */
790 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
791 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
793 v4lNormBox = new QComboBox;
794 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
795 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
797 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
798 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
800 v4lFreq = new QSpinBox;
801 v4lFreq->setAlignment( Qt::AlignRight );
802 v4lFreq->setSuffix(" kHz");
803 setSpinBoxFreq( v4lFreq );
804 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
805 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
809 CuMRL( v4lVideoDevice, textChanged( QString ) );
810 CuMRL( v4lAudioDevice, textChanged( QString ) );
811 CuMRL( v4lFreq, valueChanged ( int ) );
812 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
818 if( module_exists( "jack" ) ){
819 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
821 /* Jack Main panel */
823 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
824 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
826 jackChannels = new QSpinBox;
827 setSpinBoxFreq( jackChannels );
828 jackChannels->setMaximum(255);
829 jackChannels->setValue(2);
830 jackChannels->setAlignment( Qt::AlignRight );
831 jackDevLayout->addWidget( jackChannels, 1, 1 );
833 /* Jack Props panel */
836 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
837 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
839 jackPortsSelected = new QLineEdit( qtr( ".*") );
840 jackPortsSelected->setAlignment( Qt::AlignRight );
841 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
844 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
845 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
846 jackCaching = new QSpinBox;
847 setSpinBoxFreq( jackCaching );
848 jackCaching->setSuffix( " ms" );
849 jackCaching->setValue(1000);
850 jackCaching->setAlignment( Qt::AlignRight );
851 jackPropLayout->addWidget( jackCaching, 1 , 1 );
854 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
855 jackPropLayout->addWidget( jackPace, 2, 1 );
858 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
859 jackPropLayout->addWidget( jackConnect, 3, 1 );
862 CuMRL( jackChannels, valueChanged( int ) );
863 CuMRL( jackCaching, valueChanged( int ) );
864 CuMRL( jackPace, stateChanged( int ) );
865 CuMRL( jackConnect, stateChanged( int ) );
866 CuMRL( jackPortsSelected, textChanged( QString ) );
872 if( module_exists( "pvr" ) ){
873 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
876 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
877 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
879 pvrDevice = new QLineEdit;
880 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
882 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
883 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
885 pvrRadioDevice = new QLineEdit;
886 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
888 /* PVR props panel */
889 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
890 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
892 pvrNormBox = new QComboBox;
893 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
894 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
896 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
897 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
899 pvrFreq = new QSpinBox;
900 pvrFreq->setAlignment( Qt::AlignRight );
901 pvrFreq->setSuffix(" kHz");
902 setSpinBoxFreq( pvrFreq );
903 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
905 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
906 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
908 pvrBitr = new QSpinBox;
909 pvrBitr->setAlignment( Qt::AlignRight );
910 pvrBitr->setSuffix(" kHz");
911 setSpinBoxFreq( pvrBitr );
912 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
913 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
917 CuMRL( pvrDevice, textChanged( QString ) );
918 CuMRL( pvrRadioDevice, textChanged( QString ) );
920 CuMRL( pvrFreq, valueChanged ( int ) );
921 CuMRL( pvrBitr, valueChanged ( int ) );
922 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
928 if( module_exists( "dvb" ) ){
929 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
932 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
933 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
935 dvbCard = new QSpinBox;
936 dvbCard->setAlignment( Qt::AlignRight );
937 dvbCard->setPrefix( "/dev/dvb/adapter" );
939 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
940 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
942 dvbs = new QRadioButton( "DVB-S" );
943 dvbs->setChecked( true );
944 dvbc = new QRadioButton( "DVB-C" );
945 dvbt = new QRadioButton( "DVB-T" );
947 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
948 dvbDevLayout->addWidget( dvbs, 1, 1 );
949 dvbDevLayout->addWidget( dvbc, 1, 2 );
950 dvbDevLayout->addWidget( dvbt, 1, 3 );
952 /* DVB Props panel */
953 QLabel *dvbFreqLabel =
954 new QLabel( qtr( "Transponder/multiplex frequency" ) );
955 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
957 dvbFreq = new QSpinBox;
958 dvbFreq->setAlignment( Qt::AlignRight );
959 dvbFreq->setSuffix(" kHz");
960 setSpinBoxFreq( dvbFreq );
961 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
963 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
964 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
966 dvbSrate = new QSpinBox;
967 dvbSrate->setAlignment( Qt::AlignRight );
968 dvbSrate->setSuffix(" kHz");
969 setSpinBoxFreq( dvbSrate );
970 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
971 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
975 CuMRL( dvbCard, valueChanged ( int ) );
976 CuMRL( dvbFreq, valueChanged ( int ) );
977 CuMRL( dvbSrate, valueChanged ( int ) );
979 BUTTONACT( dvbs, updateButtons() );
980 BUTTONACT( dvbt, updateButtons() );
981 BUTTONACT( dvbc, updateButtons() );
990 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
991 QLabel *screenLabel = new QLabel( "This option will open your own "
992 "desktop in order to save or stream it.");
993 screenLabel->setWordWrap( true );
994 screenDevLayout->addWidget( screenLabel, 0, 0 );
996 QLabel *screenFPSLabel = new QLabel(
997 qtr( "Desired frame rate for the capture." ) );
998 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1000 screenFPS = new QSpinBox;
1001 screenFPS->setValue( 1 );
1002 screenFPS->setAlignment( Qt::AlignRight );
1003 screenPropLayout->addWidget( screenFPS, 0, 1 );
1005 /* General connects */
1006 CONNECT( ui.deviceCombo, activated( int ) ,
1007 stackedDevLayout, setCurrentIndex( int ) );
1008 CONNECT( ui.deviceCombo, activated( int ),
1009 stackedPropLayout, setCurrentIndex( int ) );
1010 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1011 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1016 CaptureOpenPanel::~CaptureOpenPanel()
1020 void CaptureOpenPanel::clear()
1025 void CaptureOpenPanel::updateMRL()
1028 int i_devicetype = ui.deviceCombo->itemData(
1029 ui.deviceCombo->currentIndex() ).toInt();
1030 switch( i_devicetype )
1034 if( bdas->isChecked() ) mrl = "dvb-s://";
1035 else if( bdat->isChecked() ) mrl = "dvb-t://";
1036 else if( bdac->isChecked() ) mrl = "dvb-c://";
1037 else if( bdaa->isChecked() ) mrl = "atsc://";
1039 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1040 if( bdas->isChecked() || bdac->isChecked() )
1041 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1042 else if( bdat->isChecked() )
1043 mrl += " :dvb-bandwidth=" +
1044 QString("%1").arg( bdaBandBox->itemData(
1045 bdaBandBox->currentIndex() ).toInt() );
1049 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1050 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1051 if( dshowVSizeLine->isModified() )
1052 mrl += " :dshow-size=" + dshowVSizeLine->text();
1057 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1058 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1059 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1060 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1064 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1065 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1066 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1070 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1071 mrl += ":ports=" + jackPortsSelected->text();
1072 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1073 if ( jackPace->isChecked() )
1075 mrl += " --jack-input-use-vlc-pace";
1077 if ( jackConnect->isChecked() )
1079 mrl += " --jack-input-auto-connect";
1084 mrl += " :pvr-device=" + pvrDevice->text();
1085 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1086 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1087 if( pvrFreq->value() )
1088 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1089 if( pvrBitr->value() )
1090 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1094 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1095 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1096 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1101 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1106 if( !advMRL.isEmpty() ) mrl += advMRL;
1108 emit mrlUpdated( mrl );
1112 * Update the Buttons (show/hide) for the GUI as all device type don't
1113 * use the same ui. elements.
1115 void CaptureOpenPanel::updateButtons()
1117 /* Be sure to display the ui Elements in case they were hidden by
1118 * some Device Type (like Screen://) */
1119 ui.optionsBox->show();
1120 ui.advancedButton->show();
1121 /* Get the current Device Number */
1122 int i_devicetype = ui.deviceCombo->itemData(
1123 ui.deviceCombo->currentIndex() ).toInt();
1124 switch( i_devicetype )
1128 if( bdas->isChecked() || bdac->isChecked() )
1131 bdaSrateLabel->show();
1133 bdaBandLabel->hide();
1135 else if( bdat->isChecked() )
1138 bdaSrateLabel->hide();
1140 bdaBandLabel->show();
1145 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1146 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1150 //ui.optionsBox->hide();
1151 ui.advancedButton->hide();
1158 void CaptureOpenPanel::advancedDialog()
1160 /* Get selected device type */
1161 int i_devicetype = ui.deviceCombo->itemData(
1162 ui.deviceCombo->currentIndex() ).toInt();
1164 /* Get the corresponding module */
1165 module_t *p_module =
1166 module_find( psz_devModule[i_devicetype] );
1167 if( NULL == p_module ) return;
1170 QList<ConfigControl *> controls;
1172 /* Get the confsize */
1173 unsigned int i_confsize;
1174 module_config_t *p_config;
1175 p_config = module_config_get( p_module, &i_confsize );
1177 /* New Adv Prop dialog */
1178 adv = new QDialog( this );
1179 adv->setWindowTitle( qtr( "Advanced Options" ) );
1181 /* A main Layout with a Frame */
1182 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1183 QScrollArea *scroll = new QScrollArea;
1184 mainLayout->addWidget( scroll );
1186 QFrame *advFrame = new QFrame;
1187 /* GridLayout inside the Frame */
1188 QGridLayout *gLayout = new QGridLayout( advFrame );
1190 scroll->setWidgetResizable( true );
1191 scroll->setWidget( advFrame );
1193 /* Create the options inside the FrameLayout */
1194 for( int n = 0; n < (int)i_confsize; n++ )
1196 module_config_t *p_item = p_config + n;
1197 ConfigControl *config = ConfigControl::createControl(
1198 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1199 controls.append( config );
1203 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1204 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1205 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1207 CONNECT( closeButton, clicked(), adv, accept() );
1208 CONNECT( cancelButton, clicked(), adv, reject() );
1210 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1211 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1213 mainLayout->addWidget( advButtonBox );
1215 /* Creation of the MRL */
1218 QString tempMRL = "";
1219 for( int i = 0; i < controls.size(); i++ )
1221 ConfigControl *control = controls[i];
1224 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1228 tempMRL += (i ? " :" : ":");
1230 if( control->getType() == CONFIG_ITEM_BOOL )
1231 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1234 tempMRL += control->getName();
1236 switch( control->getType() )
1238 case CONFIG_ITEM_STRING:
1239 case CONFIG_ITEM_FILE:
1240 case CONFIG_ITEM_DIRECTORY:
1241 case CONFIG_ITEM_MODULE:
1242 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1244 case CONFIG_ITEM_INTEGER:
1245 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1247 case CONFIG_ITEM_FLOAT:
1248 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1254 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1257 module_config_free( p_config );
1258 module_release (p_module);