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 )
61 /* Classic UI Setup */
65 /** BEGIN QFileDialog tweaking **/
66 /* Use a QFileDialog and customize it because we don't want to
67 rewrite it all. Be careful to your eyes cause there are a few hacks.
68 Be very careful and test correctly when you modify this. */
70 /* Set Filters for file selection */
71 QString fileTypes = "";
72 ADD_FILTER_MEDIA( fileTypes );
73 ADD_FILTER_VIDEO( fileTypes );
74 ADD_FILTER_AUDIO( fileTypes );
75 ADD_FILTER_PLAYLIST( fileTypes );
76 ADD_FILTER_ALL( fileTypes );
77 fileTypes.replace( QString(";*"), QString(" *"));
79 // Make this QFileDialog a child of tempWidget from the ui.
80 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
81 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
83 dialogBox->setFileMode( QFileDialog::ExistingFiles );
84 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
85 dialogBox->restoreState(
86 getSettings()->value( "file-dialog-state" ).toByteArray() );
88 /* We don't want to see a grip in the middle of the window, do we? */
89 dialogBox->setSizeGripEnabled( false );
92 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
93 dialogBox->setMinimumHeight( 250 );
95 // But hide the two OK/Cancel buttons. Enable them for debug.
96 QDialogButtonBox *fileDialogAcceptBox =
97 dialogBox->findChildren<QDialogButtonBox*>()[0];
98 fileDialogAcceptBox->hide();
100 /* Ugly hacks to get the good Widget */
101 //This lineEdit is the normal line in the fileDialog.
102 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
103 /* Make a list of QLabel inside the QFileDialog to access the good ones */
104 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
106 /* Hide the FileNames one. Enable it for debug */
107 listLabel[1]->setText( qtr( "File names:" ) );
108 /* Change the text that was uncool in the usual box */
109 listLabel[2]->setText( qtr( "Filter:" ) );
111 dialogBox->layout()->setMargin( 0 );
112 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
114 /** END of QFileDialog tweaking **/
116 // Add the DialogBox to the layout
117 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
120 /* lineFileEdit = ui.fileEdit;
121 //TODO later: fill the fileCompleteList with previous items played.
122 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
123 fileCompleter->setModel( new QDirModel( fileCompleter ) );
124 lineFileEdit->setCompleter( fileCompleter );*/
126 // Hide the subtitles control by default.
127 ui.subFrame->setEnabled( false );
129 /* Build the subs size combo box */
130 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
131 ui.sizeSubComboBox );
133 /* Build the subs align combo box */
134 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
137 BUTTONACT( ui.fileBrowseButton, browseFile() );
138 BUTTONACT( ui.delFileButton, deleteFile() );
139 BUTTONACT( ui.subBrowseButton, browseFileSub() );
140 CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
142 CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
143 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
144 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
145 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
148 FileOpenPanel::~FileOpenPanel()
150 // getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
153 void FileOpenPanel::browseFile()
155 QStringList files = QFileDialog::getOpenFileNames( this );
156 foreach( const QString &file, files)
158 QListWidgetItem *item = new QListWidgetItem( file, ui.fileListWidg );
159 item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
160 ui.fileListWidg->addItem( item );
165 void FileOpenPanel::deleteFile()
167 int i = ui.fileListWidg->currentRow();
170 QListWidgetItem *temp = ui.fileListWidg->takeItem( i );
177 /* Show a fileBrowser to select a subtitle */
178 void FileOpenPanel::browseFileSub()
180 // TODO Handle selection of more than one subtitles file
181 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
182 EXT_FILTER_SUBTITLE, p_intf->p_sys->psz_filepath );
184 if( files.isEmpty() ) return;
185 ui.subInput->setText( files.join(" ") );
189 void FileOpenPanel::toggleSubtitleFrame( bool b )
191 ui.subFrame->setEnabled( b );
198 /* Update the current MRL */
199 void FileOpenPanel::updateMRL()
201 QStringList fileList;
204 for( int i = 0; i < ui.fileListWidg->count(); i++ )
206 if( !ui.fileListWidg->item( i )->text().isEmpty() )
207 fileList << ui.fileListWidg->item( i )->text();
210 if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) {
211 mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
212 int align = ui.alignSubComboBox->itemData(
213 ui.alignSubComboBox->currentIndex() ).toInt();
214 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
215 int size = ui.sizeSubComboBox->itemData(
216 ui.sizeSubComboBox->currentIndex() ).toInt();
217 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
220 emit mrlUpdated( fileList, mrl );
221 emit methodChanged( "file-caching" );
224 /* Function called by Open Dialog when clicke on Play/Enqueue */
225 void FileOpenPanel::accept()
228 // p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
229 ui.fileListWidg->clear();
232 /* Function called by Open Dialog when clicked on cancel */
233 void FileOpenPanel::clear()
235 ui.fileListWidg->clear();
236 ui.subInput->clear();
239 /**************************************************************************
240 * Open Discs ( DVD, CD, VCD and similar devices ) *
241 **************************************************************************/
242 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
243 OpenPanel( _parent, _p_intf )
247 /* Get the default configuration path for the devices */
248 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
249 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
250 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
252 /* State to avoid overwritting the users changes with the configuration */
257 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
258 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
260 #ifdef WIN32 /* Disc drives probing for Windows */
263 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
265 char *drive = szDrives;
266 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
269 if( GetDriveTypeA(drive) == DRIVE_CDROM )
270 ui.deviceCombo->addItem( drive );
272 /* go to next drive */
275 SetErrorMode(oldMode);
277 #else /* Use a Completer under Linux */
278 QCompleter *discCompleter = new QCompleter( this );
279 discCompleter->setModel( new QDirModel( discCompleter ) );
280 ui.deviceCombo->setCompleter( discCompleter );
284 BUTTONACT( ui.dvdRadioButton, updateButtons() );
285 BUTTONACT( ui.vcdRadioButton, updateButtons() );
286 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
287 BUTTONACT( ui.dvdsimple, updateButtons() );
288 BUTTONACT( ui.browseDiscButton, browseDevice() );
289 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
292 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
293 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
294 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
295 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
296 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
298 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
302 DiscOpenPanel::~DiscOpenPanel()
304 free( psz_dvddiscpath );
305 free( psz_vcddiscpath );
306 free( psz_cddadiscpath );
309 void DiscOpenPanel::clear()
311 ui.titleSpin->setValue( 0 );
312 ui.chapterSpin->setValue( 0 );
313 ui.subtitlesSpin->setValue( -1 );
314 ui.audioSpin->setValue( -1 );
321 #define setDrive( psz_name ) {\
322 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
323 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
325 #define setDrive( psz_name ) {\
326 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
329 /* update the buttons according the type of device */
330 void DiscOpenPanel::updateButtons()
332 if ( ui.dvdRadioButton->isChecked() )
336 setDrive( psz_dvddiscpath );
339 ui.titleLabel->setText( qtr("Title") );
340 ui.chapterLabel->show();
341 ui.chapterSpin->show();
342 ui.diskOptionBox_2->show();
343 ui.dvdsimple->setEnabled( true );
345 else if ( ui.vcdRadioButton->isChecked() )
349 setDrive( psz_vcddiscpath );
352 ui.titleLabel->setText( qtr("Entry") );
353 ui.chapterLabel->hide();
354 ui.chapterSpin->hide();
355 ui.diskOptionBox_2->show();
356 ui.dvdsimple->setEnabled( false );
362 setDrive( psz_cddadiscpath );
365 ui.titleLabel->setText( qtr("Track") );
366 ui.chapterLabel->hide();
367 ui.chapterSpin->hide();
368 ui.diskOptionBox_2->hide();
369 ui.dvdsimple->setEnabled( false );
375 /* Update the current MRL */
376 void DiscOpenPanel::updateMRL()
379 QStringList fileList;
381 /* CDDAX and VCDX not implemented. TODO ? No. */
383 if( ui.dvdRadioButton->isChecked() ) {
384 if( !ui.dvdsimple->isChecked() )
387 mrl = "dvdsimple://";
388 mrl += ui.deviceCombo->currentText();
389 emit methodChanged( "dvdnav-caching" );
391 if ( ui.titleSpin->value() > 0 ) {
392 mrl += QString("@%1").arg( ui.titleSpin->value() );
393 if ( ui.chapterSpin->value() > 0 ) {
394 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
399 } else if ( ui.vcdRadioButton->isChecked() ) {
400 mrl = "vcd://" + ui.deviceCombo->currentText();
401 emit methodChanged( "vcd-caching" );
403 if( ui.titleSpin->value() > 0 ) {
404 mrl += QString("@E%1").arg( ui.titleSpin->value() );
409 mrl = "cdda://" + ui.deviceCombo->currentText();
410 if( ui.titleSpin->value() > 0 ) {
411 mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
415 fileList << mrl; mrl = "";
417 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
419 if ( ui.audioSpin->value() >= 0 ) {
420 mrl += " :audio-track=" +
421 QString("%1").arg( ui.audioSpin->value() );
423 if ( ui.subtitlesSpin->value() >= 0 ) {
424 mrl += " :sub-track=" +
425 QString("%1").arg( ui.subtitlesSpin->value() );
428 emit mrlUpdated( fileList, mrl );
431 void DiscOpenPanel::browseDevice()
433 QString dir = QFileDialog::getExistingDirectory( this,
434 qtr( I_DEVICE_TOOLTIP ) );
436 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
441 void DiscOpenPanel::eject()
443 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
446 void DiscOpenPanel::accept()
449 /**************************************************************************
450 * Open Network streams and URL pages *
451 **************************************************************************/
452 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
453 OpenPanel( _parent, _p_intf )
458 CONNECT( ui.protocolCombo, activated( int ),
459 this, updateProtocol( int ) );
460 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
461 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
463 ui.protocolCombo->addItem( "" );
464 ui.protocolCombo->addItem("HTTP", QVariant("http"));
465 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
466 ui.protocolCombo->addItem("MMS", QVariant("mms"));
467 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
468 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
469 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
470 ui.protocolCombo->addItem("UDP", QVariant("udp"));
471 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
473 updateProtocol( ui.protocolCombo->currentIndex() );
475 if( config_GetInt( p_intf, "qt-recentplay" ) )
477 mrlList = new QStringListModel(
478 getSettings()->value( "Open/netMRL" ).toStringList() );
479 QCompleter *completer = new QCompleter( mrlList, this );
480 ui.addressText->setCompleter( completer );
482 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
488 NetOpenPanel::~NetOpenPanel()
490 if( !mrlList ) return;
492 QStringList tempL = mrlList->stringList();
493 while( tempL.size() > 8 ) tempL.removeFirst();
495 getSettings()->setValue( "Open/netMRL", tempL );
498 void NetOpenPanel::clear()
501 /* update the widgets according the type of protocol */
502 void NetOpenPanel::updateProtocol( int idx_proto ) {
503 QString addr = ui.addressText->text();
504 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
506 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
507 idx_proto == RTP_PROTO );
509 if( idx_proto == NO_PROTO ) return;
511 /* If we already have a protocol in the address, replace it */
512 if( addr.contains( "://"))
514 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
515 addr.replace( QRegExp("^.*://@*"), proto + "://");
516 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
517 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
518 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
519 addr.replace( QRegExp("^.*://"), proto + "://@");
521 addr.replace( QRegExp("^.*://"), proto + "://");
522 addr.replace( QRegExp("@+"), "@");
523 ui.addressText->setText( addr );
528 void NetOpenPanel::updateMRL() {
530 QString addr = ui.addressText->text();
531 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
532 int idx_proto = ui.protocolCombo->currentIndex();
533 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
534 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
535 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
536 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
537 if( addr.contains( "://"))
539 /* Match the correct item in the comboBox */
540 ui.protocolCombo->setCurrentIndex(
541 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
546 switch( idx_proto ) {
548 mrl = "http://" + addr;
549 emit methodChanged("http-caching");
552 mrl = "https://" + addr;
553 emit methodChanged("http-caching");
556 mrl = "mms://" + addr;
557 emit methodChanged("mms-caching");
560 mrl = "ftp://" + addr;
561 emit methodChanged("ftp-caching");
564 mrl = "rtsp://" + addr;
565 emit methodChanged("rtsp-caching");
568 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
573 if ( addr_is_ipv6 && !addr.contains('[') )
575 mrl += "[" + addr + "]";
579 mrl += QString(":%1").arg( ui.portSpin->value() );
580 emit methodChanged("udp-caching");
583 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
587 if ( addr_is_ipv6 && !addr.contains('[') )
588 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
592 mrl += QString(":%1").arg( ui.portSpin->value() );
593 emit methodChanged("rtp-caching");
596 mrl = "rtmp://" + addr;
597 emit methodChanged("rtmp-caching");
602 QStringList qsl; qsl<< mrl;
603 emit mrlUpdated( qsl, "" );
606 void NetOpenPanel::updateCompleter()
609 QStringList tempL = mrlList->stringList();
610 tempL.append( ui.addressText->text() );
611 mrlList->setStringList( tempL );
614 /**************************************************************************
615 * Open Capture device ( DVB, PVR, V4L, and similar ) *
616 **************************************************************************/
617 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
618 OpenPanel( _parent, _p_intf )
620 isInitialized = false;
623 void CaptureOpenPanel::initialize()
625 if( isInitialized ) return;
627 msg_Dbg( p_intf, "Initialization of Capture device panel" );
628 isInitialized = true;
632 BUTTONACT( ui.advancedButton, advancedDialog() );
634 /* Create two stacked layouts in the main comboBoxes */
635 QStackedLayout *stackedDevLayout = new QStackedLayout;
636 ui.cardBox->setLayout( stackedDevLayout );
638 QStackedLayout *stackedPropLayout = new QStackedLayout;
639 ui.optionsBox->setLayout( stackedPropLayout );
641 /* Creation and connections of the WIdgets in the stacked layout */
642 #define addModuleAndLayouts( number, name, label ) \
643 QWidget * name ## DevPage = new QWidget( this ); \
644 QWidget * name ## PropPage = new QWidget( this ); \
645 stackedDevLayout->addWidget( name ## DevPage ); \
646 stackedPropLayout->addWidget( name ## PropPage ); \
647 QGridLayout * name ## DevLayout = new QGridLayout; \
648 QGridLayout * name ## PropLayout = new QGridLayout; \
649 name ## DevPage->setLayout( name ## DevLayout ); \
650 name ## PropPage->setLayout( name ## PropLayout ); \
651 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
653 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
656 /*********************
657 * DirectShow Stuffs *
658 *********************/
659 if( module_exists( "dshow" ) ){
660 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
664 module_config_t *p_config =
665 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
666 vdevDshowW = new StringListConfigControl(
667 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
670 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
671 adevDshowW = new StringListConfigControl(
672 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
675 /* dshow Properties */
676 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
677 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
679 dshowVSizeLine = new QLineEdit;
680 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
681 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
685 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
686 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
687 CuMRL( dshowVSizeLine, textChanged( QString ) );
693 if( module_exists( "bda" ) ){
694 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
697 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
699 bdas = new QRadioButton( "DVB-S" );
700 bdas->setChecked( true );
701 bdac = new QRadioButton( "DVB-C" );
702 bdat = new QRadioButton( "DVB-T" );
703 bdaa = new QRadioButton( "ATSC" );
705 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
706 bdaDevLayout->addWidget( bdas, 0, 1 );
707 bdaDevLayout->addWidget( bdac, 0, 2 );
708 bdaDevLayout->addWidget( bdat, 0, 3 );
709 bdaDevLayout->addWidget( bdaa, 0, 4 );
712 QLabel *bdaFreqLabel =
713 new QLabel( qtr( "Transponder/multiplex frequency" ) );
714 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
716 bdaFreq = new QSpinBox;
717 bdaFreq->setAlignment( Qt::AlignRight );
718 bdaFreq->setSuffix(" kHz");
719 bdaFreq->setSingleStep( 1000 );
720 setSpinBoxFreq( bdaFreq )
721 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
723 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
724 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
726 bdaSrate = new QSpinBox;
727 bdaSrate->setAlignment( Qt::AlignRight );
728 bdaSrate->setSuffix(" kHz");
729 setSpinBoxFreq( bdaSrate );
730 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
732 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
733 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
735 bdaBandBox = new QComboBox;
736 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
737 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
739 bdaBandLabel->hide();
741 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
745 CuMRL( bdaFreq, valueChanged ( int ) );
746 CuMRL( bdaSrate, valueChanged ( int ) );
747 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
748 BUTTONACT( bdas, updateButtons() );
749 BUTTONACT( bdat, updateButtons() );
750 BUTTONACT( bdac, updateButtons() );
751 BUTTONACT( bdaa, updateButtons() );
752 BUTTONACT( bdas, updateMRL() );
753 BUTTONACT( bdat, updateMRL() );
754 BUTTONACT( bdac, updateMRL() );
755 BUTTONACT( bdaa, updateMRL() );
762 if( module_exists( "v4l2" ) ){
763 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
766 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
767 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
769 v4l2VideoDevice = new QLineEdit;
770 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
772 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
773 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
775 v4l2AudioDevice = new QLineEdit;
776 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
778 /* v4l2 Props panel */
779 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
780 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
782 v4l2StdBox = new QComboBox;
783 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
784 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
785 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
789 CuMRL( v4l2VideoDevice, textChanged( QString ) );
790 CuMRL( v4l2AudioDevice, textChanged( QString ) );
791 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
797 if( module_exists( "v4l" ) ){
798 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
801 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
802 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
804 v4lVideoDevice = new QLineEdit;
805 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
807 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
808 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
810 v4lAudioDevice = new QLineEdit;
811 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
813 /* V4l Props panel */
814 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
815 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
817 v4lNormBox = new QComboBox;
818 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
819 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
821 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
822 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
824 v4lFreq = new QSpinBox;
825 v4lFreq->setAlignment( Qt::AlignRight );
826 v4lFreq->setSuffix(" kHz");
827 setSpinBoxFreq( v4lFreq );
828 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
829 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
833 CuMRL( v4lVideoDevice, textChanged( QString ) );
834 CuMRL( v4lAudioDevice, textChanged( QString ) );
835 CuMRL( v4lFreq, valueChanged ( int ) );
836 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
842 if( module_exists( "jack" ) ){
843 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
845 /* Jack Main panel */
847 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
848 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
850 jackChannels = new QSpinBox;
851 setSpinBoxFreq( jackChannels );
852 jackChannels->setMaximum(255);
853 jackChannels->setValue(2);
854 jackChannels->setAlignment( Qt::AlignRight );
855 jackDevLayout->addWidget( jackChannels, 1, 1 );
858 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
859 jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
861 jackPortsSelected = new QLineEdit( qtr( ".*") );
862 jackPortsSelected->setAlignment( Qt::AlignRight );
863 jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
865 /* Jack Props panel */
868 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
869 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
870 jackCaching = new QSpinBox;
871 setSpinBoxFreq( jackCaching );
872 jackCaching->setSuffix( " ms" );
873 jackCaching->setValue(1000);
874 jackCaching->setAlignment( Qt::AlignRight );
875 jackPropLayout->addWidget( jackCaching, 1 , 2 );
878 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
879 jackPropLayout->addWidget( jackPace, 2, 1 );
882 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
883 jackPropLayout->addWidget( jackConnect, 2, 2 );
886 CuMRL( jackChannels, valueChanged( int ) );
887 CuMRL( jackCaching, valueChanged( int ) );
888 CuMRL( jackPace, stateChanged( int ) );
889 CuMRL( jackConnect, stateChanged( int ) );
890 CuMRL( jackPortsSelected, textChanged( QString ) );
896 if( module_exists( "pvr" ) ){
897 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
900 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
901 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
903 pvrDevice = new QLineEdit;
904 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
906 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
907 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
909 pvrRadioDevice = new QLineEdit;
910 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
912 /* PVR props panel */
913 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
914 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
916 pvrNormBox = new QComboBox;
917 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
918 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
920 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
921 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
923 pvrFreq = new QSpinBox;
924 pvrFreq->setAlignment( Qt::AlignRight );
925 pvrFreq->setSuffix(" kHz");
926 setSpinBoxFreq( pvrFreq );
927 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
929 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
930 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
932 pvrBitr = new QSpinBox;
933 pvrBitr->setAlignment( Qt::AlignRight );
934 pvrBitr->setSuffix(" kHz");
935 setSpinBoxFreq( pvrBitr );
936 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
937 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
941 CuMRL( pvrDevice, textChanged( QString ) );
942 CuMRL( pvrRadioDevice, textChanged( QString ) );
944 CuMRL( pvrFreq, valueChanged ( int ) );
945 CuMRL( pvrBitr, valueChanged ( int ) );
946 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
952 if( module_exists( "dvb" ) ){
953 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
956 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
957 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
959 dvbCard = new QSpinBox;
960 dvbCard->setAlignment( Qt::AlignRight );
961 dvbCard->setPrefix( "/dev/dvb/adapter" );
963 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
964 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
966 dvbs = new QRadioButton( "DVB-S" );
967 dvbs->setChecked( true );
968 dvbc = new QRadioButton( "DVB-C" );
969 dvbt = new QRadioButton( "DVB-T" );
971 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
972 dvbDevLayout->addWidget( dvbs, 1, 1 );
973 dvbDevLayout->addWidget( dvbc, 1, 2 );
974 dvbDevLayout->addWidget( dvbt, 1, 3 );
976 /* DVB Props panel */
977 QLabel *dvbFreqLabel =
978 new QLabel( qtr( "Transponder/multiplex frequency" ) );
979 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
981 dvbFreq = new QSpinBox;
982 dvbFreq->setAlignment( Qt::AlignRight );
983 dvbFreq->setSuffix(" kHz");
984 setSpinBoxFreq( dvbFreq );
985 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
987 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
988 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
990 dvbSrate = new QSpinBox;
991 dvbSrate->setAlignment( Qt::AlignRight );
992 dvbSrate->setSuffix(" kHz");
993 setSpinBoxFreq( dvbSrate );
994 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
995 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
999 CuMRL( dvbCard, valueChanged ( int ) );
1000 CuMRL( dvbFreq, valueChanged ( int ) );
1001 CuMRL( dvbSrate, valueChanged ( int ) );
1003 BUTTONACT( dvbs, updateButtons() );
1004 BUTTONACT( dvbt, updateButtons() );
1005 BUTTONACT( dvbc, updateButtons() );
1014 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
1015 QLabel *screenLabel = new QLabel( "Your display will will be "
1016 "opened and played in order to stream or save it." );
1017 screenLabel->setWordWrap( true );
1018 screenDevLayout->addWidget( screenLabel, 0, 0 );
1020 QLabel *screenFPSLabel = new QLabel(
1021 qtr( "Desired frame rate for the capture." ) );
1022 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1024 screenFPS = new QSpinBox;
1025 screenFPS->setValue( 1 );
1026 screenFPS->setAlignment( Qt::AlignRight );
1027 screenPropLayout->addWidget( screenFPS, 0, 1 );
1029 /* General connects */
1030 CONNECT( ui.deviceCombo, activated( int ) ,
1031 stackedDevLayout, setCurrentIndex( int ) );
1032 CONNECT( ui.deviceCombo, activated( int ),
1033 stackedPropLayout, setCurrentIndex( int ) );
1034 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1035 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1040 CaptureOpenPanel::~CaptureOpenPanel()
1044 void CaptureOpenPanel::clear()
1049 void CaptureOpenPanel::updateMRL()
1052 QStringList fileList;
1053 int i_devicetype = ui.deviceCombo->itemData(
1054 ui.deviceCombo->currentIndex() ).toInt();
1055 switch( i_devicetype )
1059 if( bdas->isChecked() ) mrl = "dvb-s://";
1060 else if( bdat->isChecked() ) mrl = "dvb-t://";
1061 else if( bdac->isChecked() ) mrl = "dvb-c://";
1062 else if( bdaa->isChecked() ) mrl = "atsc://";
1064 fileList << mrl; mrl = "";
1066 mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
1067 if( bdas->isChecked() || bdac->isChecked() )
1068 mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1069 else if( bdat->isChecked() )
1070 mrl += " :dvb-bandwidth=" +
1071 QString::number( bdaBandBox->itemData(
1072 bdaBandBox->currentIndex() ).toInt() );
1075 fileList << "dshow://";
1076 mrl+= " :dshow-vdev=" +
1077 colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1078 mrl+= " :dshow-adev=" +
1079 colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
1080 if( dshowVSizeLine->isModified() )
1081 mrl += " :dshow-size=" + dshowVSizeLine->text();
1085 fileList << "v4l://";
1086 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1087 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1088 mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1089 mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1092 fileList << "v4l2://";
1093 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1094 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1095 mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1099 mrl += "channels=" + QString::number( jackChannels->value() );
1100 mrl += ":ports=" + jackPortsSelected->text();
1101 fileList << mrl; mrl = "";
1103 mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1104 if ( jackPace->isChecked() )
1106 mrl += " :jack-input-use-vlc-pace";
1108 if ( jackConnect->isChecked() )
1110 mrl += " :jack-input-auto-connect";
1114 fileList << "pvr://";
1115 mrl += " :pvr-device=" + pvrDevice->text();
1116 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1117 mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1118 if( pvrFreq->value() )
1119 mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1120 if( pvrBitr->value() )
1121 mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1124 fileList << "dvb://";
1125 mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1126 mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
1127 mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1131 fileList << "screen://";
1132 mrl = " :screen-fps=" + QString::number( screenFPS->value() );
1137 if( !advMRL.isEmpty() ) mrl += advMRL;
1139 emit mrlUpdated( fileList, mrl );
1143 * Update the Buttons (show/hide) for the GUI as all device type don't
1144 * use the same ui. elements.
1146 void CaptureOpenPanel::updateButtons()
1148 /* Be sure to display the ui Elements in case they were hidden by
1149 * some Device Type (like Screen://) */
1150 ui.optionsBox->show();
1151 ui.advancedButton->show();
1152 /* Get the current Device Number */
1153 int i_devicetype = ui.deviceCombo->itemData(
1154 ui.deviceCombo->currentIndex() ).toInt();
1155 switch( i_devicetype )
1159 if( bdas->isChecked() || bdac->isChecked() )
1162 bdaSrateLabel->show();
1164 bdaBandLabel->hide();
1166 else if( bdat->isChecked() )
1169 bdaSrateLabel->hide();
1171 bdaBandLabel->show();
1176 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1177 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1181 //ui.optionsBox->hide();
1182 ui.advancedButton->hide();
1189 void CaptureOpenPanel::advancedDialog()
1191 /* Get selected device type */
1192 int i_devicetype = ui.deviceCombo->itemData(
1193 ui.deviceCombo->currentIndex() ).toInt();
1195 /* Get the corresponding module */
1196 module_t *p_module =
1197 module_find( psz_devModule[i_devicetype] );
1198 if( NULL == p_module ) return;
1201 QList<ConfigControl *> controls;
1203 /* Get the confsize */
1204 unsigned int i_confsize;
1205 module_config_t *p_config;
1206 p_config = module_config_get( p_module, &i_confsize );
1208 /* New Adv Prop dialog */
1209 adv = new QDialog( this );
1210 adv->setWindowTitle( qtr( "Advanced Options" ) );
1212 /* A main Layout with a Frame */
1213 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1214 QScrollArea *scroll = new QScrollArea;
1215 mainLayout->addWidget( scroll );
1217 QFrame *advFrame = new QFrame;
1218 /* GridLayout inside the Frame */
1219 QGridLayout *gLayout = new QGridLayout( advFrame );
1221 scroll->setWidgetResizable( true );
1222 scroll->setWidget( advFrame );
1224 /* Create the options inside the FrameLayout */
1225 for( int n = 0; n < (int)i_confsize; n++ )
1227 module_config_t *p_item = p_config + n;
1228 ConfigControl *config = ConfigControl::createControl(
1229 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1230 controls.append( config );
1234 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1235 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1236 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1238 CONNECT( closeButton, clicked(), adv, accept() );
1239 CONNECT( cancelButton, clicked(), adv, reject() );
1241 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1242 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1244 mainLayout->addWidget( advButtonBox );
1246 /* Creation of the MRL */
1249 QString tempMRL = "";
1250 for( int i = 0; i < controls.size(); i++ )
1252 ConfigControl *control = controls[i];
1255 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1259 tempMRL += (i ? " :" : ":");
1261 if( control->getType() == CONFIG_ITEM_BOOL )
1262 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1265 tempMRL += control->getName();
1267 switch( control->getType() )
1269 case CONFIG_ITEM_STRING:
1270 case CONFIG_ITEM_FILE:
1271 case CONFIG_ITEM_DIRECTORY:
1272 case CONFIG_ITEM_MODULE:
1273 tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1275 case CONFIG_ITEM_INTEGER:
1276 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1278 case CONFIG_ITEM_FLOAT:
1279 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1285 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1288 module_config_free( p_config );
1289 module_release (p_module);