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 qfu( p_intf->p_sys->psz_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->psz_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()
244 // p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
245 ui.fileListWidg->clear();
248 /* Function called by Open Dialog when clicked on cancel */
249 void FileOpenPanel::clear()
251 ui.fileListWidg->clear();
252 ui.subInput->clear();
255 /**************************************************************************
256 * Open Discs ( DVD, CD, VCD and similar devices ) *
257 **************************************************************************/
258 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
259 OpenPanel( _parent, _p_intf )
263 /* Get the default configuration path for the devices */
264 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
265 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
266 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
268 /* State to avoid overwritting the users changes with the configuration */
273 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
274 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
276 #ifdef WIN32 /* Disc drives probing for Windows */
279 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
281 char *drive = szDrives;
282 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
285 if( GetDriveTypeA(drive) == DRIVE_CDROM )
286 ui.deviceCombo->addItem( drive );
288 /* go to next drive */
291 SetErrorMode(oldMode);
293 #else /* Use a Completer under Linux */
294 QCompleter *discCompleter = new QCompleter( this );
295 discCompleter->setModel( new QDirModel( discCompleter ) );
296 ui.deviceCombo->setCompleter( discCompleter );
300 BUTTONACT( ui.dvdRadioButton, updateButtons() );
301 BUTTONACT( ui.vcdRadioButton, updateButtons() );
302 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
303 BUTTONACT( ui.dvdsimple, updateButtons() );
304 BUTTONACT( ui.browseDiscButton, browseDevice() );
305 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
308 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
309 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
310 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
311 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
312 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
314 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
318 DiscOpenPanel::~DiscOpenPanel()
320 free( psz_dvddiscpath );
321 free( psz_vcddiscpath );
322 free( psz_cddadiscpath );
325 void DiscOpenPanel::clear()
327 ui.titleSpin->setValue( 0 );
328 ui.chapterSpin->setValue( 0 );
329 ui.subtitlesSpin->setValue( -1 );
330 ui.audioSpin->setValue( -1 );
337 #define setDrive( psz_name ) {\
338 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
339 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
341 #define setDrive( psz_name ) {\
342 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
345 /* update the buttons according the type of device */
346 void DiscOpenPanel::updateButtons()
348 if ( ui.dvdRadioButton->isChecked() )
352 setDrive( psz_dvddiscpath );
355 ui.titleLabel->setText( qtr("Title") );
356 ui.chapterLabel->show();
357 ui.chapterSpin->show();
358 ui.diskOptionBox_2->show();
359 ui.dvdsimple->setEnabled( true );
361 else if ( ui.vcdRadioButton->isChecked() )
365 setDrive( psz_vcddiscpath );
368 ui.titleLabel->setText( qtr("Entry") );
369 ui.chapterLabel->hide();
370 ui.chapterSpin->hide();
371 ui.diskOptionBox_2->show();
372 ui.dvdsimple->setEnabled( false );
378 setDrive( psz_cddadiscpath );
381 ui.titleLabel->setText( qtr("Track") );
382 ui.chapterLabel->hide();
383 ui.chapterSpin->hide();
384 ui.diskOptionBox_2->hide();
385 ui.dvdsimple->setEnabled( false );
391 /* Update the current MRL */
392 void DiscOpenPanel::updateMRL()
395 QStringList fileList;
397 /* CDDAX and VCDX not implemented. TODO ? No. */
399 if( ui.dvdRadioButton->isChecked() ) {
400 if( !ui.dvdsimple->isChecked() )
403 mrl = "dvdsimple://";
404 mrl += ui.deviceCombo->currentText();
405 emit methodChanged( "dvdnav-caching" );
407 if ( ui.titleSpin->value() > 0 ) {
408 mrl += QString("@%1").arg( ui.titleSpin->value() );
409 if ( ui.chapterSpin->value() > 0 ) {
410 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
415 } else if ( ui.vcdRadioButton->isChecked() ) {
416 mrl = "vcd://" + ui.deviceCombo->currentText();
417 emit methodChanged( "vcd-caching" );
419 if( ui.titleSpin->value() > 0 ) {
420 mrl += QString("@E%1").arg( ui.titleSpin->value() );
425 mrl = "cdda://" + ui.deviceCombo->currentText();
426 if( ui.titleSpin->value() > 0 ) {
427 mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
431 fileList << mrl; mrl = "";
433 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
435 if ( ui.audioSpin->value() >= 0 ) {
436 mrl += " :audio-track=" +
437 QString("%1").arg( ui.audioSpin->value() );
439 if ( ui.subtitlesSpin->value() >= 0 ) {
440 mrl += " :sub-track=" +
441 QString("%1").arg( ui.subtitlesSpin->value() );
444 emit mrlUpdated( fileList, mrl );
447 void DiscOpenPanel::browseDevice()
449 QString dir = QFileDialog::getExistingDirectory( this,
450 qtr( I_DEVICE_TOOLTIP ) );
452 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
457 void DiscOpenPanel::eject()
459 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
462 void DiscOpenPanel::accept()
465 /**************************************************************************
466 * Open Network streams and URL pages *
467 **************************************************************************/
468 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
469 OpenPanel( _parent, _p_intf )
474 CONNECT( ui.protocolCombo, activated( int ),
475 this, updateProtocol( int ) );
476 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
477 CONNECT( ui.addressText, textChanged( const QString& ), this, updateMRL());
479 ui.protocolCombo->addItem( "" );
480 ui.protocolCombo->addItem("HTTP", QVariant("http"));
481 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
482 ui.protocolCombo->addItem("MMS", QVariant("mms"));
483 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
484 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
485 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
486 ui.protocolCombo->addItem("UDP", QVariant("udp"));
487 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
489 updateProtocol( ui.protocolCombo->currentIndex() );
491 if( config_GetInt( p_intf, "qt-recentplay" ) )
493 mrlList = new QStringListModel(
494 getSettings()->value( "Open/netMRL" ).toStringList() );
495 QCompleter *completer = new QCompleter( mrlList, this );
496 ui.addressText->setCompleter( completer );
498 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
504 NetOpenPanel::~NetOpenPanel()
506 if( !mrlList ) return;
508 QStringList tempL = mrlList->stringList();
509 while( tempL.size() > 8 ) tempL.removeFirst();
511 getSettings()->setValue( "Open/netMRL", tempL );
514 void NetOpenPanel::clear()
517 /* update the widgets according the type of protocol */
518 void NetOpenPanel::updateProtocol( int idx_proto ) {
519 QString addr = ui.addressText->text();
520 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
522 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
523 idx_proto == RTP_PROTO );
525 if( idx_proto == NO_PROTO ) return;
527 /* If we already have a protocol in the address, replace it */
528 if( addr.contains( "://"))
530 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
531 addr.replace( QRegExp("^.*://@*"), proto + "://");
532 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
533 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
534 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
535 addr.replace( QRegExp("^.*://"), proto + "://@");
537 addr.replace( QRegExp("^.*://"), proto + "://");
538 addr.replace( QRegExp("@+"), "@");
539 ui.addressText->setText( addr );
544 void NetOpenPanel::updateMRL() {
546 QString addr = ui.addressText->text();
547 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
548 int idx_proto = ui.protocolCombo->currentIndex();
549 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
550 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
551 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
552 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
553 if( addr.contains( "://"))
555 /* Match the correct item in the comboBox */
556 ui.protocolCombo->setCurrentIndex(
557 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
562 switch( idx_proto ) {
564 mrl = "http://" + addr;
565 emit methodChanged("http-caching");
568 mrl = "https://" + addr;
569 emit methodChanged("http-caching");
572 mrl = "mms://" + addr;
573 emit methodChanged("mms-caching");
576 mrl = "ftp://" + addr;
577 emit methodChanged("ftp-caching");
580 mrl = "rtsp://" + addr;
581 emit methodChanged("rtsp-caching");
584 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
589 if ( addr_is_ipv6 && !addr.contains('[') )
591 mrl += "[" + addr + "]";
595 mrl += QString(":%1").arg( ui.portSpin->value() );
596 emit methodChanged("udp-caching");
599 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
603 if ( addr_is_ipv6 && !addr.contains('[') )
604 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
608 mrl += QString(":%1").arg( ui.portSpin->value() );
609 emit methodChanged("rtp-caching");
612 mrl = "rtmp://" + addr;
613 emit methodChanged("rtmp-caching");
618 QStringList qsl; qsl<< mrl;
619 emit mrlUpdated( qsl, "" );
622 void NetOpenPanel::updateCompleter()
625 QStringList tempL = mrlList->stringList();
626 tempL.append( ui.addressText->text() );
627 mrlList->setStringList( tempL );
630 /**************************************************************************
631 * Open Capture device ( DVB, PVR, V4L, and similar ) *
632 **************************************************************************/
633 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
634 OpenPanel( _parent, _p_intf )
636 isInitialized = false;
639 void CaptureOpenPanel::initialize()
641 if( isInitialized ) return;
643 msg_Dbg( p_intf, "Initialization of Capture device panel" );
644 isInitialized = true;
648 BUTTONACT( ui.advancedButton, advancedDialog() );
650 /* Create two stacked layouts in the main comboBoxes */
651 QStackedLayout *stackedDevLayout = new QStackedLayout;
652 ui.cardBox->setLayout( stackedDevLayout );
654 QStackedLayout *stackedPropLayout = new QStackedLayout;
655 ui.optionsBox->setLayout( stackedPropLayout );
657 /* Creation and connections of the WIdgets in the stacked layout */
658 #define addModuleAndLayouts( number, name, label ) \
659 QWidget * name ## DevPage = new QWidget( this ); \
660 QWidget * name ## PropPage = new QWidget( this ); \
661 stackedDevLayout->addWidget( name ## DevPage ); \
662 stackedPropLayout->addWidget( name ## PropPage ); \
663 QGridLayout * name ## DevLayout = new QGridLayout; \
664 QGridLayout * name ## PropLayout = new QGridLayout; \
665 name ## DevPage->setLayout( name ## DevLayout ); \
666 name ## PropPage->setLayout( name ## PropLayout ); \
667 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
669 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
672 /*********************
673 * DirectShow Stuffs *
674 *********************/
675 if( module_exists( "dshow" ) ){
676 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
680 module_config_t *p_config =
681 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
682 vdevDshowW = new StringListConfigControl(
683 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
686 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
687 adevDshowW = new StringListConfigControl(
688 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
691 /* dshow Properties */
692 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
693 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
695 dshowVSizeLine = new QLineEdit;
696 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
697 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
701 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
702 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
703 CuMRL( dshowVSizeLine, textChanged( const QString& ) );
709 if( module_exists( "bda" ) ){
710 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
713 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
715 bdas = new QRadioButton( "DVB-S" );
716 bdas->setChecked( true );
717 bdac = new QRadioButton( "DVB-C" );
718 bdat = new QRadioButton( "DVB-T" );
719 bdaa = new QRadioButton( "ATSC" );
721 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
722 bdaDevLayout->addWidget( bdas, 0, 1 );
723 bdaDevLayout->addWidget( bdac, 0, 2 );
724 bdaDevLayout->addWidget( bdat, 0, 3 );
725 bdaDevLayout->addWidget( bdaa, 0, 4 );
728 QLabel *bdaFreqLabel =
729 new QLabel( qtr( "Transponder/multiplex frequency" ) );
730 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
732 bdaFreq = new QSpinBox;
733 bdaFreq->setAlignment( Qt::AlignRight );
734 bdaFreq->setSuffix(" kHz");
735 bdaFreq->setSingleStep( 1000 );
736 setSpinBoxFreq( bdaFreq )
737 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
739 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
740 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
742 bdaSrate = new QSpinBox;
743 bdaSrate->setAlignment( Qt::AlignRight );
744 bdaSrate->setSuffix(" kHz");
745 setSpinBoxFreq( bdaSrate );
746 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
748 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
749 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
751 bdaBandBox = new QComboBox;
752 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
753 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
755 bdaBandLabel->hide();
757 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
761 CuMRL( bdaFreq, valueChanged ( int ) );
762 CuMRL( bdaSrate, valueChanged ( int ) );
763 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
764 BUTTONACT( bdas, updateButtons() );
765 BUTTONACT( bdat, updateButtons() );
766 BUTTONACT( bdac, updateButtons() );
767 BUTTONACT( bdaa, updateButtons() );
768 BUTTONACT( bdas, updateMRL() );
769 BUTTONACT( bdat, updateMRL() );
770 BUTTONACT( bdac, updateMRL() );
771 BUTTONACT( bdaa, updateMRL() );
778 if( module_exists( "v4l2" ) ){
779 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
782 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
783 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
785 v4l2VideoDevice = new QLineEdit;
786 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
788 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
789 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
791 v4l2AudioDevice = new QLineEdit;
792 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
794 /* v4l2 Props panel */
795 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
796 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
798 v4l2StdBox = new QComboBox;
799 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
800 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
801 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
805 CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
806 CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
807 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
813 if( module_exists( "v4l" ) ){
814 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
817 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
818 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
820 v4lVideoDevice = new QLineEdit;
821 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
823 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
824 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
826 v4lAudioDevice = new QLineEdit;
827 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
829 /* V4l Props panel */
830 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
831 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
833 v4lNormBox = new QComboBox;
834 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
835 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
837 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
838 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
840 v4lFreq = new QSpinBox;
841 v4lFreq->setAlignment( Qt::AlignRight );
842 v4lFreq->setSuffix(" kHz");
843 setSpinBoxFreq( v4lFreq );
844 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
845 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
849 CuMRL( v4lVideoDevice, textChanged( const QString& ) );
850 CuMRL( v4lAudioDevice, textChanged( const QString& ) );
851 CuMRL( v4lFreq, valueChanged ( int ) );
852 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
858 if( module_exists( "jack" ) ){
859 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
861 /* Jack Main panel */
863 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
864 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
866 jackChannels = new QSpinBox;
867 setSpinBoxFreq( jackChannels );
868 jackChannels->setMaximum(255);
869 jackChannels->setValue(2);
870 jackChannels->setAlignment( Qt::AlignRight );
871 jackDevLayout->addWidget( jackChannels, 1, 1 );
874 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
875 jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
877 jackPortsSelected = new QLineEdit( qtr( ".*") );
878 jackPortsSelected->setAlignment( Qt::AlignRight );
879 jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
881 /* Jack Props panel */
884 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
885 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
886 jackCaching = new QSpinBox;
887 setSpinBoxFreq( jackCaching );
888 jackCaching->setSuffix( " ms" );
889 jackCaching->setValue(1000);
890 jackCaching->setAlignment( Qt::AlignRight );
891 jackPropLayout->addWidget( jackCaching, 1 , 2 );
894 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
895 jackPropLayout->addWidget( jackPace, 2, 1 );
898 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
899 jackPropLayout->addWidget( jackConnect, 2, 2 );
902 CuMRL( jackChannels, valueChanged( int ) );
903 CuMRL( jackCaching, valueChanged( int ) );
904 CuMRL( jackPace, stateChanged( int ) );
905 CuMRL( jackConnect, stateChanged( int ) );
906 CuMRL( jackPortsSelected, textChanged( const QString& ) );
912 if( module_exists( "pvr" ) ){
913 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
916 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
917 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
919 pvrDevice = new QLineEdit;
920 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
922 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
923 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
925 pvrRadioDevice = new QLineEdit;
926 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
928 /* PVR props panel */
929 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
930 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
932 pvrNormBox = new QComboBox;
933 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
934 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
936 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
937 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
939 pvrFreq = new QSpinBox;
940 pvrFreq->setAlignment( Qt::AlignRight );
941 pvrFreq->setSuffix(" kHz");
942 setSpinBoxFreq( pvrFreq );
943 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
945 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
946 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
948 pvrBitr = new QSpinBox;
949 pvrBitr->setAlignment( Qt::AlignRight );
950 pvrBitr->setSuffix(" kHz");
951 setSpinBoxFreq( pvrBitr );
952 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
953 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
957 CuMRL( pvrDevice, textChanged( const QString& ) );
958 CuMRL( pvrRadioDevice, textChanged( const QString& ) );
960 CuMRL( pvrFreq, valueChanged ( int ) );
961 CuMRL( pvrBitr, valueChanged ( int ) );
962 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
968 if( module_exists( "dvb" ) ){
969 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
972 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
973 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
975 dvbCard = new QSpinBox;
976 dvbCard->setAlignment( Qt::AlignRight );
977 dvbCard->setPrefix( "/dev/dvb/adapter" );
979 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
980 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
982 dvbs = new QRadioButton( "DVB-S" );
983 dvbs->setChecked( true );
984 dvbc = new QRadioButton( "DVB-C" );
985 dvbt = new QRadioButton( "DVB-T" );
987 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
988 dvbDevLayout->addWidget( dvbs, 1, 1 );
989 dvbDevLayout->addWidget( dvbc, 1, 2 );
990 dvbDevLayout->addWidget( dvbt, 1, 3 );
992 /* DVB Props panel */
993 QLabel *dvbFreqLabel =
994 new QLabel( qtr( "Transponder/multiplex frequency" ) );
995 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
997 dvbFreq = new QSpinBox;
998 dvbFreq->setAlignment( Qt::AlignRight );
999 dvbFreq->setSuffix(" kHz");
1000 setSpinBoxFreq( dvbFreq );
1001 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
1003 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
1004 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
1006 dvbSrate = new QSpinBox;
1007 dvbSrate->setAlignment( Qt::AlignRight );
1008 dvbSrate->setSuffix(" kHz");
1009 setSpinBoxFreq( dvbSrate );
1010 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
1011 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
1015 CuMRL( dvbCard, valueChanged ( int ) );
1016 CuMRL( dvbFreq, valueChanged ( int ) );
1017 CuMRL( dvbSrate, valueChanged ( int ) );
1019 BUTTONACT( dvbs, updateButtons() );
1020 BUTTONACT( dvbt, updateButtons() );
1021 BUTTONACT( dvbc, updateButtons() );
1030 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
1031 QLabel *screenLabel = new QLabel( "Your display will will be "
1032 "opened and played in order to stream or save it." );
1033 screenLabel->setWordWrap( true );
1034 screenDevLayout->addWidget( screenLabel, 0, 0 );
1036 QLabel *screenFPSLabel = new QLabel(
1037 qtr( "Desired frame rate for the capture." ) );
1038 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1040 screenFPS = new QSpinBox;
1041 screenFPS->setValue( 1 );
1042 screenFPS->setAlignment( Qt::AlignRight );
1043 screenPropLayout->addWidget( screenFPS, 0, 1 );
1045 /* General connects */
1046 CONNECT( ui.deviceCombo, activated( int ) ,
1047 stackedDevLayout, setCurrentIndex( int ) );
1048 CONNECT( ui.deviceCombo, activated( int ),
1049 stackedPropLayout, setCurrentIndex( int ) );
1050 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1051 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1056 CaptureOpenPanel::~CaptureOpenPanel()
1060 void CaptureOpenPanel::clear()
1065 void CaptureOpenPanel::updateMRL()
1068 QStringList fileList;
1069 int i_devicetype = ui.deviceCombo->itemData(
1070 ui.deviceCombo->currentIndex() ).toInt();
1071 switch( i_devicetype )
1075 if( bdas->isChecked() ) mrl = "dvb-s://";
1076 else if( bdat->isChecked() ) mrl = "dvb-t://";
1077 else if( bdac->isChecked() ) mrl = "dvb-c://";
1078 else if( bdaa->isChecked() ) mrl = "atsc://";
1080 fileList << mrl; mrl = "";
1082 mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
1083 if( bdas->isChecked() || bdac->isChecked() )
1084 mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1085 else if( bdat->isChecked() )
1086 mrl += " :dvb-bandwidth=" +
1087 QString::number( bdaBandBox->itemData(
1088 bdaBandBox->currentIndex() ).toInt() );
1091 fileList << "dshow://";
1092 mrl+= " :dshow-vdev=" +
1093 colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1094 mrl+= " :dshow-adev=" +
1095 colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
1096 if( dshowVSizeLine->isModified() )
1097 mrl += " :dshow-size=" + dshowVSizeLine->text();
1101 fileList << "v4l://";
1102 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1103 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1104 mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1105 mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1108 fileList << "v4l2://";
1109 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1110 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1111 mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1115 mrl += "channels=" + QString::number( jackChannels->value() );
1116 mrl += ":ports=" + jackPortsSelected->text();
1117 fileList << mrl; mrl = "";
1119 mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1120 if ( jackPace->isChecked() )
1122 mrl += " :jack-input-use-vlc-pace";
1124 if ( jackConnect->isChecked() )
1126 mrl += " :jack-input-auto-connect";
1130 fileList << "pvr://";
1131 mrl += " :pvr-device=" + pvrDevice->text();
1132 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1133 mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1134 if( pvrFreq->value() )
1135 mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1136 if( pvrBitr->value() )
1137 mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1140 fileList << "dvb://";
1141 mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1142 mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
1143 mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1147 fileList << "screen://";
1148 mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1153 if( !advMRL.isEmpty() ) mrl += advMRL;
1155 emit mrlUpdated( fileList, mrl );
1159 * Update the Buttons (show/hide) for the GUI as all device type don't
1160 * use the same ui. elements.
1162 void CaptureOpenPanel::updateButtons()
1164 /* Be sure to display the ui Elements in case they were hidden by
1165 * some Device Type (like Screen://) */
1166 ui.optionsBox->show();
1167 ui.advancedButton->show();
1168 /* Get the current Device Number */
1169 int i_devicetype = ui.deviceCombo->itemData(
1170 ui.deviceCombo->currentIndex() ).toInt();
1171 switch( i_devicetype )
1175 if( bdas->isChecked() || bdac->isChecked() )
1178 bdaSrateLabel->show();
1180 bdaBandLabel->hide();
1182 else if( bdat->isChecked() )
1185 bdaSrateLabel->hide();
1187 bdaBandLabel->show();
1192 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1193 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1197 //ui.optionsBox->hide();
1198 ui.advancedButton->hide();
1205 void CaptureOpenPanel::advancedDialog()
1207 /* Get selected device type */
1208 int i_devicetype = ui.deviceCombo->itemData(
1209 ui.deviceCombo->currentIndex() ).toInt();
1211 /* Get the corresponding module */
1212 module_t *p_module =
1213 module_find( psz_devModule[i_devicetype] );
1214 if( NULL == p_module ) return;
1217 QList<ConfigControl *> controls;
1219 /* Get the confsize */
1220 unsigned int i_confsize;
1221 module_config_t *p_config;
1222 p_config = module_config_get( p_module, &i_confsize );
1224 /* New Adv Prop dialog */
1225 adv = new QDialog( this );
1226 adv->setWindowTitle( qtr( "Advanced Options" ) );
1228 /* A main Layout with a Frame */
1229 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1230 QScrollArea *scroll = new QScrollArea;
1231 mainLayout->addWidget( scroll );
1233 QFrame *advFrame = new QFrame;
1234 /* GridLayout inside the Frame */
1235 QGridLayout *gLayout = new QGridLayout( advFrame );
1237 scroll->setWidgetResizable( true );
1238 scroll->setWidget( advFrame );
1240 /* Create the options inside the FrameLayout */
1241 for( int n = 0; n < (int)i_confsize; n++ )
1243 module_config_t *p_item = p_config + n;
1244 ConfigControl *config = ConfigControl::createControl(
1245 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1246 controls.append( config );
1250 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1251 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1252 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1254 CONNECT( closeButton, clicked(), adv, accept() );
1255 CONNECT( cancelButton, clicked(), adv, reject() );
1257 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1258 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1260 mainLayout->addWidget( advButtonBox );
1262 /* Creation of the MRL */
1265 QString tempMRL = "";
1266 for( int i = 0; i < controls.size(); i++ )
1268 ConfigControl *control = controls[i];
1271 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1275 tempMRL += (i ? " :" : ":");
1277 if( control->getType() == CONFIG_ITEM_BOOL )
1278 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1281 tempMRL += control->getName();
1283 switch( control->getType() )
1285 case CONFIG_ITEM_STRING:
1286 case CONFIG_ITEM_FILE:
1287 case CONFIG_ITEM_DIRECTORY:
1288 case CONFIG_ITEM_MODULE:
1289 tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1291 case CONFIG_ITEM_INTEGER:
1292 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1294 case CONFIG_ITEM_FLOAT:
1295 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1301 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1304 module_config_free( p_config );
1305 module_release (p_module);