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.subBrowseButton, browseFileSub() );
139 CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
141 CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
142 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
143 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
144 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
147 FileOpenPanel::~FileOpenPanel()
149 // getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
152 void FileOpenPanel::browseFile()
154 QStringList files = QFileDialog::getOpenFileNames( this );
155 foreach( const QString &file, files)
157 QListWidgetItem *item = new QListWidgetItem( file, ui.fileListWidg );
158 item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
159 ui.fileListWidg->addItem( item );
164 /* Show a fileBrowser to select a subtitle */
165 void FileOpenPanel::browseFileSub()
167 // TODO Handle selection of more than one subtitles file
168 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
169 EXT_FILTER_SUBTITLE, p_intf->p_sys->psz_filepath );
171 if( files.isEmpty() ) return;
172 ui.subInput->setText( files.join(" ") );
176 void FileOpenPanel::toggleSubtitleFrame( bool b )
178 ui.subFrame->setEnabled( b );
185 /* Update the current MRL */
186 void FileOpenPanel::updateMRL()
188 QStringList fileList;
191 for( int i = 0; i < ui.fileListWidg->count(); i++ )
192 fileList << ui.fileListWidg->item( i )->text();
194 if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) {
195 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
196 int align = ui.alignSubComboBox->itemData(
197 ui.alignSubComboBox->currentIndex() ).toInt();
198 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
199 int size = ui.sizeSubComboBox->itemData(
200 ui.sizeSubComboBox->currentIndex() ).toInt();
201 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
204 emit mrlUpdated( fileList, mrl );
205 emit methodChanged( "file-caching" );
208 /* Function called by Open Dialog when clicke on Play/Enqueue */
209 void FileOpenPanel::accept()
212 // p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
213 ui.fileListWidg->clear();
216 /* Function called by Open Dialog when clicked on cancel */
217 void FileOpenPanel::clear()
219 ui.fileListWidg->clear();
220 ui.subInput->clear();
223 /**************************************************************************
224 * Open Discs ( DVD, CD, VCD and similar devices ) *
225 **************************************************************************/
226 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
227 OpenPanel( _parent, _p_intf )
231 /* Get the default configuration path for the devices */
232 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
233 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
234 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
236 /* State to avoid overwritting the users changes with the configuration */
241 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
242 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
244 #ifdef WIN32 /* Disc drives probing for Windows */
247 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
249 char *drive = szDrives;
250 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
253 if( GetDriveTypeA(drive) == DRIVE_CDROM )
254 ui.deviceCombo->addItem( drive );
256 /* go to next drive */
259 SetErrorMode(oldMode);
261 #else /* Use a Completer under Linux */
262 QCompleter *discCompleter = new QCompleter( this );
263 discCompleter->setModel( new QDirModel( discCompleter ) );
264 ui.deviceCombo->setCompleter( discCompleter );
268 BUTTONACT( ui.dvdRadioButton, updateButtons() );
269 BUTTONACT( ui.vcdRadioButton, updateButtons() );
270 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
271 BUTTONACT( ui.dvdsimple, updateButtons() );
272 BUTTONACT( ui.browseDiscButton, browseDevice() );
273 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
276 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
277 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
278 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
279 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
280 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
282 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
286 DiscOpenPanel::~DiscOpenPanel()
288 free( psz_dvddiscpath );
289 free( psz_vcddiscpath );
290 free( psz_cddadiscpath );
293 void DiscOpenPanel::clear()
295 ui.titleSpin->setValue( 0 );
296 ui.chapterSpin->setValue( 0 );
297 ui.subtitlesSpin->setValue( -1 );
298 ui.audioSpin->setValue( -1 );
305 #define setDrive( psz_name ) {\
306 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
307 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
309 #define setDrive( psz_name ) {\
310 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
313 /* update the buttons according the type of device */
314 void DiscOpenPanel::updateButtons()
316 if ( ui.dvdRadioButton->isChecked() )
320 setDrive( psz_dvddiscpath );
323 ui.titleLabel->setText( qtr("Title") );
324 ui.chapterLabel->show();
325 ui.chapterSpin->show();
326 ui.diskOptionBox_2->show();
327 ui.dvdsimple->setEnabled( true );
329 else if ( ui.vcdRadioButton->isChecked() )
333 setDrive( psz_vcddiscpath );
336 ui.titleLabel->setText( qtr("Entry") );
337 ui.chapterLabel->hide();
338 ui.chapterSpin->hide();
339 ui.diskOptionBox_2->show();
340 ui.dvdsimple->setEnabled( false );
346 setDrive( psz_cddadiscpath );
349 ui.titleLabel->setText( qtr("Track") );
350 ui.chapterLabel->hide();
351 ui.chapterSpin->hide();
352 ui.diskOptionBox_2->hide();
353 ui.dvdsimple->setEnabled( false );
359 /* Update the current MRL */
360 void DiscOpenPanel::updateMRL()
363 QStringList fileList;
365 /* CDDAX and VCDX not implemented. TODO ? No. */
367 if( ui.dvdRadioButton->isChecked() ) {
368 if( !ui.dvdsimple->isChecked() )
371 mrl = "dvdsimple://";
372 mrl += ui.deviceCombo->currentText();
373 emit methodChanged( "dvdnav-caching" );
375 if ( ui.titleSpin->value() > 0 ) {
376 mrl += QString("@%1").arg( ui.titleSpin->value() );
377 if ( ui.chapterSpin->value() > 0 ) {
378 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
383 } else if ( ui.vcdRadioButton->isChecked() ) {
384 mrl = "vcd://" + ui.deviceCombo->currentText();
385 emit methodChanged( "vcd-caching" );
387 if( ui.titleSpin->value() > 0 ) {
388 mrl += QString("@E%1").arg( ui.titleSpin->value() );
393 mrl = "cdda://" + ui.deviceCombo->currentText();
394 if( ui.titleSpin->value() > 0 ) {
395 mrl += QString("@%1").arg( ui.titleSpin->value() );
399 fileList << mrl; mrl = "";
401 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
403 if ( ui.audioSpin->value() >= 0 ) {
404 mrl += " :audio-track=" +
405 QString("%1").arg( ui.audioSpin->value() );
407 if ( ui.subtitlesSpin->value() >= 0 ) {
408 mrl += " :sub-track=" +
409 QString("%1").arg( ui.subtitlesSpin->value() );
412 emit mrlUpdated( fileList, mrl );
415 void DiscOpenPanel::browseDevice()
417 QString dir = QFileDialog::getExistingDirectory( this,
418 qtr( I_DEVICE_TOOLTIP ) );
420 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
425 void DiscOpenPanel::eject()
427 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
430 void DiscOpenPanel::accept()
433 /**************************************************************************
434 * Open Network streams and URL pages *
435 **************************************************************************/
436 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
437 OpenPanel( _parent, _p_intf )
442 CONNECT( ui.protocolCombo, activated( int ),
443 this, updateProtocol( int ) );
444 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
445 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
447 ui.protocolCombo->addItem( "" );
448 ui.protocolCombo->addItem("HTTP", QVariant("http"));
449 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
450 ui.protocolCombo->addItem("MMS", QVariant("mms"));
451 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
452 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
453 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
454 ui.protocolCombo->addItem("UDP", QVariant("udp"));
455 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
457 updateProtocol( ui.protocolCombo->currentIndex() );
459 if( config_GetInt( p_intf, "qt-recentplay" ) )
461 mrlList = new QStringListModel(
462 getSettings()->value( "Open/netMRL" ).toStringList() );
463 QCompleter *completer = new QCompleter( mrlList, this );
464 ui.addressText->setCompleter( completer );
466 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
472 NetOpenPanel::~NetOpenPanel()
474 if( !mrlList ) return;
476 QStringList tempL = mrlList->stringList();
477 while( tempL.size() > 8 ) tempL.removeFirst();
479 getSettings()->setValue( "Open/netMRL", tempL );
482 void NetOpenPanel::clear()
485 /* update the widgets according the type of protocol */
486 void NetOpenPanel::updateProtocol( int idx_proto ) {
487 QString addr = ui.addressText->text();
488 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
490 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
491 idx_proto == RTP_PROTO );
493 if( idx_proto == NO_PROTO ) return;
495 /* If we already have a protocol in the address, replace it */
496 if( addr.contains( "://"))
498 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
499 addr.replace( QRegExp("^.*://@*"), proto + "://");
500 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
501 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
502 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
503 addr.replace( QRegExp("^.*://"), proto + "://@");
505 addr.replace( QRegExp("^.*://"), proto + "://");
506 addr.replace( QRegExp("@+"), "@");
507 ui.addressText->setText( addr );
512 void NetOpenPanel::updateMRL() {
514 QString addr = ui.addressText->text();
515 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
516 int idx_proto = ui.protocolCombo->currentIndex();
517 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
518 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
519 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
520 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
521 if( addr.contains( "://"))
523 /* Match the correct item in the comboBox */
524 ui.protocolCombo->setCurrentIndex(
525 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
530 switch( idx_proto ) {
532 mrl = "http://" + addr;
533 emit methodChanged("http-caching");
536 mrl = "https://" + addr;
537 emit methodChanged("http-caching");
540 mrl = "mms://" + addr;
541 emit methodChanged("mms-caching");
544 mrl = "ftp://" + addr;
545 emit methodChanged("ftp-caching");
548 mrl = "rtsp://" + addr;
549 emit methodChanged("rtsp-caching");
552 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
557 if ( addr_is_ipv6 && !addr.contains('[') )
559 mrl += "[" + addr + "]";
563 mrl += QString(":%1").arg( ui.portSpin->value() );
564 emit methodChanged("udp-caching");
567 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
571 if ( addr_is_ipv6 && !addr.contains('[') )
572 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
576 mrl += QString(":%1").arg( ui.portSpin->value() );
577 emit methodChanged("rtp-caching");
580 mrl = "rtmp://" + addr;
581 emit methodChanged("rtmp-caching");
586 QStringList qsl; qsl<< mrl;
587 emit mrlUpdated( qsl, "" );
590 void NetOpenPanel::updateCompleter()
593 QStringList tempL = mrlList->stringList();
594 tempL.append( ui.addressText->text() );
595 mrlList->setStringList( tempL );
598 /**************************************************************************
599 * Open Capture device ( DVB, PVR, V4L, and similar ) *
600 **************************************************************************/
601 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
602 OpenPanel( _parent, _p_intf )
604 isInitialized = false;
607 void CaptureOpenPanel::initialize()
609 if( isInitialized ) return;
611 msg_Dbg( p_intf, "Initialization of Capture device panel" );
612 isInitialized = true;
616 BUTTONACT( ui.advancedButton, advancedDialog() );
618 /* Create two stacked layouts in the main comboBoxes */
619 QStackedLayout *stackedDevLayout = new QStackedLayout;
620 ui.cardBox->setLayout( stackedDevLayout );
622 QStackedLayout *stackedPropLayout = new QStackedLayout;
623 ui.optionsBox->setLayout( stackedPropLayout );
625 /* Creation and connections of the WIdgets in the stacked layout */
626 #define addModuleAndLayouts( number, name, label ) \
627 QWidget * name ## DevPage = new QWidget( this ); \
628 QWidget * name ## PropPage = new QWidget( this ); \
629 stackedDevLayout->addWidget( name ## DevPage ); \
630 stackedPropLayout->addWidget( name ## PropPage ); \
631 QGridLayout * name ## DevLayout = new QGridLayout; \
632 QGridLayout * name ## PropLayout = new QGridLayout; \
633 name ## DevPage->setLayout( name ## DevLayout ); \
634 name ## PropPage->setLayout( name ## PropLayout ); \
635 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
637 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
640 /*********************
641 * DirectShow Stuffs *
642 *********************/
643 if( module_exists( "dshow" ) ){
644 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
648 module_config_t *p_config =
649 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
650 vdevDshowW = new StringListConfigControl(
651 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
654 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
655 adevDshowW = new StringListConfigControl(
656 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
659 /* dshow Properties */
660 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
661 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
663 dshowVSizeLine = new QLineEdit;
664 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
665 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
669 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
670 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
671 CuMRL( dshowVSizeLine, textChanged( QString ) );
677 if( module_exists( "bda" ) ){
678 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
681 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
683 bdas = new QRadioButton( "DVB-S" );
684 bdas->setChecked( true );
685 bdac = new QRadioButton( "DVB-C" );
686 bdat = new QRadioButton( "DVB-T" );
687 bdaa = new QRadioButton( "ATSC" );
689 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
690 bdaDevLayout->addWidget( bdas, 0, 1 );
691 bdaDevLayout->addWidget( bdac, 0, 2 );
692 bdaDevLayout->addWidget( bdat, 0, 3 );
693 bdaDevLayout->addWidget( bdaa, 0, 4 );
696 QLabel *bdaFreqLabel =
697 new QLabel( qtr( "Transponder/multiplex frequency" ) );
698 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
700 bdaFreq = new QSpinBox;
701 bdaFreq->setAlignment( Qt::AlignRight );
702 bdaFreq->setSuffix(" kHz");
703 bdaFreq->setSingleStep( 1000 );
704 setSpinBoxFreq( bdaFreq )
705 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
707 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
708 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
710 bdaSrate = new QSpinBox;
711 bdaSrate->setAlignment( Qt::AlignRight );
712 bdaSrate->setSuffix(" kHz");
713 setSpinBoxFreq( bdaSrate );
714 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
716 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
717 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
719 bdaBandBox = new QComboBox;
720 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
721 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
723 bdaBandLabel->hide();
725 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
729 CuMRL( bdaFreq, valueChanged ( int ) );
730 CuMRL( bdaSrate, valueChanged ( int ) );
731 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
732 BUTTONACT( bdas, updateButtons() );
733 BUTTONACT( bdat, updateButtons() );
734 BUTTONACT( bdac, updateButtons() );
735 BUTTONACT( bdaa, updateButtons() );
736 BUTTONACT( bdas, updateMRL() );
737 BUTTONACT( bdat, updateMRL() );
738 BUTTONACT( bdac, updateMRL() );
739 BUTTONACT( bdaa, updateMRL() );
746 if( module_exists( "v4l2" ) ){
747 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
750 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
751 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
753 v4l2VideoDevice = new QLineEdit;
754 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
756 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
757 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
759 v4l2AudioDevice = new QLineEdit;
760 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
762 /* v4l2 Props panel */
763 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
764 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
766 v4l2StdBox = new QComboBox;
767 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
768 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
769 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
773 CuMRL( v4l2VideoDevice, textChanged( QString ) );
774 CuMRL( v4l2AudioDevice, textChanged( QString ) );
775 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
781 if( module_exists( "v4l" ) ){
782 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
785 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
786 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
788 v4lVideoDevice = new QLineEdit;
789 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
791 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
792 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
794 v4lAudioDevice = new QLineEdit;
795 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
797 /* V4l Props panel */
798 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
799 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
801 v4lNormBox = new QComboBox;
802 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
803 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
805 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
806 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
808 v4lFreq = new QSpinBox;
809 v4lFreq->setAlignment( Qt::AlignRight );
810 v4lFreq->setSuffix(" kHz");
811 setSpinBoxFreq( v4lFreq );
812 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
813 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
817 CuMRL( v4lVideoDevice, textChanged( QString ) );
818 CuMRL( v4lAudioDevice, textChanged( QString ) );
819 CuMRL( v4lFreq, valueChanged ( int ) );
820 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
826 if( module_exists( "jack" ) ){
827 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
829 /* Jack Main panel */
831 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
832 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
834 jackChannels = new QSpinBox;
835 setSpinBoxFreq( jackChannels );
836 jackChannels->setMaximum(255);
837 jackChannels->setValue(2);
838 jackChannels->setAlignment( Qt::AlignRight );
839 jackDevLayout->addWidget( jackChannels, 1, 1 );
842 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
843 jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
845 jackPortsSelected = new QLineEdit( qtr( ".*") );
846 jackPortsSelected->setAlignment( Qt::AlignRight );
847 jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
849 /* Jack Props panel */
852 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
853 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
854 jackCaching = new QSpinBox;
855 setSpinBoxFreq( jackCaching );
856 jackCaching->setSuffix( " ms" );
857 jackCaching->setValue(1000);
858 jackCaching->setAlignment( Qt::AlignRight );
859 jackPropLayout->addWidget( jackCaching, 1 , 2 );
862 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
863 jackPropLayout->addWidget( jackPace, 2, 1 );
866 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
867 jackPropLayout->addWidget( jackConnect, 2, 2 );
870 CuMRL( jackChannels, valueChanged( int ) );
871 CuMRL( jackCaching, valueChanged( int ) );
872 CuMRL( jackPace, stateChanged( int ) );
873 CuMRL( jackConnect, stateChanged( int ) );
874 CuMRL( jackPortsSelected, textChanged( QString ) );
880 if( module_exists( "pvr" ) ){
881 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
884 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
885 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
887 pvrDevice = new QLineEdit;
888 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
890 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
891 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
893 pvrRadioDevice = new QLineEdit;
894 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
896 /* PVR props panel */
897 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
898 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
900 pvrNormBox = new QComboBox;
901 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
902 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
904 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
905 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
907 pvrFreq = new QSpinBox;
908 pvrFreq->setAlignment( Qt::AlignRight );
909 pvrFreq->setSuffix(" kHz");
910 setSpinBoxFreq( pvrFreq );
911 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
913 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
914 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
916 pvrBitr = new QSpinBox;
917 pvrBitr->setAlignment( Qt::AlignRight );
918 pvrBitr->setSuffix(" kHz");
919 setSpinBoxFreq( pvrBitr );
920 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
921 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
925 CuMRL( pvrDevice, textChanged( QString ) );
926 CuMRL( pvrRadioDevice, textChanged( QString ) );
928 CuMRL( pvrFreq, valueChanged ( int ) );
929 CuMRL( pvrBitr, valueChanged ( int ) );
930 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
936 if( module_exists( "dvb" ) ){
937 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
940 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
941 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
943 dvbCard = new QSpinBox;
944 dvbCard->setAlignment( Qt::AlignRight );
945 dvbCard->setPrefix( "/dev/dvb/adapter" );
947 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
948 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
950 dvbs = new QRadioButton( "DVB-S" );
951 dvbs->setChecked( true );
952 dvbc = new QRadioButton( "DVB-C" );
953 dvbt = new QRadioButton( "DVB-T" );
955 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
956 dvbDevLayout->addWidget( dvbs, 1, 1 );
957 dvbDevLayout->addWidget( dvbc, 1, 2 );
958 dvbDevLayout->addWidget( dvbt, 1, 3 );
960 /* DVB Props panel */
961 QLabel *dvbFreqLabel =
962 new QLabel( qtr( "Transponder/multiplex frequency" ) );
963 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
965 dvbFreq = new QSpinBox;
966 dvbFreq->setAlignment( Qt::AlignRight );
967 dvbFreq->setSuffix(" kHz");
968 setSpinBoxFreq( dvbFreq );
969 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
971 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
972 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
974 dvbSrate = new QSpinBox;
975 dvbSrate->setAlignment( Qt::AlignRight );
976 dvbSrate->setSuffix(" kHz");
977 setSpinBoxFreq( dvbSrate );
978 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
979 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
983 CuMRL( dvbCard, valueChanged ( int ) );
984 CuMRL( dvbFreq, valueChanged ( int ) );
985 CuMRL( dvbSrate, valueChanged ( int ) );
987 BUTTONACT( dvbs, updateButtons() );
988 BUTTONACT( dvbt, updateButtons() );
989 BUTTONACT( dvbc, updateButtons() );
998 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
999 QLabel *screenLabel = new QLabel( "This option will open your own "
1000 "desktop in order to save or stream it.");
1001 screenLabel->setWordWrap( true );
1002 screenDevLayout->addWidget( screenLabel, 0, 0 );
1004 QLabel *screenFPSLabel = new QLabel(
1005 qtr( "Desired frame rate for the capture." ) );
1006 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1008 screenFPS = new QSpinBox;
1009 screenFPS->setValue( 1 );
1010 screenFPS->setAlignment( Qt::AlignRight );
1011 screenPropLayout->addWidget( screenFPS, 0, 1 );
1013 /* General connects */
1014 CONNECT( ui.deviceCombo, activated( int ) ,
1015 stackedDevLayout, setCurrentIndex( int ) );
1016 CONNECT( ui.deviceCombo, activated( int ),
1017 stackedPropLayout, setCurrentIndex( int ) );
1018 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1019 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1024 CaptureOpenPanel::~CaptureOpenPanel()
1028 void CaptureOpenPanel::clear()
1033 void CaptureOpenPanel::updateMRL()
1036 QStringList fileList;
1037 int i_devicetype = ui.deviceCombo->itemData(
1038 ui.deviceCombo->currentIndex() ).toInt();
1039 switch( i_devicetype )
1043 if( bdas->isChecked() ) mrl = "dvb-s://";
1044 else if( bdat->isChecked() ) mrl = "dvb-t://";
1045 else if( bdac->isChecked() ) mrl = "dvb-c://";
1046 else if( bdaa->isChecked() ) mrl = "atsc://";
1048 fileList << mrl; mrl = "";
1050 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1051 if( bdas->isChecked() || bdac->isChecked() )
1052 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1053 else if( bdat->isChecked() )
1054 mrl += " :dvb-bandwidth=" +
1055 QString("%1").arg( bdaBandBox->itemData(
1056 bdaBandBox->currentIndex() ).toInt() );
1059 fileList << "dshow://";
1060 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1061 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1062 if( dshowVSizeLine->isModified() )
1063 mrl += " :dshow-size=" + dshowVSizeLine->text();
1067 fileList << "v4l://";
1068 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1069 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1070 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1071 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1074 fileList << "v4l2://";
1075 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1076 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1077 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1081 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1082 mrl += ":ports=" + jackPortsSelected->text();
1083 fileList << mrl; mrl = "";
1085 mrl += " :jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1086 if ( jackPace->isChecked() )
1088 mrl += " :jack-input-use-vlc-pace";
1090 if ( jackConnect->isChecked() )
1092 mrl += " :jack-input-auto-connect";
1096 fileList << "pvr://";
1097 mrl += " :pvr-device=" + pvrDevice->text();
1098 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1099 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1100 if( pvrFreq->value() )
1101 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1102 if( pvrBitr->value() )
1103 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1106 fileList << "dvb://";
1107 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1108 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1109 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1113 fileList << "screen://";
1114 mrl = " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1119 if( !advMRL.isEmpty() ) mrl += advMRL;
1121 emit mrlUpdated( fileList, mrl );
1125 * Update the Buttons (show/hide) for the GUI as all device type don't
1126 * use the same ui. elements.
1128 void CaptureOpenPanel::updateButtons()
1130 /* Be sure to display the ui Elements in case they were hidden by
1131 * some Device Type (like Screen://) */
1132 ui.optionsBox->show();
1133 ui.advancedButton->show();
1134 /* Get the current Device Number */
1135 int i_devicetype = ui.deviceCombo->itemData(
1136 ui.deviceCombo->currentIndex() ).toInt();
1137 switch( i_devicetype )
1141 if( bdas->isChecked() || bdac->isChecked() )
1144 bdaSrateLabel->show();
1146 bdaBandLabel->hide();
1148 else if( bdat->isChecked() )
1151 bdaSrateLabel->hide();
1153 bdaBandLabel->show();
1158 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1159 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1163 //ui.optionsBox->hide();
1164 ui.advancedButton->hide();
1171 void CaptureOpenPanel::advancedDialog()
1173 /* Get selected device type */
1174 int i_devicetype = ui.deviceCombo->itemData(
1175 ui.deviceCombo->currentIndex() ).toInt();
1177 /* Get the corresponding module */
1178 module_t *p_module =
1179 module_find( psz_devModule[i_devicetype] );
1180 if( NULL == p_module ) return;
1183 QList<ConfigControl *> controls;
1185 /* Get the confsize */
1186 unsigned int i_confsize;
1187 module_config_t *p_config;
1188 p_config = module_config_get( p_module, &i_confsize );
1190 /* New Adv Prop dialog */
1191 adv = new QDialog( this );
1192 adv->setWindowTitle( qtr( "Advanced Options" ) );
1194 /* A main Layout with a Frame */
1195 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1196 QScrollArea *scroll = new QScrollArea;
1197 mainLayout->addWidget( scroll );
1199 QFrame *advFrame = new QFrame;
1200 /* GridLayout inside the Frame */
1201 QGridLayout *gLayout = new QGridLayout( advFrame );
1203 scroll->setWidgetResizable( true );
1204 scroll->setWidget( advFrame );
1206 /* Create the options inside the FrameLayout */
1207 for( int n = 0; n < (int)i_confsize; n++ )
1209 module_config_t *p_item = p_config + n;
1210 ConfigControl *config = ConfigControl::createControl(
1211 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1212 controls.append( config );
1216 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1217 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1218 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1220 CONNECT( closeButton, clicked(), adv, accept() );
1221 CONNECT( cancelButton, clicked(), adv, reject() );
1223 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1224 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1226 mainLayout->addWidget( advButtonBox );
1228 /* Creation of the MRL */
1231 QString tempMRL = "";
1232 for( int i = 0; i < controls.size(); i++ )
1234 ConfigControl *control = controls[i];
1237 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1241 tempMRL += (i ? " :" : ":");
1243 if( control->getType() == CONFIG_ITEM_BOOL )
1244 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1247 tempMRL += control->getName();
1249 switch( control->getType() )
1251 case CONFIG_ITEM_STRING:
1252 case CONFIG_ITEM_FILE:
1253 case CONFIG_ITEM_DIRECTORY:
1254 case CONFIG_ITEM_MODULE:
1255 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1257 case CONFIG_ITEM_INTEGER:
1258 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1260 case CONFIG_ITEM_FLOAT:
1261 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1267 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1270 module_config_free( p_config );
1271 module_release (p_module);