1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2009 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 ), dialogBox( NULL )
61 /* Classic UI Setup */
64 /* Set Filters for file selection */
65 /* QString fileTypes = "";
66 ADD_FILTER_MEDIA( fileTypes );
67 ADD_FILTER_VIDEO( fileTypes );
68 ADD_FILTER_AUDIO( fileTypes );
69 ADD_FILTER_PLAYLIST( fileTypes );
70 ADD_FILTER_ALL( fileTypes );
71 fileTypes.replace( QString(";*"), QString(" *")); */
74 /* lineFileEdit = ui.fileEdit;
75 //TODO later: fill the fileCompleteList with previous items played.
76 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
77 fileCompleter->setModel( new QDirModel( fileCompleter ) );
78 lineFileEdit->setCompleter( fileCompleter );*/
79 if( config_GetInt( p_intf, "qt-embedded-open" ) )
81 ui.tempWidget->hide();
86 /* Deactivate the subtitles control by default. */
87 ui.subFrame->setEnabled( false );
88 /* Build the subs size combo box */
89 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
91 /* Build the subs align combo box */
92 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
95 BUTTONACT( ui.fileBrowseButton, browseFile() );
96 BUTTONACT( ui.delFileButton, deleteFile() );
98 BUTTONACT( ui.subBrowseButton, browseFileSub() );
99 CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
101 CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
102 CONNECT( ui.subInput, textChanged( const QString& ), this, updateMRL() );
103 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
104 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
107 inline void FileOpenPanel::BuildOldPanel()
109 /** BEGIN QFileDialog tweaking **/
110 /* Use a QFileDialog and customize it because we don't want to
111 rewrite it all. Be careful to your eyes cause there are a few hacks.
112 Be very careful and test correctly when you modify this. */
114 /* Make this QFileDialog a child of tempWidget from the ui. */
115 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
116 p_intf->p_sys->filepath, "" );
118 dialogBox->setFileMode( QFileDialog::ExistingFiles );
119 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
120 dialogBox->restoreState(
121 getSettings()->value( "file-dialog-state" ).toByteArray() );
123 /* We don't want to see a grip in the middle of the window, do we? */
124 dialogBox->setSizeGripEnabled( false );
127 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
128 dialogBox->setMinimumHeight( 250 );
130 // But hide the two OK/Cancel buttons. Enable them for debug.
131 QDialogButtonBox *fileDialogAcceptBox =
132 dialogBox->findChildren<QDialogButtonBox*>()[0];
133 fileDialogAcceptBox->hide();
135 /* Ugly hacks to get the good Widget */
136 //This lineEdit is the normal line in the fileDialog.
137 QLineEdit *lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
138 /* Make a list of QLabel inside the QFileDialog to access the good ones */
139 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
141 /* Hide the FileNames one. Enable it for debug */
142 listLabel[1]->setText( qtr( "File names:" ) );
143 /* Change the text that was uncool in the usual box */
144 listLabel[2]->setText( qtr( "Filter:" ) );
146 dialogBox->layout()->setMargin( 0 );
147 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
149 /** END of QFileDialog tweaking **/
151 // Add the DialogBox to the layout
152 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
154 CONNECT( lineFileEdit, textChanged( const QString& ), this, updateMRL() );
155 dialogBox->installEventFilter( this );
158 FileOpenPanel::~FileOpenPanel()
161 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
164 void FileOpenPanel::browseFile()
166 QStringList files = QFileDialog::getOpenFileNames( this );
167 foreach( const QString &file, files)
169 QListWidgetItem *item = new QListWidgetItem( file, ui.fileListWidg );
170 item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
171 ui.fileListWidg->addItem( item );
176 void FileOpenPanel::deleteFile()
178 int i = ui.fileListWidg->currentRow();
181 QListWidgetItem *temp = ui.fileListWidg->takeItem( i );
188 /* Show a fileBrowser to select a subtitle */
189 void FileOpenPanel::browseFileSub()
191 // TODO Handle selection of more than one subtitles file
192 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
193 EXT_FILTER_SUBTITLE, p_intf->p_sys->filepath );
195 if( files.isEmpty() ) return;
196 ui.subInput->setText( files.join(" ") );
200 void FileOpenPanel::toggleSubtitleFrame( bool b )
202 ui.subFrame->setEnabled( b );
209 /* Update the current MRL */
210 void FileOpenPanel::updateMRL()
212 QStringList fileList;
216 if( dialogBox == NULL )
217 for( int i = 0; i < ui.fileListWidg->count(); i++ )
219 if( !ui.fileListWidg->item( i )->text().isEmpty() )
220 fileList << ui.fileListWidg->item( i )->text();
223 fileList = dialogBox->selectedFiles();
226 if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) {
227 mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
228 int align = ui.alignSubComboBox->itemData(
229 ui.alignSubComboBox->currentIndex() ).toInt();
230 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
231 int size = ui.sizeSubComboBox->itemData(
232 ui.sizeSubComboBox->currentIndex() ).toInt();
233 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
236 emit mrlUpdated( fileList, mrl );
237 emit methodChanged( "file-caching" );
240 /* Function called by Open Dialog when clicke on Play/Enqueue */
241 void FileOpenPanel::accept()
243 p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
244 ui.fileListWidg->clear();
247 /* Function called by Open Dialog when clicked on cancel */
248 void FileOpenPanel::clear()
250 ui.fileListWidg->clear();
251 ui.subInput->clear();
254 /**************************************************************************
255 * Open Discs ( DVD, CD, VCD and similar devices ) *
256 **************************************************************************/
257 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
258 OpenPanel( _parent, _p_intf )
262 /* Get the default configuration path for the devices */
263 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
264 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
265 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
267 /* State to avoid overwritting the users changes with the configuration */
272 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
273 ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
275 #ifdef WIN32 /* Disc drives probing for Windows */
278 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
280 char *drive = szDrives;
281 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
284 if( GetDriveTypeA(drive) == DRIVE_CDROM )
285 ui.deviceCombo->addItem( drive );
287 /* go to next drive */
290 SetErrorMode(oldMode);
292 #else /* Use a Completer under Linux */
293 QCompleter *discCompleter = new QCompleter( this );
294 discCompleter->setModel( new QDirModel( discCompleter ) );
295 ui.deviceCombo->setCompleter( discCompleter );
299 BUTTONACT( ui.dvdRadioButton, updateButtons() );
300 BUTTONACT( ui.vcdRadioButton, updateButtons() );
301 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
302 BUTTONACT( ui.dvdsimple, updateButtons() );
303 BUTTONACT( ui.browseDiscButton, browseDevice() );
304 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
307 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
308 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
309 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
310 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
311 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
313 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
317 DiscOpenPanel::~DiscOpenPanel()
319 free( psz_dvddiscpath );
320 free( psz_vcddiscpath );
321 free( psz_cddadiscpath );
324 void DiscOpenPanel::clear()
326 ui.titleSpin->setValue( 0 );
327 ui.chapterSpin->setValue( 0 );
328 ui.subtitlesSpin->setValue( -1 );
329 ui.audioSpin->setValue( -1 );
336 #define setDrive( psz_name ) {\
337 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
338 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
340 #define setDrive( psz_name ) {\
341 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
344 /* update the buttons according the type of device */
345 void DiscOpenPanel::updateButtons()
347 if ( ui.dvdRadioButton->isChecked() )
351 setDrive( psz_dvddiscpath );
354 ui.titleLabel->setText( qtr("Title") );
355 ui.chapterLabel->show();
356 ui.chapterSpin->show();
357 ui.diskOptionBox_2->show();
358 ui.dvdsimple->setEnabled( true );
360 else if ( ui.vcdRadioButton->isChecked() )
364 setDrive( psz_vcddiscpath );
367 ui.titleLabel->setText( qtr("Entry") );
368 ui.chapterLabel->hide();
369 ui.chapterSpin->hide();
370 ui.diskOptionBox_2->show();
371 ui.dvdsimple->setEnabled( false );
377 setDrive( psz_cddadiscpath );
380 ui.titleLabel->setText( qtr("Track") );
381 ui.chapterLabel->hide();
382 ui.chapterSpin->hide();
383 ui.diskOptionBox_2->hide();
384 ui.dvdsimple->setEnabled( false );
390 /* Update the current MRL */
391 void DiscOpenPanel::updateMRL()
394 QStringList fileList;
396 /* CDDAX and VCDX not implemented. TODO ? No. */
398 if( ui.dvdRadioButton->isChecked() ) {
399 if( !ui.dvdsimple->isChecked() )
402 mrl = "dvdsimple://";
403 mrl += ui.deviceCombo->currentText();
404 emit methodChanged( "dvdnav-caching" );
406 if ( ui.titleSpin->value() > 0 ) {
407 mrl += QString("@%1").arg( ui.titleSpin->value() );
408 if ( ui.chapterSpin->value() > 0 ) {
409 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
414 } else if ( ui.vcdRadioButton->isChecked() ) {
415 mrl = "vcd://" + ui.deviceCombo->currentText();
416 emit methodChanged( "vcd-caching" );
418 if( ui.titleSpin->value() > 0 ) {
419 mrl += QString("@E%1").arg( ui.titleSpin->value() );
424 mrl = "cdda://" + ui.deviceCombo->currentText();
427 fileList << mrl; mrl = "";
429 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
431 if ( ui.audioSpin->value() >= 0 ) {
432 mrl += " :audio-track=" +
433 QString("%1").arg( ui.audioSpin->value() );
435 if ( ui.subtitlesSpin->value() >= 0 ) {
436 mrl += " :sub-track=" +
437 QString("%1").arg( ui.subtitlesSpin->value() );
442 if( ui.titleSpin->value() > 0 )
443 mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
445 emit mrlUpdated( fileList, mrl );
448 void DiscOpenPanel::browseDevice()
450 QString dir = QFileDialog::getExistingDirectory( this,
451 qtr( I_DEVICE_TOOLTIP ) );
453 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
458 void DiscOpenPanel::eject()
460 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
463 void DiscOpenPanel::accept()
466 /**************************************************************************
467 * Open Network streams and URL pages *
468 **************************************************************************/
469 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
470 OpenPanel( _parent, _p_intf )
475 CONNECT( ui.protocolCombo, activated( int ),
476 this, updateProtocol( int ) );
477 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
478 CONNECT( ui.addressText, textChanged( const QString& ), this, updateMRL());
480 ui.protocolCombo->addItem( "" );
481 ui.protocolCombo->addItem("HTTP", QVariant("http"));
482 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
483 ui.protocolCombo->addItem("MMS", QVariant("mms"));
484 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
485 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
486 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
487 ui.protocolCombo->addItem("UDP", QVariant("udp"));
488 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
490 updateProtocol( ui.protocolCombo->currentIndex() );
492 if( config_GetInt( p_intf, "qt-recentplay" ) )
494 mrlList = new QStringListModel(
495 getSettings()->value( "Open/netMRL" ).toStringList() );
496 QCompleter *completer = new QCompleter( mrlList, this );
497 ui.addressText->setCompleter( completer );
499 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
505 NetOpenPanel::~NetOpenPanel()
507 if( !mrlList ) return;
509 QStringList tempL = mrlList->stringList();
510 while( tempL.size() > 8 ) tempL.removeFirst();
512 getSettings()->setValue( "Open/netMRL", tempL );
515 void NetOpenPanel::clear()
518 /* update the widgets according the type of protocol */
519 void NetOpenPanel::updateProtocol( int idx_proto ) {
520 QString addr = ui.addressText->text();
521 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
523 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
524 idx_proto == RTP_PROTO );
526 if( idx_proto == NO_PROTO ) return;
528 /* If we already have a protocol in the address, replace it */
529 if( addr.contains( "://"))
531 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
532 addr.replace( QRegExp("^.*://@*"), proto + "://");
533 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
534 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
535 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
536 addr.replace( QRegExp("^.*://"), proto + "://@");
538 addr.replace( QRegExp("^.*://"), proto + "://");
539 addr.replace( QRegExp("@+"), "@");
540 ui.addressText->setText( addr );
545 void NetOpenPanel::updateMRL() {
547 QString addr = ui.addressText->text();
548 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
549 int idx_proto = ui.protocolCombo->currentIndex();
550 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
551 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
552 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
553 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
554 if( addr.contains( "://"))
556 /* Match the correct item in the comboBox */
557 ui.protocolCombo->setCurrentIndex(
558 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
563 switch( idx_proto ) {
565 mrl = "http://" + addr;
566 emit methodChanged("http-caching");
569 mrl = "https://" + addr;
570 emit methodChanged("http-caching");
573 mrl = "mms://" + addr;
574 emit methodChanged("mms-caching");
577 mrl = "ftp://" + addr;
578 emit methodChanged("ftp-caching");
581 mrl = "rtsp://" + addr;
582 emit methodChanged("rtsp-caching");
585 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
590 if ( addr_is_ipv6 && !addr.contains('[') )
592 mrl += "[" + addr + "]";
596 mrl += QString(":%1").arg( ui.portSpin->value() );
597 emit methodChanged("udp-caching");
600 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
604 if ( addr_is_ipv6 && !addr.contains('[') )
605 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
609 mrl += QString(":%1").arg( ui.portSpin->value() );
610 emit methodChanged("rtp-caching");
613 mrl = "rtmp://" + addr;
614 emit methodChanged("rtmp-caching");
619 QStringList qsl; qsl<< mrl;
620 emit mrlUpdated( qsl, "" );
623 void NetOpenPanel::updateCompleter()
626 QStringList tempL = mrlList->stringList();
627 if( !tempL.contains( ui.addressText->text() ) )
628 tempL.append( ui.addressText->text() );
629 mrlList->setStringList( tempL );
632 /**************************************************************************
633 * Open Capture device ( DVB, PVR, V4L, and similar ) *
634 **************************************************************************/
635 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
636 OpenPanel( _parent, _p_intf )
638 isInitialized = false;
641 void CaptureOpenPanel::initialize()
643 if( isInitialized ) return;
645 msg_Dbg( p_intf, "Initialization of Capture device panel" );
646 isInitialized = true;
650 BUTTONACT( ui.advancedButton, advancedDialog() );
652 /* Create two stacked layouts in the main comboBoxes */
653 QStackedLayout *stackedDevLayout = new QStackedLayout;
654 ui.cardBox->setLayout( stackedDevLayout );
656 QStackedLayout *stackedPropLayout = new QStackedLayout;
657 ui.optionsBox->setLayout( stackedPropLayout );
659 /* Creation and connections of the WIdgets in the stacked layout */
660 #define addModuleAndLayouts( number, name, label ) \
661 QWidget * name ## DevPage = new QWidget( this ); \
662 QWidget * name ## PropPage = new QWidget( this ); \
663 stackedDevLayout->addWidget( name ## DevPage ); \
664 stackedPropLayout->addWidget( name ## PropPage ); \
665 QGridLayout * name ## DevLayout = new QGridLayout; \
666 QGridLayout * name ## PropLayout = new QGridLayout; \
667 name ## DevPage->setLayout( name ## DevLayout ); \
668 name ## PropPage->setLayout( name ## PropLayout ); \
669 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
671 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
674 /*********************
675 * DirectShow Stuffs *
676 *********************/
677 if( module_exists( "dshow" ) ){
678 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
682 module_config_t *p_config =
683 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
684 vdevDshowW = new StringListConfigControl(
685 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
688 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
689 adevDshowW = new StringListConfigControl(
690 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
693 /* dshow Properties */
694 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
695 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
697 dshowVSizeLine = new QLineEdit;
698 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
699 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
703 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
704 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
705 CuMRL( dshowVSizeLine, textChanged( const QString& ) );
711 if( module_exists( "bda" ) ){
712 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
715 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
717 bdas = new QRadioButton( "DVB-S" );
718 bdas->setChecked( true );
719 bdac = new QRadioButton( "DVB-C" );
720 bdat = new QRadioButton( "DVB-T" );
721 bdaa = new QRadioButton( "ATSC" );
723 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
724 bdaDevLayout->addWidget( bdas, 0, 1 );
725 bdaDevLayout->addWidget( bdac, 0, 2 );
726 bdaDevLayout->addWidget( bdat, 0, 3 );
727 bdaDevLayout->addWidget( bdaa, 0, 4 );
730 QLabel *bdaFreqLabel =
731 new QLabel( qtr( "Transponder/multiplex frequency" ) );
732 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
734 bdaFreq = new QSpinBox;
735 bdaFreq->setAlignment( Qt::AlignRight );
736 bdaFreq->setSuffix(" kHz");
737 bdaFreq->setSingleStep( 1000 );
738 setSpinBoxFreq( bdaFreq )
739 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
741 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
742 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
744 bdaSrate = new QSpinBox;
745 bdaSrate->setAlignment( Qt::AlignRight );
746 bdaSrate->setSuffix(" kHz");
747 setSpinBoxFreq( bdaSrate );
748 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
750 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
751 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
753 bdaBandBox = new QComboBox;
754 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
755 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
757 bdaBandLabel->hide();
759 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
763 CuMRL( bdaFreq, valueChanged ( int ) );
764 CuMRL( bdaSrate, valueChanged ( int ) );
765 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
766 BUTTONACT( bdas, updateButtons() );
767 BUTTONACT( bdat, updateButtons() );
768 BUTTONACT( bdac, updateButtons() );
769 BUTTONACT( bdaa, updateButtons() );
770 BUTTONACT( bdas, updateMRL() );
771 BUTTONACT( bdat, updateMRL() );
772 BUTTONACT( bdac, updateMRL() );
773 BUTTONACT( bdaa, updateMRL() );
780 if( module_exists( "v4l2" ) ){
781 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
784 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
785 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
787 v4l2VideoDevice = new QLineEdit;
788 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
790 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
791 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
793 v4l2AudioDevice = new QLineEdit;
794 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
796 /* v4l2 Props panel */
797 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
798 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
800 v4l2StdBox = new QComboBox;
801 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
802 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
803 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
807 CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
808 CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
809 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
815 if( module_exists( "v4l" ) ){
816 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
819 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
820 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
822 v4lVideoDevice = new QLineEdit;
823 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
825 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
826 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
828 v4lAudioDevice = new QLineEdit;
829 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
831 /* V4l Props panel */
832 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
833 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
835 v4lNormBox = new QComboBox;
836 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
837 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
839 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
840 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
842 v4lFreq = new QSpinBox;
843 v4lFreq->setAlignment( Qt::AlignRight );
844 v4lFreq->setSuffix(" kHz");
845 setSpinBoxFreq( v4lFreq );
846 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
847 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
851 CuMRL( v4lVideoDevice, textChanged( const QString& ) );
852 CuMRL( v4lAudioDevice, textChanged( const QString& ) );
853 CuMRL( v4lFreq, valueChanged ( int ) );
854 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
860 if( module_exists( "jack" ) ){
861 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
863 /* Jack Main panel */
865 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
866 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
868 jackChannels = new QSpinBox;
869 setSpinBoxFreq( jackChannels );
870 jackChannels->setMaximum(255);
871 jackChannels->setValue(2);
872 jackChannels->setAlignment( Qt::AlignRight );
873 jackDevLayout->addWidget( jackChannels, 1, 1 );
876 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
877 jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
879 jackPortsSelected = new QLineEdit( qtr( ".*") );
880 jackPortsSelected->setAlignment( Qt::AlignRight );
881 jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
883 /* Jack Props panel */
886 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
887 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
888 jackCaching = new QSpinBox;
889 setSpinBoxFreq( jackCaching );
890 jackCaching->setSuffix( " ms" );
891 jackCaching->setValue(1000);
892 jackCaching->setAlignment( Qt::AlignRight );
893 jackPropLayout->addWidget( jackCaching, 1 , 2 );
896 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
897 jackPropLayout->addWidget( jackPace, 2, 1 );
900 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
901 jackPropLayout->addWidget( jackConnect, 2, 2 );
904 CuMRL( jackChannels, valueChanged( int ) );
905 CuMRL( jackCaching, valueChanged( int ) );
906 CuMRL( jackPace, stateChanged( int ) );
907 CuMRL( jackConnect, stateChanged( int ) );
908 CuMRL( jackPortsSelected, textChanged( const QString& ) );
914 if( module_exists( "pvr" ) ){
915 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
918 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
919 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
921 pvrDevice = new QLineEdit;
922 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
924 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
925 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
927 pvrRadioDevice = new QLineEdit;
928 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
930 /* PVR props panel */
931 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
932 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
934 pvrNormBox = new QComboBox;
935 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
936 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
938 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
939 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
941 pvrFreq = new QSpinBox;
942 pvrFreq->setAlignment( Qt::AlignRight );
943 pvrFreq->setSuffix(" kHz");
944 setSpinBoxFreq( pvrFreq );
945 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
947 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
948 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
950 pvrBitr = new QSpinBox;
951 pvrBitr->setAlignment( Qt::AlignRight );
952 pvrBitr->setSuffix(" kHz");
953 setSpinBoxFreq( pvrBitr );
954 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
955 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
959 CuMRL( pvrDevice, textChanged( const QString& ) );
960 CuMRL( pvrRadioDevice, textChanged( const QString& ) );
962 CuMRL( pvrFreq, valueChanged ( int ) );
963 CuMRL( pvrBitr, valueChanged ( int ) );
964 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
970 if( module_exists( "dvb" ) ){
971 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
974 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
975 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
977 dvbCard = new QSpinBox;
978 dvbCard->setAlignment( Qt::AlignRight );
979 dvbCard->setPrefix( "/dev/dvb/adapter" );
981 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
982 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
984 dvbs = new QRadioButton( "DVB-S" );
985 dvbs->setChecked( true );
986 dvbc = new QRadioButton( "DVB-C" );
987 dvbt = new QRadioButton( "DVB-T" );
989 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
990 dvbDevLayout->addWidget( dvbs, 1, 1 );
991 dvbDevLayout->addWidget( dvbc, 1, 2 );
992 dvbDevLayout->addWidget( dvbt, 1, 3 );
994 /* DVB Props panel */
995 QLabel *dvbFreqLabel =
996 new QLabel( qtr( "Transponder/multiplex frequency" ) );
997 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
999 dvbFreq = new QSpinBox;
1000 dvbFreq->setAlignment( Qt::AlignRight );
1001 dvbFreq->setSuffix(" kHz");
1002 setSpinBoxFreq( dvbFreq );
1003 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
1005 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
1006 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
1008 dvbSrate = new QSpinBox;
1009 dvbSrate->setAlignment( Qt::AlignRight );
1010 dvbSrate->setSuffix(" kHz");
1011 setSpinBoxFreq( dvbSrate );
1012 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
1013 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
1017 CuMRL( dvbCard, valueChanged ( int ) );
1018 CuMRL( dvbFreq, valueChanged ( int ) );
1019 CuMRL( dvbSrate, valueChanged ( int ) );
1021 BUTTONACT( dvbs, updateButtons() );
1022 BUTTONACT( dvbt, updateButtons() );
1023 BUTTONACT( dvbc, updateButtons() );
1032 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
1033 QLabel *screenLabel = new QLabel( "Your display will will be "
1034 "opened and played in order to stream or save it." );
1035 screenLabel->setWordWrap( true );
1036 screenDevLayout->addWidget( screenLabel, 0, 0 );
1038 QLabel *screenFPSLabel = new QLabel(
1039 qtr( "Desired frame rate for the capture." ) );
1040 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1042 screenFPS = new QSpinBox;
1043 screenFPS->setValue( 1 );
1044 screenFPS->setAlignment( Qt::AlignRight );
1045 screenPropLayout->addWidget( screenFPS, 0, 1 );
1047 /* General connects */
1048 CONNECT( ui.deviceCombo, activated( int ) ,
1049 stackedDevLayout, setCurrentIndex( int ) );
1050 CONNECT( ui.deviceCombo, activated( int ),
1051 stackedPropLayout, setCurrentIndex( int ) );
1052 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1053 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1058 CaptureOpenPanel::~CaptureOpenPanel()
1062 void CaptureOpenPanel::clear()
1067 void CaptureOpenPanel::updateMRL()
1070 QStringList fileList;
1071 int i_devicetype = ui.deviceCombo->itemData(
1072 ui.deviceCombo->currentIndex() ).toInt();
1073 switch( i_devicetype )
1077 if( bdas->isChecked() ) mrl = "dvb-s://";
1078 else if( bdat->isChecked() ) mrl = "dvb-t://";
1079 else if( bdac->isChecked() ) mrl = "dvb-c://";
1080 else if( bdaa->isChecked() ) mrl = "atsc://";
1082 fileList << mrl; mrl = "";
1084 mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
1085 if( bdas->isChecked() || bdac->isChecked() )
1086 mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1087 else if( bdat->isChecked() )
1088 mrl += " :dvb-bandwidth=" +
1089 QString::number( bdaBandBox->itemData(
1090 bdaBandBox->currentIndex() ).toInt() );
1093 fileList << "dshow://";
1094 mrl+= " :dshow-vdev=" +
1095 colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1096 mrl+= " :dshow-adev=" +
1097 colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
1098 if( dshowVSizeLine->isModified() )
1099 mrl += " :dshow-size=" + dshowVSizeLine->text();
1103 fileList << "v4l://";
1104 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1105 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1106 mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1107 mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1110 fileList << "v4l2://";
1111 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1112 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1113 mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1117 mrl += "channels=" + QString::number( jackChannels->value() );
1118 mrl += ":ports=" + jackPortsSelected->text();
1119 fileList << mrl; mrl = "";
1121 mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1122 if ( jackPace->isChecked() )
1124 mrl += " :jack-input-use-vlc-pace";
1126 if ( jackConnect->isChecked() )
1128 mrl += " :jack-input-auto-connect";
1132 fileList << "pvr://";
1133 mrl += " :pvr-device=" + pvrDevice->text();
1134 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1135 mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1136 if( pvrFreq->value() )
1137 mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1138 if( pvrBitr->value() )
1139 mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1142 fileList << "dvb://";
1143 mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1144 mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
1145 mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1149 fileList << "screen://";
1150 mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1155 if( !advMRL.isEmpty() ) mrl += advMRL;
1157 emit mrlUpdated( fileList, mrl );
1161 * Update the Buttons (show/hide) for the GUI as all device type don't
1162 * use the same ui. elements.
1164 void CaptureOpenPanel::updateButtons()
1166 /* Be sure to display the ui Elements in case they were hidden by
1167 * some Device Type (like Screen://) */
1168 ui.optionsBox->show();
1169 ui.advancedButton->show();
1170 /* Get the current Device Number */
1171 int i_devicetype = ui.deviceCombo->itemData(
1172 ui.deviceCombo->currentIndex() ).toInt();
1173 switch( i_devicetype )
1177 if( bdas->isChecked() || bdac->isChecked() )
1180 bdaSrateLabel->show();
1182 bdaBandLabel->hide();
1184 else if( bdat->isChecked() )
1187 bdaSrateLabel->hide();
1189 bdaBandLabel->show();
1194 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1195 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1199 //ui.optionsBox->hide();
1200 ui.advancedButton->hide();
1207 void CaptureOpenPanel::advancedDialog()
1209 /* Get selected device type */
1210 int i_devicetype = ui.deviceCombo->itemData(
1211 ui.deviceCombo->currentIndex() ).toInt();
1213 /* Get the corresponding module */
1214 module_t *p_module =
1215 module_find( psz_devModule[i_devicetype] );
1216 if( NULL == p_module ) return;
1219 QList<ConfigControl *> controls;
1221 /* Get the confsize */
1222 unsigned int i_confsize;
1223 module_config_t *p_config;
1224 p_config = module_config_get( p_module, &i_confsize );
1226 /* New Adv Prop dialog */
1227 adv = new QDialog( this );
1228 adv->setWindowTitle( qtr( "Advanced Options" ) );
1230 /* A main Layout with a Frame */
1231 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1232 QScrollArea *scroll = new QScrollArea;
1233 mainLayout->addWidget( scroll );
1235 QFrame *advFrame = new QFrame;
1236 /* GridLayout inside the Frame */
1237 QGridLayout *gLayout = new QGridLayout( advFrame );
1239 scroll->setWidgetResizable( true );
1240 scroll->setWidget( advFrame );
1242 /* Create the options inside the FrameLayout */
1243 for( int n = 0; n < (int)i_confsize; n++ )
1245 module_config_t *p_item = p_config + n;
1246 ConfigControl *config = ConfigControl::createControl(
1247 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1248 controls.append( config );
1252 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1253 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1254 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1256 CONNECT( closeButton, clicked(), adv, accept() );
1257 CONNECT( cancelButton, clicked(), adv, reject() );
1259 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1260 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1262 mainLayout->addWidget( advButtonBox );
1264 /* Creation of the MRL */
1267 QString tempMRL = "";
1268 for( int i = 0; i < controls.size(); i++ )
1270 ConfigControl *control = controls[i];
1273 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1277 tempMRL += (i ? " :" : ":");
1279 if( control->getType() == CONFIG_ITEM_BOOL )
1280 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1283 tempMRL += control->getName();
1285 switch( control->getType() )
1287 case CONFIG_ITEM_STRING:
1288 case CONFIG_ITEM_FILE:
1289 case CONFIG_ITEM_DIRECTORY:
1290 case CONFIG_ITEM_MODULE:
1291 tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1293 case CONFIG_ITEM_INTEGER:
1294 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1296 case CONFIG_ITEM_FLOAT:
1297 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1303 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1306 module_config_free( p_config );
1307 module_release (p_module);