1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
5 * Copyright (C) 2007 Société des arts technologiques
6 * Copyright (C) 2007 Savoir-faire Linux
10 * Authors: Clément Stenac <zorglub@videolan.org>
11 * Jean-Baptiste Kempf <jb@videolan.org>
12 * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 *****************************************************************************/
34 #include "components/open_panels.hpp"
35 #include "dialogs/open.hpp"
36 #include "dialogs_provider.hpp" /* Open Subtitle file */
37 #include "util/qt_dirs.hpp"
39 #include <QFileDialog>
40 #include <QDialogButtonBox>
42 #include <QStackedLayout>
46 #include <QScrollArea>
48 #include <QStringListModel>
50 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
52 /**************************************************************************
53 * Open Files and subtitles *
54 **************************************************************************/
55 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
56 OpenPanel( _parent, _p_intf )
58 /* Classic UI Setup */
61 /** BEGIN QFileDialog tweaking **/
62 /* Use a QFileDialog and customize it because we don't want to
63 rewrite it all. Be careful to your eyes cause there are a few hacks.
64 Be very careful and test correctly when you modify this. */
66 /* Set Filters for file selection */
67 QString fileTypes = "";
68 ADD_FILTER_MEDIA( fileTypes );
69 ADD_FILTER_VIDEO( fileTypes );
70 ADD_FILTER_AUDIO( fileTypes );
71 ADD_FILTER_PLAYLIST( fileTypes );
72 ADD_FILTER_ALL( fileTypes );
73 fileTypes.replace( QString(";*"), QString(" *"));
75 // Make this QFileDialog a child of tempWidget from the ui.
76 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
77 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
79 dialogBox->setFileMode( QFileDialog::ExistingFiles );
80 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
81 dialogBox->restoreState(
82 getSettings()->value( "file-dialog-state" ).toByteArray() );
84 /* We don't want to see a grip in the middle of the window, do we? */
85 dialogBox->setSizeGripEnabled( false );
88 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
89 dialogBox->setMinimumHeight( 250 );
91 // But hide the two OK/Cancel buttons. Enable them for debug.
92 QDialogButtonBox *fileDialogAcceptBox =
93 dialogBox->findChildren<QDialogButtonBox*>()[0];
94 fileDialogAcceptBox->hide();
96 /* Ugly hacks to get the good Widget */
97 //This lineEdit is the normal line in the fileDialog.
98 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
99 /* Make a list of QLabel inside the QFileDialog to access the good ones */
100 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
102 /* Hide the FileNames one. Enable it for debug */
103 listLabel[1]->setText( qtr( "File names:" ) );
104 /* Change the text that was uncool in the usual box */
105 listLabel[2]->setText( qtr( "Filter:" ) );
107 dialogBox->layout()->setMargin( 0 );
108 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
110 /** END of QFileDialog tweaking **/
112 // Add the DialogBox to the layout
113 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
115 //TODO later: fill the fileCompleteList with previous items played.
116 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
117 fileCompleter->setModel( new QDirModel( fileCompleter ) );
118 lineFileEdit->setCompleter( fileCompleter );
120 // Hide the subtitles control by default.
123 /* Build the subs size combo box */
124 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
125 ui.sizeSubComboBox );
127 /* Build the subs align combo box */
128 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
131 BUTTONACT( ui.subBrowseButton, browseFileSub() );
132 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
134 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
135 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
136 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
137 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
140 FileOpenPanel::~FileOpenPanel()
142 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
145 /* Show a fileBrowser to select a subtitle */
146 void FileOpenPanel::browseFileSub()
148 // TODO Handle selection of more than one subtitles file
149 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
151 dialogBox->directory().absolutePath() );
152 if( files.isEmpty() ) return;
153 ui.subInput->setText( files.join(" ") );
157 /* Update the current MRL */
158 void FileOpenPanel::updateMRL()
161 foreach( QString file, dialogBox->selectedFiles() ) {
162 mrl += "\"" + file + "\" ";
165 if( ui.subCheckBox->isChecked() ) {
166 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
167 int align = ui.alignSubComboBox->itemData(
168 ui.alignSubComboBox->currentIndex() ).toInt();
169 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
170 int size = ui.sizeSubComboBox->itemData(
171 ui.sizeSubComboBox->currentIndex() ).toInt();
172 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
175 emit mrlUpdated( mrl );
176 emit methodChanged( "file-caching" );
179 /* Function called by Open Dialog when clicke on Play/Enqueue */
180 void FileOpenPanel::accept()
182 //TODO set the completer
183 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
186 void FileOpenBox::accept()
188 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
191 void FileOpenBox::reject()
193 OpenDialog::getInstance( NULL, NULL, true )->cancel();
196 /* Function called by Open Dialog when clicked on cancel */
197 void FileOpenPanel::clear()
199 lineFileEdit->clear();
200 ui.subInput->clear();
203 void FileOpenPanel::toggleSubtitleFrame()
205 TOGGLEV( ui.subFrame );
211 /**************************************************************************
212 * Open Discs ( DVD, CD, VCD and similar devices ) *
213 **************************************************************************/
214 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
215 OpenPanel( _parent, _p_intf )
219 /* Get the default configuration path for the devices */
220 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
221 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
222 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
224 /* State to avoid overwritting the users changes with the configuration */
229 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
230 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
232 #ifdef WIN32 /* Disc drives probing for Windows */
235 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
237 char *drive = szDrives;
238 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
241 if( GetDriveTypeA(drive) == DRIVE_CDROM )
242 ui.deviceCombo->addItem( drive );
244 /* go to next drive */
247 SetErrorMode(oldMode);
249 #else /* Use a Completer under Linux */
250 QCompleter *discCompleter = new QCompleter( this );
251 discCompleter->setModel( new QDirModel( discCompleter ) );
252 ui.deviceCombo->setCompleter( discCompleter );
256 BUTTONACT( ui.dvdRadioButton, updateButtons() );
257 BUTTONACT( ui.vcdRadioButton, updateButtons() );
258 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
259 BUTTONACT( ui.dvdsimple, updateButtons() );
260 BUTTONACT( ui.browseDiscButton, browseDevice() );
261 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
264 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
265 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
266 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
267 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
268 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
270 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
274 DiscOpenPanel::~DiscOpenPanel()
276 free( psz_dvddiscpath );
277 free( psz_vcddiscpath );
278 free( psz_cddadiscpath );
281 void DiscOpenPanel::clear()
283 ui.titleSpin->setValue( 0 );
284 ui.chapterSpin->setValue( 0 );
291 #define setDrive( psz_name ) {\
292 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
293 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
295 #define setDrive( psz_name ) {\
296 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
299 /* update the buttons according the type of device */
300 void DiscOpenPanel::updateButtons()
302 if ( ui.dvdRadioButton->isChecked() )
306 setDrive( psz_dvddiscpath );
309 ui.titleLabel->setText( qtr("Title") );
310 ui.chapterLabel->show();
311 ui.chapterSpin->show();
312 ui.diskOptionBox_2->show();
313 ui.dvdsimple->setEnabled( true );
315 else if ( ui.vcdRadioButton->isChecked() )
319 setDrive( psz_vcddiscpath );
322 ui.titleLabel->setText( qtr("Entry") );
323 ui.chapterLabel->hide();
324 ui.chapterSpin->hide();
325 ui.diskOptionBox_2->show();
326 ui.dvdsimple->setEnabled( false );
332 setDrive( psz_cddadiscpath );
335 ui.titleLabel->setText( qtr("Track") );
336 ui.chapterLabel->hide();
337 ui.chapterSpin->hide();
338 ui.diskOptionBox_2->hide();
339 ui.dvdsimple->setEnabled( false );
345 /* Update the current MRL */
346 void DiscOpenPanel::updateMRL()
350 /* CDDAX and VCDX not implemented. TODO ? */
352 if( ui.dvdRadioButton->isChecked() ) {
353 if( !ui.dvdsimple->isChecked() )
356 mrl = "\"dvdsimple://";
357 mrl += ui.deviceCombo->currentText();
358 emit methodChanged( "dvdnav-caching" );
360 if ( ui.titleSpin->value() > 0 ) {
361 mrl += QString("@%1").arg( ui.titleSpin->value() );
362 if ( ui.chapterSpin->value() > 0 ) {
363 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
368 } else if ( ui.vcdRadioButton->isChecked() ) {
369 mrl = "\"vcd://" + ui.deviceCombo->currentText();
370 emit methodChanged( "vcd-caching" );
372 if( ui.titleSpin->value() > 0 ) {
373 mrl += QString("@E%1").arg( ui.titleSpin->value() );
378 mrl = "\"cdda://" + ui.deviceCombo->currentText();
379 if( ui.titleSpin->value() > 0 ) {
380 QString("@%1").arg( ui.titleSpin->value() );
386 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
388 if ( ui.audioSpin->value() >= 0 ) {
389 mrl += " :audio-track=" +
390 QString("%1").arg( ui.audioSpin->value() );
392 if ( ui.subtitlesSpin->value() >= 0 ) {
393 mrl += " :sub-track=" +
394 QString("%1").arg( ui.subtitlesSpin->value() );
397 emit mrlUpdated( mrl );
400 void DiscOpenPanel::browseDevice()
402 QString dir = QFileDialog::getExistingDirectory( this,
403 qtr( I_DEVICE_TOOLTIP ) );
405 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
410 void DiscOpenPanel::eject()
412 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
415 void DiscOpenPanel::accept()
418 /**************************************************************************
419 * Open Network streams and URL pages *
420 **************************************************************************/
421 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
422 OpenPanel( _parent, _p_intf )
427 CONNECT( ui.protocolCombo, activated( int ),
428 this, updateProtocol( int ) );
429 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
430 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
431 CONNECT( ui.timeShift, clicked(), this, updateMRL());
433 ui.protocolCombo->addItem( "" );
434 ui.protocolCombo->addItem("HTTP", QVariant("http"));
435 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
436 ui.protocolCombo->addItem("MMS", QVariant("mms"));
437 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
438 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
439 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
440 ui.protocolCombo->addItem("UDP", QVariant("udp"));
441 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
443 updateProtocol( ui.protocolCombo->currentIndex() );
445 if( config_GetInt( p_intf, "qt-recentplay" ) )
447 mrlList = new QStringListModel(
448 getSettings()->value( "Open/netMRL" ).toStringList() );
449 QCompleter *completer = new QCompleter( mrlList, this );
450 ui.addressText->setCompleter( completer );
452 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
458 NetOpenPanel::~NetOpenPanel()
460 if( !mrlList ) return;
462 QStringList tempL = mrlList->stringList();
463 while( tempL.size() > 8 ) tempL.removeFirst();
465 getSettings()->setValue( "Open/netMRL", tempL );
468 void NetOpenPanel::clear()
471 /* update the widgets according the type of protocol */
472 void NetOpenPanel::updateProtocol( int idx_proto ) {
473 QString addr = ui.addressText->text();
474 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
476 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
477 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
478 idx_proto == RTP_PROTO );
480 if( idx_proto == NO_PROTO ) return;
482 /* If we already have a protocol in the address, replace it */
483 if( addr.contains( "://"))
485 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
486 addr.replace( QRegExp("^.*://@*"), proto + "://");
487 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
488 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
489 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
490 addr.replace( QRegExp("^.*://"), proto + "://@");
492 addr.replace( QRegExp("^.*://"), proto + "://");
493 addr.replace( QRegExp("@+"), "@");
494 ui.addressText->setText( addr );
499 void NetOpenPanel::updateMRL() {
501 QString addr = ui.addressText->text();
502 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
503 int idx_proto = ui.protocolCombo->currentIndex();
504 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
505 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
506 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
507 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
508 if( addr.contains( "://"))
510 /* Match the correct item in the comboBox */
511 ui.protocolCombo->setCurrentIndex(
512 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
517 switch( idx_proto ) {
519 mrl = "http://" + addr;
520 emit methodChanged("http-caching");
523 mrl = "https://" + addr;
524 emit methodChanged("http-caching");
527 mrl = "mms://" + addr;
528 emit methodChanged("mms-caching");
531 mrl = "ftp://" + addr;
532 emit methodChanged("ftp-caching");
535 mrl = "rtsp://" + addr;
536 emit methodChanged("rtsp-caching");
539 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
544 if ( addr_is_ipv6 && !addr.contains('[') )
546 mrl += "[" + addr + "]";
550 mrl += QString(":%1").arg( ui.portSpin->value() );
551 emit methodChanged("udp-caching");
554 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
558 if ( addr_is_ipv6 && !addr.contains('[') )
559 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
563 mrl += QString(":%1").arg( ui.portSpin->value() );
564 emit methodChanged("rtp-caching");
567 mrl = "rtmp://" + addr;
568 emit methodChanged("rtmp-caching");
573 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
574 mrl += " :access-filter=timeshift";
576 emit mrlUpdated( mrl );
579 void NetOpenPanel::updateCompleter()
582 QStringList tempL = mrlList->stringList();
583 tempL.append( ui.addressText->text() );
584 mrlList->setStringList( tempL );
587 /**************************************************************************
588 * Open Capture device ( DVB, PVR, V4L, and similar ) *
589 **************************************************************************/
590 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
591 OpenPanel( _parent, _p_intf )
593 isInitialized = false;
596 void CaptureOpenPanel::initialize()
598 if( isInitialized ) return;
600 msg_Dbg( p_intf, "Initialization of Capture device panel" );
601 isInitialized = true;
605 BUTTONACT( ui.advancedButton, advancedDialog() );
607 /* Create two stacked layouts in the main comboBoxes */
608 QStackedLayout *stackedDevLayout = new QStackedLayout;
609 ui.cardBox->setLayout( stackedDevLayout );
611 QStackedLayout *stackedPropLayout = new QStackedLayout;
612 ui.optionsBox->setLayout( stackedPropLayout );
614 /* Creation and connections of the WIdgets in the stacked layout */
615 #define addModuleAndLayouts( number, name, label ) \
616 QWidget * name ## DevPage = new QWidget( this ); \
617 QWidget * name ## PropPage = new QWidget( this ); \
618 stackedDevLayout->addWidget( name ## DevPage ); \
619 stackedPropLayout->addWidget( name ## PropPage ); \
620 QGridLayout * name ## DevLayout = new QGridLayout; \
621 QGridLayout * name ## PropLayout = new QGridLayout; \
622 name ## DevPage->setLayout( name ## DevLayout ); \
623 name ## PropPage->setLayout( name ## PropLayout ); \
624 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
626 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
629 /*********************
630 * DirectShow Stuffs *
631 *********************/
632 if( module_exists( "dshow" ) ){
633 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
637 module_config_t *p_config =
638 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
639 vdevDshowW = new StringListConfigControl(
640 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
643 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
644 adevDshowW = new StringListConfigControl(
645 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
648 /* dshow Properties */
649 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
650 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
652 dshowVSizeLine = new QLineEdit;
653 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
654 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
658 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
659 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
660 CuMRL( dshowVSizeLine, textChanged( QString ) );
666 if( module_exists( "bda" ) ){
667 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
670 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
672 bdas = new QRadioButton( "DVB-S" );
673 bdas->setChecked( true );
674 bdac = new QRadioButton( "DVB-C" );
675 bdat = new QRadioButton( "DVB-T" );
676 bdaa = new QRadioButton( "ATSC" );
678 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
679 bdaDevLayout->addWidget( bdas, 0, 1 );
680 bdaDevLayout->addWidget( bdac, 0, 2 );
681 bdaDevLayout->addWidget( bdat, 0, 3 );
682 bdaDevLayout->addWidget( bdaa, 0, 4 );
685 QLabel *bdaFreqLabel =
686 new QLabel( qtr( "Transponder/multiplex frequency" ) );
687 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
689 bdaFreq = new QSpinBox;
690 bdaFreq->setAlignment( Qt::AlignRight );
691 bdaFreq->setSuffix(" kHz");
692 bdaFreq->setSingleStep( 1000 );
693 setSpinBoxFreq( bdaFreq )
694 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
696 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
697 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
699 bdaSrate = new QSpinBox;
700 bdaSrate->setAlignment( Qt::AlignRight );
701 bdaSrate->setSuffix(" kHz");
702 setSpinBoxFreq( bdaSrate );
703 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
705 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
706 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
708 bdaBandBox = new QComboBox;
709 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
710 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
712 bdaBandLabel->hide();
714 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
718 CuMRL( bdaFreq, valueChanged ( int ) );
719 CuMRL( bdaSrate, valueChanged ( int ) );
720 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
721 BUTTONACT( bdas, updateButtons() );
722 BUTTONACT( bdat, updateButtons() );
723 BUTTONACT( bdac, updateButtons() );
724 BUTTONACT( bdaa, updateButtons() );
725 BUTTONACT( bdas, updateMRL() );
726 BUTTONACT( bdat, updateMRL() );
727 BUTTONACT( bdac, updateMRL() );
728 BUTTONACT( bdaa, updateMRL() );
735 if( module_exists( "v4l2" ) ){
736 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
739 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
740 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
742 v4l2VideoDevice = new QLineEdit;
743 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
745 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
746 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
748 v4l2AudioDevice = new QLineEdit;
749 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
751 /* v4l2 Props panel */
752 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
753 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
755 v4l2StdBox = new QComboBox;
756 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
757 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
758 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
762 CuMRL( v4l2VideoDevice, textChanged( QString ) );
763 CuMRL( v4l2AudioDevice, textChanged( QString ) );
764 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
770 if( module_exists( "v4l" ) ){
771 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
774 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
775 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
777 v4lVideoDevice = new QLineEdit;
778 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
780 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
781 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
783 v4lAudioDevice = new QLineEdit;
784 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
786 /* V4l Props panel */
787 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
788 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
790 v4lNormBox = new QComboBox;
791 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
792 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
794 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
795 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
797 v4lFreq = new QSpinBox;
798 v4lFreq->setAlignment( Qt::AlignRight );
799 v4lFreq->setSuffix(" kHz");
800 setSpinBoxFreq( v4lFreq );
801 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
802 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
806 CuMRL( v4lVideoDevice, textChanged( QString ) );
807 CuMRL( v4lAudioDevice, textChanged( QString ) );
808 CuMRL( v4lFreq, valueChanged ( int ) );
809 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
815 if( module_exists( "jack" ) ){
816 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
818 /* Jack Main panel */
820 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
821 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
823 jackChannels = new QSpinBox;
824 setSpinBoxFreq( jackChannels );
825 jackChannels->setMaximum(255);
826 jackChannels->setValue(2);
827 jackChannels->setAlignment( Qt::AlignRight );
828 jackDevLayout->addWidget( jackChannels, 1, 1 );
830 /* Jack Props panel */
833 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
834 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
836 jackPortsSelected = new QLineEdit( qtr( ".*") );
837 jackPortsSelected->setAlignment( Qt::AlignRight );
838 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
841 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
842 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
843 jackCaching = new QSpinBox;
844 setSpinBoxFreq( jackCaching );
845 jackCaching->setSuffix( " ms" );
846 jackCaching->setValue(1000);
847 jackCaching->setAlignment( Qt::AlignRight );
848 jackPropLayout->addWidget( jackCaching, 1 , 1 );
851 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
852 jackPropLayout->addWidget( jackPace, 2, 1 );
855 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
856 jackPropLayout->addWidget( jackConnect, 3, 1 );
859 CuMRL( jackChannels, valueChanged( int ) );
860 CuMRL( jackCaching, valueChanged( int ) );
861 CuMRL( jackPace, stateChanged( int ) );
862 CuMRL( jackConnect, stateChanged( int ) );
863 CuMRL( jackPortsSelected, textChanged( QString ) );
869 if( module_exists( "pvr" ) ){
870 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
873 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
874 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
876 pvrDevice = new QLineEdit;
877 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
879 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
880 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
882 pvrRadioDevice = new QLineEdit;
883 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
885 /* PVR props panel */
886 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
887 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
889 pvrNormBox = new QComboBox;
890 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
891 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
893 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
894 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
896 pvrFreq = new QSpinBox;
897 pvrFreq->setAlignment( Qt::AlignRight );
898 pvrFreq->setSuffix(" kHz");
899 setSpinBoxFreq( pvrFreq );
900 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
902 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
903 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
905 pvrBitr = new QSpinBox;
906 pvrBitr->setAlignment( Qt::AlignRight );
907 pvrBitr->setSuffix(" kHz");
908 setSpinBoxFreq( pvrBitr );
909 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
910 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
914 CuMRL( pvrDevice, textChanged( QString ) );
915 CuMRL( pvrRadioDevice, textChanged( QString ) );
917 CuMRL( pvrFreq, valueChanged ( int ) );
918 CuMRL( pvrBitr, valueChanged ( int ) );
919 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
925 if( module_exists( "dvb" ) ){
926 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
929 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
930 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
932 dvbCard = new QSpinBox;
933 dvbCard->setAlignment( Qt::AlignRight );
934 dvbCard->setPrefix( "/dev/dvb/adapter" );
936 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
937 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
939 dvbs = new QRadioButton( "DVB-S" );
940 dvbs->setChecked( true );
941 dvbc = new QRadioButton( "DVB-C" );
942 dvbt = new QRadioButton( "DVB-T" );
944 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
945 dvbDevLayout->addWidget( dvbs, 1, 1 );
946 dvbDevLayout->addWidget( dvbc, 1, 2 );
947 dvbDevLayout->addWidget( dvbt, 1, 3 );
949 /* DVB Props panel */
950 QLabel *dvbFreqLabel =
951 new QLabel( qtr( "Transponder/multiplex frequency" ) );
952 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
954 dvbFreq = new QSpinBox;
955 dvbFreq->setAlignment( Qt::AlignRight );
956 dvbFreq->setSuffix(" kHz");
957 setSpinBoxFreq( dvbFreq );
958 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
960 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
961 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
963 dvbSrate = new QSpinBox;
964 dvbSrate->setAlignment( Qt::AlignRight );
965 dvbSrate->setSuffix(" kHz");
966 setSpinBoxFreq( dvbSrate );
967 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
968 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
972 CuMRL( dvbCard, valueChanged ( int ) );
973 CuMRL( dvbFreq, valueChanged ( int ) );
974 CuMRL( dvbSrate, valueChanged ( int ) );
976 BUTTONACT( dvbs, updateButtons() );
977 BUTTONACT( dvbt, updateButtons() );
978 BUTTONACT( dvbc, updateButtons() );
987 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
988 QLabel *screenLabel = new QLabel( "This option will open your own "
989 "desktop in order to save or stream it.");
990 screenLabel->setWordWrap( true );
991 screenDevLayout->addWidget( screenLabel, 0, 0 );
993 QLabel *screenFPSLabel = new QLabel(
994 qtr( "Desired frame rate for the capture." ) );
995 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
997 screenFPS = new QSpinBox;
998 screenFPS->setValue( 1 );
999 screenFPS->setAlignment( Qt::AlignRight );
1000 screenPropLayout->addWidget( screenFPS, 0, 1 );
1002 /* General connects */
1003 CONNECT( ui.deviceCombo, activated( int ) ,
1004 stackedDevLayout, setCurrentIndex( int ) );
1005 CONNECT( ui.deviceCombo, activated( int ),
1006 stackedPropLayout, setCurrentIndex( int ) );
1007 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1008 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1013 CaptureOpenPanel::~CaptureOpenPanel()
1017 void CaptureOpenPanel::clear()
1022 void CaptureOpenPanel::updateMRL()
1025 int i_devicetype = ui.deviceCombo->itemData(
1026 ui.deviceCombo->currentIndex() ).toInt();
1027 switch( i_devicetype )
1031 if( bdas->isChecked() ) mrl = "dvb-s://";
1032 else if( bdat->isChecked() ) mrl = "dvb-t://";
1033 else if( bdac->isChecked() ) mrl = "dvb-c://";
1034 else if( bdaa->isChecked() ) mrl = "atsc://";
1036 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1037 if( bdas->isChecked() || bdac->isChecked() )
1038 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1039 else if( bdat->isChecked() )
1040 mrl += " :dvb-bandwidth=" +
1041 QString("%1").arg( bdaBandBox->itemData(
1042 bdaBandBox->currentIndex() ).toInt() );
1046 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1047 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1048 if( dshowVSizeLine->isModified() )
1049 mrl += " :dshow-size=" + dshowVSizeLine->text();
1054 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1055 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1056 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1057 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1061 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1062 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1063 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1067 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1068 mrl += ":ports=" + jackPortsSelected->text();
1069 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1070 if ( jackPace->isChecked() )
1072 mrl += " --jack-input-use-vlc-pace";
1074 if ( jackConnect->isChecked() )
1076 mrl += " --jack-input-auto-connect";
1081 mrl += " :pvr-device=" + pvrDevice->text();
1082 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1083 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1084 if( pvrFreq->value() )
1085 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1086 if( pvrBitr->value() )
1087 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1091 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1092 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1093 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1098 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1103 if( !advMRL.isEmpty() ) mrl += advMRL;
1105 emit mrlUpdated( mrl );
1109 * Update the Buttons (show/hide) for the GUI as all device type don't
1110 * use the same ui. elements.
1112 void CaptureOpenPanel::updateButtons()
1114 /* Be sure to display the ui Elements in case they were hidden by
1115 * some Device Type (like Screen://) */
1116 ui.optionsBox->show();
1117 ui.advancedButton->show();
1118 /* Get the current Device Number */
1119 int i_devicetype = ui.deviceCombo->itemData(
1120 ui.deviceCombo->currentIndex() ).toInt();
1121 switch( i_devicetype )
1125 if( bdas->isChecked() || bdac->isChecked() )
1128 bdaSrateLabel->show();
1130 bdaBandLabel->hide();
1132 else if( bdat->isChecked() )
1135 bdaSrateLabel->hide();
1137 bdaBandLabel->show();
1142 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1143 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1147 //ui.optionsBox->hide();
1148 ui.advancedButton->hide();
1155 void CaptureOpenPanel::advancedDialog()
1157 /* Get selected device type */
1158 int i_devicetype = ui.deviceCombo->itemData(
1159 ui.deviceCombo->currentIndex() ).toInt();
1161 /* Get the corresponding module */
1162 module_t *p_module =
1163 module_find( psz_devModule[i_devicetype] );
1164 if( NULL == p_module ) return;
1167 QList<ConfigControl *> controls;
1169 /* Get the confsize */
1170 unsigned int i_confsize;
1171 module_config_t *p_config;
1172 p_config = module_config_get( p_module, &i_confsize );
1174 /* New Adv Prop dialog */
1175 adv = new QDialog( this );
1176 adv->setWindowTitle( qtr( "Advanced Options" ) );
1178 /* A main Layout with a Frame */
1179 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1180 QScrollArea *scroll = new QScrollArea;
1181 mainLayout->addWidget( scroll );
1183 QFrame *advFrame = new QFrame;
1184 /* GridLayout inside the Frame */
1185 QGridLayout *gLayout = new QGridLayout( advFrame );
1187 scroll->setWidgetResizable( true );
1188 scroll->setWidget( advFrame );
1190 /* Create the options inside the FrameLayout */
1191 for( int n = 0; n < (int)i_confsize; n++ )
1193 module_config_t *p_item = p_config + n;
1194 ConfigControl *config = ConfigControl::createControl(
1195 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1196 controls.append( config );
1200 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1201 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1202 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1204 CONNECT( closeButton, clicked(), adv, accept() );
1205 CONNECT( cancelButton, clicked(), adv, reject() );
1207 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1208 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1210 mainLayout->addWidget( advButtonBox );
1212 /* Creation of the MRL */
1215 QString tempMRL = "";
1216 for( int i = 0; i < controls.size(); i++ )
1218 ConfigControl *control = controls[i];
1221 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1225 tempMRL += (i ? " :" : ":");
1227 if( control->getType() == CONFIG_ITEM_BOOL )
1228 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1231 tempMRL += control->getName();
1233 switch( control->getType() )
1235 case CONFIG_ITEM_STRING:
1236 case CONFIG_ITEM_FILE:
1237 case CONFIG_ITEM_DIRECTORY:
1238 case CONFIG_ITEM_MODULE:
1239 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1241 case CONFIG_ITEM_INTEGER:
1242 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1244 case CONFIG_ITEM_FLOAT:
1245 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1251 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1254 module_config_free( p_config );
1255 module_release (p_module);