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"
38 #include <QFileDialog>
39 #include <QDialogButtonBox>
41 #include <QStackedLayout>
45 #include <QScrollArea>
47 #include <QStringListModel>
49 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
51 /**************************************************************************
52 * Open Files and subtitles *
53 **************************************************************************/
54 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
55 OpenPanel( _parent, _p_intf )
57 /* Classic UI Setup */
60 /** BEGIN QFileDialog tweaking **/
61 /* Use a QFileDialog and customize it because we don't want to
62 rewrite it all. Be careful to your eyes cause there are a few hacks.
63 Be very careful and test correctly when you modify this. */
65 /* Set Filters for file selection */
66 QString fileTypes = "";
67 ADD_FILTER_MEDIA( fileTypes );
68 ADD_FILTER_VIDEO( fileTypes );
69 ADD_FILTER_AUDIO( fileTypes );
70 ADD_FILTER_PLAYLIST( fileTypes );
71 ADD_FILTER_ALL( fileTypes );
72 fileTypes.replace( QString(";*"), QString(" *"));
74 // Make this QFileDialog a child of tempWidget from the ui.
75 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
76 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
78 dialogBox->setFileMode( QFileDialog::ExistingFiles );
79 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
80 dialogBox->restoreState(
81 getSettings()->value( "file-dialog-state" ).toByteArray() );
83 /* We don't want to see a grip in the middle of the window, do we? */
84 dialogBox->setSizeGripEnabled( false );
87 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
88 dialogBox->setMinimumHeight( 250 );
90 // But hide the two OK/Cancel buttons. Enable them for debug.
91 QDialogButtonBox *fileDialogAcceptBox =
92 dialogBox->findChildren<QDialogButtonBox*>()[0];
93 fileDialogAcceptBox->hide();
95 /* Ugly hacks to get the good Widget */
96 //This lineEdit is the normal line in the fileDialog.
97 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
98 /* Make a list of QLabel inside the QFileDialog to access the good ones */
99 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
101 /* Hide the FileNames one. Enable it for debug */
102 listLabel[1]->setText( qtr( "File names:" ) );
103 /* Change the text that was uncool in the usual box */
104 listLabel[2]->setText( qtr( "Filter:" ) );
106 dialogBox->layout()->setMargin( 0 );
107 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
109 /** END of QFileDialog tweaking **/
111 // Add the DialogBox to the layout
112 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
114 //TODO later: fill the fileCompleteList with previous items played.
115 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
116 fileCompleter->setModel( new QDirModel( fileCompleter ) );
117 lineFileEdit->setCompleter( fileCompleter );
119 // Hide the subtitles control by default.
122 /* Build the subs size combo box */
123 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
124 ui.sizeSubComboBox );
126 /* Build the subs align combo box */
127 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
130 BUTTONACT( ui.subBrowseButton, browseFileSub() );
131 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
133 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
134 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
135 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
136 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
139 FileOpenPanel::~FileOpenPanel()
141 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
144 /* Show a fileBrowser to select a subtitle */
145 void FileOpenPanel::browseFileSub()
147 // TODO Handle selection of more than one subtitles file
148 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
150 dialogBox->directory().absolutePath() );
151 if( files.isEmpty() ) return;
152 ui.subInput->setText( files.join(" ") );
156 /* Update the current MRL */
157 void FileOpenPanel::updateMRL()
160 foreach( QString file, dialogBox->selectedFiles() ) {
161 mrl += "\"" + file + "\" ";
164 if( ui.subCheckBox->isChecked() ) {
165 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
166 int align = ui.alignSubComboBox->itemData(
167 ui.alignSubComboBox->currentIndex() ).toInt();
168 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
169 int size = ui.sizeSubComboBox->itemData(
170 ui.sizeSubComboBox->currentIndex() ).toInt();
171 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
174 emit mrlUpdated( mrl );
175 emit methodChanged( "file-caching" );
178 /* Function called by Open Dialog when clicke on Play/Enqueue */
179 void FileOpenPanel::accept()
181 //TODO set the completer
182 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
185 void FileOpenBox::accept()
187 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
190 void FileOpenBox::reject()
192 OpenDialog::getInstance( NULL, NULL, true )->cancel();
195 /* Function called by Open Dialog when clicked on cancel */
196 void FileOpenPanel::clear()
198 lineFileEdit->clear();
199 ui.subInput->clear();
202 void FileOpenPanel::toggleSubtitleFrame()
204 TOGGLEV( ui.subFrame );
210 /**************************************************************************
211 * Open Discs ( DVD, CD, VCD and similar devices ) *
212 **************************************************************************/
213 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
214 OpenPanel( _parent, _p_intf )
218 /* Get the default configuration path for the devices */
219 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
220 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
221 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
223 /* State to avoid overwritting the users changes with the configuration */
228 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
229 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
231 #ifdef WIN32 /* Disc drives probing for Windows */
234 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
236 char *drive = szDrives;
237 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
240 if( GetDriveTypeA(drive) == DRIVE_CDROM )
241 ui.deviceCombo->addItem( drive );
243 /* go to next drive */
246 SetErrorMode(oldMode);
248 #else /* Use a Completer under Linux */
249 QCompleter *discCompleter = new QCompleter( this );
250 discCompleter->setModel( new QDirModel( discCompleter ) );
251 ui.deviceCombo->setCompleter( discCompleter );
255 BUTTONACT( ui.dvdRadioButton, updateButtons() );
256 BUTTONACT( ui.vcdRadioButton, updateButtons() );
257 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
258 BUTTONACT( ui.dvdsimple, updateButtons() );
259 BUTTONACT( ui.browseDiscButton, browseDevice() );
260 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
263 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
264 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
265 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
266 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
267 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
269 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
273 DiscOpenPanel::~DiscOpenPanel()
275 free( psz_dvddiscpath );
276 free( psz_vcddiscpath );
277 free( psz_cddadiscpath );
280 void DiscOpenPanel::clear()
282 ui.titleSpin->setValue( 0 );
283 ui.chapterSpin->setValue( 0 );
290 #define setDrive( psz_name ) {\
291 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
292 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
294 #define setDrive( psz_name ) {\
295 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
298 /* update the buttons according the type of device */
299 void DiscOpenPanel::updateButtons()
301 if ( ui.dvdRadioButton->isChecked() )
305 setDrive( psz_dvddiscpath );
308 ui.titleLabel->setText( qtr("Title") );
309 ui.chapterLabel->show();
310 ui.chapterSpin->show();
311 ui.diskOptionBox_2->show();
312 ui.dvdsimple->setEnabled( true );
314 else if ( ui.vcdRadioButton->isChecked() )
318 setDrive( psz_vcddiscpath );
321 ui.titleLabel->setText( qtr("Entry") );
322 ui.chapterLabel->hide();
323 ui.chapterSpin->hide();
324 ui.diskOptionBox_2->show();
325 ui.dvdsimple->setEnabled( false );
331 setDrive( psz_cddadiscpath );
334 ui.titleLabel->setText( qtr("Track") );
335 ui.chapterLabel->hide();
336 ui.chapterSpin->hide();
337 ui.diskOptionBox_2->hide();
338 ui.dvdsimple->setEnabled( false );
344 /* Update the current MRL */
345 void DiscOpenPanel::updateMRL()
349 /* CDDAX and VCDX not implemented. TODO ? */
351 if( ui.dvdRadioButton->isChecked() ) {
352 if( !ui.dvdsimple->isChecked() )
355 mrl = "\"dvdsimple://";
356 mrl += ui.deviceCombo->currentText();
357 emit methodChanged( "dvdnav-caching" );
359 if ( ui.titleSpin->value() > 0 ) {
360 mrl += QString("@%1").arg( ui.titleSpin->value() );
361 if ( ui.chapterSpin->value() > 0 ) {
362 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
367 } else if ( ui.vcdRadioButton->isChecked() ) {
368 mrl = "\"vcd://" + ui.deviceCombo->currentText();
369 emit methodChanged( "vcd-caching" );
371 if( ui.titleSpin->value() > 0 ) {
372 mrl += QString("@E%1").arg( ui.titleSpin->value() );
377 mrl = "\"cdda://" + ui.deviceCombo->currentText();
378 if( ui.titleSpin->value() > 0 ) {
379 QString("@%1").arg( ui.titleSpin->value() );
385 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
387 if ( ui.audioSpin->value() >= 0 ) {
388 mrl += " :audio-track=" +
389 QString("%1").arg( ui.audioSpin->value() );
391 if ( ui.subtitlesSpin->value() >= 0 ) {
392 mrl += " :sub-track=" +
393 QString("%1").arg( ui.subtitlesSpin->value() );
396 emit mrlUpdated( mrl );
399 void DiscOpenPanel::browseDevice()
401 QString dir = QFileDialog::getExistingDirectory( this,
402 qtr( I_DEVICE_TOOLTIP ) );
404 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
409 void DiscOpenPanel::eject()
411 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
414 void DiscOpenPanel::accept()
417 /**************************************************************************
418 * Open Network streams and URL pages *
419 **************************************************************************/
420 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
421 OpenPanel( _parent, _p_intf )
426 CONNECT( ui.protocolCombo, activated( int ),
427 this, updateProtocol( int ) );
428 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
429 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
430 CONNECT( ui.timeShift, clicked(), this, updateMRL());
432 ui.protocolCombo->addItem( "" );
433 ui.protocolCombo->addItem("HTTP", QVariant("http"));
434 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
435 ui.protocolCombo->addItem("MMS", QVariant("mms"));
436 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
437 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
438 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
439 ui.protocolCombo->addItem("UDP", QVariant("udp"));
440 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
442 updateProtocol( ui.protocolCombo->currentIndex() );
444 if( config_GetInt( p_intf, "qt-recentplay" ) )
446 mrlList = new QStringListModel(
447 getSettings()->value( "Open/netMRL" ).toStringList() );
448 QCompleter *completer = new QCompleter( mrlList, this );
449 ui.addressText->setCompleter( completer );
451 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
457 NetOpenPanel::~NetOpenPanel()
459 if( !mrlList ) return;
461 QStringList tempL = mrlList->stringList();
462 while( tempL.size() > 8 ) tempL.removeFirst();
464 getSettings()->setValue( "Open/netMRL", tempL );
467 void NetOpenPanel::clear()
470 /* update the widgets according the type of protocol */
471 void NetOpenPanel::updateProtocol( int idx_proto ) {
472 QString addr = ui.addressText->text();
473 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
475 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
476 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
477 idx_proto == RTP_PROTO );
479 if( idx_proto == NO_PROTO ) return;
481 /* If we already have a protocol in the address, replace it */
482 if( addr.contains( "://"))
484 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
485 addr.replace( QRegExp("^.*://@*"), proto + "://");
486 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
487 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
488 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
489 addr.replace( QRegExp("^.*://"), proto + "://@");
491 addr.replace( QRegExp("^.*://"), proto + "://");
492 addr.replace( QRegExp("@+"), "@");
493 ui.addressText->setText( addr );
498 void NetOpenPanel::updateMRL() {
500 QString addr = ui.addressText->text();
501 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
502 int idx_proto = ui.protocolCombo->currentIndex();
503 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
504 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
505 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
506 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
507 if( addr.contains( "://"))
509 /* Match the correct item in the comboBox */
510 ui.protocolCombo->setCurrentIndex(
511 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
516 switch( idx_proto ) {
518 mrl = "http://" + addr;
519 emit methodChanged("http-caching");
522 mrl = "https://" + addr;
523 emit methodChanged("http-caching");
526 mrl = "mms://" + addr;
527 emit methodChanged("mms-caching");
530 mrl = "ftp://" + addr;
531 emit methodChanged("ftp-caching");
534 mrl = "rtsp://" + addr;
535 emit methodChanged("rtsp-caching");
538 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
543 if ( addr_is_ipv6 && !addr.contains('[') )
545 mrl += "[" + addr + "]";
549 mrl += QString(":%1").arg( ui.portSpin->value() );
550 emit methodChanged("udp-caching");
553 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
557 if ( addr_is_ipv6 && !addr.contains('[') )
558 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
562 mrl += QString(":%1").arg( ui.portSpin->value() );
563 emit methodChanged("rtp-caching");
566 mrl = "rtmp://" + addr;
567 emit methodChanged("rtmp-caching");
572 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
573 mrl += " :access-filter=timeshift";
575 emit mrlUpdated( mrl );
578 void NetOpenPanel::updateCompleter()
581 QStringList tempL = mrlList->stringList();
582 tempL.append( ui.addressText->text() );
583 mrlList->setStringList( tempL );
586 /**************************************************************************
587 * Open Capture device ( DVB, PVR, V4L, and similar ) *
588 **************************************************************************/
589 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
590 OpenPanel( _parent, _p_intf )
592 isInitialized = false;
595 void CaptureOpenPanel::initialize()
597 if( isInitialized ) return;
599 msg_Dbg( p_intf, "Initialization of Capture device panel" );
600 isInitialized = true;
604 BUTTONACT( ui.advancedButton, advancedDialog() );
606 /* Create two stacked layouts in the main comboBoxes */
607 QStackedLayout *stackedDevLayout = new QStackedLayout;
608 ui.cardBox->setLayout( stackedDevLayout );
610 QStackedLayout *stackedPropLayout = new QStackedLayout;
611 ui.optionsBox->setLayout( stackedPropLayout );
613 /* Creation and connections of the WIdgets in the stacked layout */
614 #define addModuleAndLayouts( number, name, label ) \
615 QWidget * name ## DevPage = new QWidget( this ); \
616 QWidget * name ## PropPage = new QWidget( this ); \
617 stackedDevLayout->addWidget( name ## DevPage ); \
618 stackedPropLayout->addWidget( name ## PropPage ); \
619 QGridLayout * name ## DevLayout = new QGridLayout; \
620 QGridLayout * name ## PropLayout = new QGridLayout; \
621 name ## DevPage->setLayout( name ## DevLayout ); \
622 name ## PropPage->setLayout( name ## PropLayout ); \
623 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
625 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
628 /*********************
629 * DirectShow Stuffs *
630 *********************/
631 if( module_exists( "dshow" ) ){
632 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
636 module_config_t *p_config =
637 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
638 vdevDshowW = new StringListConfigControl(
639 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
642 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
643 adevDshowW = new StringListConfigControl(
644 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
647 /* dshow Properties */
648 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
649 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
651 dshowVSizeLine = new QLineEdit;
652 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
653 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
657 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
658 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
659 CuMRL( dshowVSizeLine, textChanged( QString ) );
665 if( module_exists( "bda" ) ){
666 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
669 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
671 bdas = new QRadioButton( "DVB-S" );
672 bdas->setChecked( true );
673 bdac = new QRadioButton( "DVB-C" );
674 bdat = new QRadioButton( "DVB-T" );
676 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
677 bdaDevLayout->addWidget( bdas, 0, 1 );
678 bdaDevLayout->addWidget( bdac, 0, 2 );
679 bdaDevLayout->addWidget( bdat, 0, 3 );
682 QLabel *bdaFreqLabel =
683 new QLabel( qtr( "Transponder/multiplex frequency" ) );
684 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
686 bdaFreq = new QSpinBox;
687 bdaFreq->setAlignment( Qt::AlignRight );
688 bdaFreq->setSuffix(" kHz");
689 bdaFreq->setSingleStep( 1000 );
690 setSpinBoxFreq( bdaFreq )
691 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
693 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
694 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
696 bdaSrate = new QSpinBox;
697 bdaSrate->setAlignment( Qt::AlignRight );
698 bdaSrate->setSuffix(" kHz");
699 setSpinBoxFreq( bdaSrate );
700 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
702 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
703 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
705 bdaBandBox = new QComboBox;
706 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
707 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
709 bdaBandLabel->hide();
711 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
715 CuMRL( bdaFreq, valueChanged ( int ) );
716 CuMRL( bdaSrate, valueChanged ( int ) );
717 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
718 BUTTONACT( bdas, updateButtons() );
719 BUTTONACT( bdat, updateButtons() );
720 BUTTONACT( bdac, updateButtons() );
721 BUTTONACT( bdas, updateMRL() );
722 BUTTONACT( bdat, updateMRL() );
723 BUTTONACT( bdac, updateMRL() );
730 if( module_exists( "v4l2" ) ){
731 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
734 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
735 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
737 v4l2VideoDevice = new QLineEdit;
738 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
740 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
741 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
743 v4l2AudioDevice = new QLineEdit;
744 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
746 /* v4l2 Props panel */
747 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
748 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
750 v4l2StdBox = new QComboBox;
751 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
752 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
753 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
757 CuMRL( v4l2VideoDevice, textChanged( QString ) );
758 CuMRL( v4l2AudioDevice, textChanged( QString ) );
759 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
765 if( module_exists( "v4l" ) ){
766 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
769 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
770 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
772 v4lVideoDevice = new QLineEdit;
773 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
775 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
776 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
778 v4lAudioDevice = new QLineEdit;
779 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
781 /* V4l Props panel */
782 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
783 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
785 v4lNormBox = new QComboBox;
786 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
787 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
789 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
790 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
792 v4lFreq = new QSpinBox;
793 v4lFreq->setAlignment( Qt::AlignRight );
794 v4lFreq->setSuffix(" kHz");
795 setSpinBoxFreq( v4lFreq );
796 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
797 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
801 CuMRL( v4lVideoDevice, textChanged( QString ) );
802 CuMRL( v4lAudioDevice, textChanged( QString ) );
803 CuMRL( v4lFreq, valueChanged ( int ) );
804 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
810 if( module_exists( "jack" ) ){
811 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
813 /* Jack Main panel */
815 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
816 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
818 jackChannels = new QSpinBox;
819 setSpinBoxFreq( jackChannels );
820 jackChannels->setMaximum(255);
821 jackChannels->setValue(2);
822 jackChannels->setAlignment( Qt::AlignRight );
823 jackDevLayout->addWidget( jackChannels, 1, 1 );
825 /* Jack Props panel */
828 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
829 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
831 jackPortsSelected = new QLineEdit( qtr( ".*") );
832 jackPortsSelected->setAlignment( Qt::AlignRight );
833 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
836 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
837 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
838 jackCaching = new QSpinBox;
839 setSpinBoxFreq( jackCaching );
840 jackCaching->setSuffix( " ms" );
841 jackCaching->setValue(1000);
842 jackCaching->setAlignment( Qt::AlignRight );
843 jackPropLayout->addWidget( jackCaching, 1 , 1 );
846 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
847 jackPropLayout->addWidget( jackPace, 2, 1 );
850 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
851 jackPropLayout->addWidget( jackConnect, 3, 1 );
854 CuMRL( jackChannels, valueChanged( int ) );
855 CuMRL( jackCaching, valueChanged( int ) );
856 CuMRL( jackPace, stateChanged( int ) );
857 CuMRL( jackConnect, stateChanged( int ) );
858 CuMRL( jackPortsSelected, textChanged( QString ) );
864 if( module_exists( "pvr" ) ){
865 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
868 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
869 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
871 pvrDevice = new QLineEdit;
872 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
874 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
875 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
877 pvrRadioDevice = new QLineEdit;
878 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
880 /* PVR props panel */
881 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
882 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
884 pvrNormBox = new QComboBox;
885 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
886 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
888 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
889 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
891 pvrFreq = new QSpinBox;
892 pvrFreq->setAlignment( Qt::AlignRight );
893 pvrFreq->setSuffix(" kHz");
894 setSpinBoxFreq( pvrFreq );
895 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
897 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
898 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
900 pvrBitr = new QSpinBox;
901 pvrBitr->setAlignment( Qt::AlignRight );
902 pvrBitr->setSuffix(" kHz");
903 setSpinBoxFreq( pvrBitr );
904 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
905 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
909 CuMRL( pvrDevice, textChanged( QString ) );
910 CuMRL( pvrRadioDevice, textChanged( QString ) );
912 CuMRL( pvrFreq, valueChanged ( int ) );
913 CuMRL( pvrBitr, valueChanged ( int ) );
914 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
920 if( module_exists( "dvb" ) ){
921 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
924 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
925 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
927 dvbCard = new QSpinBox;
928 dvbCard->setAlignment( Qt::AlignRight );
929 dvbCard->setPrefix( "/dev/dvb/adapter" );
931 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
932 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
934 dvbs = new QRadioButton( "DVB-S" );
935 dvbs->setChecked( true );
936 dvbc = new QRadioButton( "DVB-C" );
937 dvbt = new QRadioButton( "DVB-T" );
939 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
940 dvbDevLayout->addWidget( dvbs, 1, 1 );
941 dvbDevLayout->addWidget( dvbc, 1, 2 );
942 dvbDevLayout->addWidget( dvbt, 1, 3 );
944 /* DVB Props panel */
945 QLabel *dvbFreqLabel =
946 new QLabel( qtr( "Transponder/multiplex frequency" ) );
947 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
949 dvbFreq = new QSpinBox;
950 dvbFreq->setAlignment( Qt::AlignRight );
951 dvbFreq->setSuffix(" kHz");
952 setSpinBoxFreq( dvbFreq );
953 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
955 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
956 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
958 dvbSrate = new QSpinBox;
959 dvbSrate->setAlignment( Qt::AlignRight );
960 dvbSrate->setSuffix(" kHz");
961 setSpinBoxFreq( dvbSrate );
962 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
963 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
967 CuMRL( dvbCard, valueChanged ( int ) );
968 CuMRL( dvbFreq, valueChanged ( int ) );
969 CuMRL( dvbSrate, valueChanged ( int ) );
971 BUTTONACT( dvbs, updateButtons() );
972 BUTTONACT( dvbt, updateButtons() );
973 BUTTONACT( dvbc, updateButtons() );
982 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
983 QLabel *screenLabel = new QLabel( "This option will open your own "
984 "desktop in order to save or stream it.");
985 screenLabel->setWordWrap( true );
986 screenDevLayout->addWidget( screenLabel, 0, 0 );
988 QLabel *screenFPSLabel = new QLabel(
989 qtr( "Desired frame rate for the capture." ) );
990 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
992 screenFPS = new QSpinBox;
993 screenFPS->setValue( 1 );
994 screenFPS->setAlignment( Qt::AlignRight );
995 screenPropLayout->addWidget( screenFPS, 0, 1 );
997 /* General connects */
998 CONNECT( ui.deviceCombo, activated( int ) ,
999 stackedDevLayout, setCurrentIndex( int ) );
1000 CONNECT( ui.deviceCombo, activated( int ),
1001 stackedPropLayout, setCurrentIndex( int ) );
1002 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1003 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1008 CaptureOpenPanel::~CaptureOpenPanel()
1012 void CaptureOpenPanel::clear()
1017 void CaptureOpenPanel::updateMRL()
1020 int i_devicetype = ui.deviceCombo->itemData(
1021 ui.deviceCombo->currentIndex() ).toInt();
1022 switch( i_devicetype )
1026 if( bdas->isChecked() ) mrl = "dvb-s://";
1027 else if( bdat->isChecked() ) mrl = "dvb-t://";
1028 else if( bdac->isChecked() ) mrl = "dvb-c://";
1030 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1031 if( bdas->isChecked() || bdac->isChecked() )
1032 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1034 mrl += " :dvb-bandwidth=" +
1035 QString("%1").arg( bdaBandBox->itemData(
1036 bdaBandBox->currentIndex() ).toInt() );
1040 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1041 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1042 if( dshowVSizeLine->isModified() )
1043 mrl += " :dshow-size=" + dshowVSizeLine->text();
1048 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1049 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1050 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1051 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1055 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1056 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1057 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1061 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1062 mrl += ":ports=" + jackPortsSelected->text();
1063 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1064 if ( jackPace->isChecked() )
1066 mrl += " --jack-input-use-vlc-pace";
1068 if ( jackConnect->isChecked() )
1070 mrl += " --jack-input-auto-connect";
1075 mrl += " :pvr-device=" + pvrDevice->text();
1076 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1077 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1078 if( pvrFreq->value() )
1079 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1080 if( pvrBitr->value() )
1081 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1085 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1086 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1087 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1092 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1097 if( !advMRL.isEmpty() ) mrl += advMRL;
1099 emit mrlUpdated( mrl );
1103 * Update the Buttons (show/hide) for the GUI as all device type don't
1104 * use the same ui. elements.
1106 void CaptureOpenPanel::updateButtons()
1108 /* Be sure to display the ui Elements in case they were hidden by
1109 * some Device Type (like Screen://) */
1110 ui.optionsBox->show();
1111 ui.advancedButton->show();
1112 /* Get the current Device Number */
1113 int i_devicetype = ui.deviceCombo->itemData(
1114 ui.deviceCombo->currentIndex() ).toInt();
1115 switch( i_devicetype )
1119 if( bdas->isChecked() || bdac->isChecked() )
1122 bdaSrateLabel->show();
1124 bdaBandLabel->hide();
1129 bdaSrateLabel->hide();
1131 bdaBandLabel->show();
1136 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1137 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1141 //ui.optionsBox->hide();
1142 ui.advancedButton->hide();
1149 void CaptureOpenPanel::advancedDialog()
1151 /* Get selected device type */
1152 int i_devicetype = ui.deviceCombo->itemData(
1153 ui.deviceCombo->currentIndex() ).toInt();
1155 /* Get the corresponding module */
1156 module_t *p_module =
1157 module_find( psz_devModule[i_devicetype] );
1158 if( NULL == p_module ) return;
1161 QList<ConfigControl *> controls;
1163 /* Get the confsize */
1164 unsigned int i_confsize;
1165 module_config_t *p_config;
1166 p_config = module_config_get( p_module, &i_confsize );
1168 /* New Adv Prop dialog */
1169 adv = new QDialog( this );
1170 adv->setWindowTitle( qtr( "Advanced Options" ) );
1172 /* A main Layout with a Frame */
1173 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1174 QScrollArea *scroll = new QScrollArea;
1175 mainLayout->addWidget( scroll );
1177 QFrame *advFrame = new QFrame;
1178 /* GridLayout inside the Frame */
1179 QGridLayout *gLayout = new QGridLayout( advFrame );
1181 scroll->setWidgetResizable( true );
1182 scroll->setWidget( advFrame );
1184 /* Create the options inside the FrameLayout */
1185 for( int n = 0; n < i_confsize; n++ )
1187 module_config_t *p_item = p_config + n;
1188 ConfigControl *config = ConfigControl::createControl(
1189 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1190 controls.append( config );
1194 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1195 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1196 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1198 CONNECT( closeButton, clicked(), adv, accept() );
1199 CONNECT( cancelButton, clicked(), adv, reject() );
1201 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1202 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1204 mainLayout->addWidget( advButtonBox );
1206 /* Creation of the MRL */
1209 QString tempMRL = "";
1210 for( int i = 0; i < controls.size(); i++ )
1212 ConfigControl *control = controls[i];
1215 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1219 tempMRL += (i ? " :" : ":");
1221 if( control->getType() == CONFIG_ITEM_BOOL )
1222 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1225 tempMRL += control->getName();
1227 switch( control->getType() )
1229 case CONFIG_ITEM_STRING:
1230 case CONFIG_ITEM_FILE:
1231 case CONFIG_ITEM_DIRECTORY:
1232 case CONFIG_ITEM_MODULE:
1233 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1235 case CONFIG_ITEM_INTEGER:
1236 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1238 case CONFIG_ITEM_FLOAT:
1239 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1245 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1248 module_config_free( p_config );
1249 module_release (p_module);