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" );
675 bdaa = new QRadioButton( "ATSC" );
677 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
678 bdaDevLayout->addWidget( bdas, 0, 1 );
679 bdaDevLayout->addWidget( bdac, 0, 2 );
680 bdaDevLayout->addWidget( bdat, 0, 3 );
681 bdaDevLayout->addWidget( bdaa, 0, 4 );
684 QLabel *bdaFreqLabel =
685 new QLabel( qtr( "Transponder/multiplex frequency" ) );
686 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
688 bdaFreq = new QSpinBox;
689 bdaFreq->setAlignment( Qt::AlignRight );
690 bdaFreq->setSuffix(" kHz");
691 bdaFreq->setSingleStep( 1000 );
692 setSpinBoxFreq( bdaFreq )
693 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
695 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
696 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
698 bdaSrate = new QSpinBox;
699 bdaSrate->setAlignment( Qt::AlignRight );
700 bdaSrate->setSuffix(" kHz");
701 setSpinBoxFreq( bdaSrate );
702 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
704 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
705 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
707 bdaBandBox = new QComboBox;
708 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
709 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
711 bdaBandLabel->hide();
713 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
717 CuMRL( bdaFreq, valueChanged ( int ) );
718 CuMRL( bdaSrate, valueChanged ( int ) );
719 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
720 BUTTONACT( bdas, updateButtons() );
721 BUTTONACT( bdat, updateButtons() );
722 BUTTONACT( bdac, updateButtons() );
723 BUTTONACT( bdaa, updateButtons() );
724 BUTTONACT( bdas, updateMRL() );
725 BUTTONACT( bdat, updateMRL() );
726 BUTTONACT( bdac, updateMRL() );
727 BUTTONACT( bdaa, updateMRL() );
734 if( module_exists( "v4l2" ) ){
735 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
738 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
739 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
741 v4l2VideoDevice = new QLineEdit;
742 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
744 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
745 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
747 v4l2AudioDevice = new QLineEdit;
748 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
750 /* v4l2 Props panel */
751 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
752 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
754 v4l2StdBox = new QComboBox;
755 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
756 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
757 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
761 CuMRL( v4l2VideoDevice, textChanged( QString ) );
762 CuMRL( v4l2AudioDevice, textChanged( QString ) );
763 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
769 if( module_exists( "v4l" ) ){
770 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
773 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
774 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
776 v4lVideoDevice = new QLineEdit;
777 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
779 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
780 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
782 v4lAudioDevice = new QLineEdit;
783 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
785 /* V4l Props panel */
786 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
787 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
789 v4lNormBox = new QComboBox;
790 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
791 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
793 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
794 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
796 v4lFreq = new QSpinBox;
797 v4lFreq->setAlignment( Qt::AlignRight );
798 v4lFreq->setSuffix(" kHz");
799 setSpinBoxFreq( v4lFreq );
800 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
801 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
805 CuMRL( v4lVideoDevice, textChanged( QString ) );
806 CuMRL( v4lAudioDevice, textChanged( QString ) );
807 CuMRL( v4lFreq, valueChanged ( int ) );
808 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
814 if( module_exists( "jack" ) ){
815 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
817 /* Jack Main panel */
819 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
820 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
822 jackChannels = new QSpinBox;
823 setSpinBoxFreq( jackChannels );
824 jackChannels->setMaximum(255);
825 jackChannels->setValue(2);
826 jackChannels->setAlignment( Qt::AlignRight );
827 jackDevLayout->addWidget( jackChannels, 1, 1 );
829 /* Jack Props panel */
832 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
833 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
835 jackPortsSelected = new QLineEdit( qtr( ".*") );
836 jackPortsSelected->setAlignment( Qt::AlignRight );
837 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
840 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
841 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
842 jackCaching = new QSpinBox;
843 setSpinBoxFreq( jackCaching );
844 jackCaching->setSuffix( " ms" );
845 jackCaching->setValue(1000);
846 jackCaching->setAlignment( Qt::AlignRight );
847 jackPropLayout->addWidget( jackCaching, 1 , 1 );
850 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
851 jackPropLayout->addWidget( jackPace, 2, 1 );
854 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
855 jackPropLayout->addWidget( jackConnect, 3, 1 );
858 CuMRL( jackChannels, valueChanged( int ) );
859 CuMRL( jackCaching, valueChanged( int ) );
860 CuMRL( jackPace, stateChanged( int ) );
861 CuMRL( jackConnect, stateChanged( int ) );
862 CuMRL( jackPortsSelected, textChanged( QString ) );
868 if( module_exists( "pvr" ) ){
869 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
872 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
873 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
875 pvrDevice = new QLineEdit;
876 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
878 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
879 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
881 pvrRadioDevice = new QLineEdit;
882 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
884 /* PVR props panel */
885 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
886 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
888 pvrNormBox = new QComboBox;
889 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
890 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
892 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
893 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
895 pvrFreq = new QSpinBox;
896 pvrFreq->setAlignment( Qt::AlignRight );
897 pvrFreq->setSuffix(" kHz");
898 setSpinBoxFreq( pvrFreq );
899 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
901 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
902 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
904 pvrBitr = new QSpinBox;
905 pvrBitr->setAlignment( Qt::AlignRight );
906 pvrBitr->setSuffix(" kHz");
907 setSpinBoxFreq( pvrBitr );
908 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
909 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
913 CuMRL( pvrDevice, textChanged( QString ) );
914 CuMRL( pvrRadioDevice, textChanged( QString ) );
916 CuMRL( pvrFreq, valueChanged ( int ) );
917 CuMRL( pvrBitr, valueChanged ( int ) );
918 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
924 if( module_exists( "dvb" ) ){
925 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
928 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
929 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
931 dvbCard = new QSpinBox;
932 dvbCard->setAlignment( Qt::AlignRight );
933 dvbCard->setPrefix( "/dev/dvb/adapter" );
935 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
936 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
938 dvbs = new QRadioButton( "DVB-S" );
939 dvbs->setChecked( true );
940 dvbc = new QRadioButton( "DVB-C" );
941 dvbt = new QRadioButton( "DVB-T" );
943 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
944 dvbDevLayout->addWidget( dvbs, 1, 1 );
945 dvbDevLayout->addWidget( dvbc, 1, 2 );
946 dvbDevLayout->addWidget( dvbt, 1, 3 );
948 /* DVB Props panel */
949 QLabel *dvbFreqLabel =
950 new QLabel( qtr( "Transponder/multiplex frequency" ) );
951 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
953 dvbFreq = new QSpinBox;
954 dvbFreq->setAlignment( Qt::AlignRight );
955 dvbFreq->setSuffix(" kHz");
956 setSpinBoxFreq( dvbFreq );
957 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
959 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
960 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
962 dvbSrate = new QSpinBox;
963 dvbSrate->setAlignment( Qt::AlignRight );
964 dvbSrate->setSuffix(" kHz");
965 setSpinBoxFreq( dvbSrate );
966 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
967 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
971 CuMRL( dvbCard, valueChanged ( int ) );
972 CuMRL( dvbFreq, valueChanged ( int ) );
973 CuMRL( dvbSrate, valueChanged ( int ) );
975 BUTTONACT( dvbs, updateButtons() );
976 BUTTONACT( dvbt, updateButtons() );
977 BUTTONACT( dvbc, updateButtons() );
986 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
987 QLabel *screenLabel = new QLabel( "This option will open your own "
988 "desktop in order to save or stream it.");
989 screenLabel->setWordWrap( true );
990 screenDevLayout->addWidget( screenLabel, 0, 0 );
992 QLabel *screenFPSLabel = new QLabel(
993 qtr( "Desired frame rate for the capture." ) );
994 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
996 screenFPS = new QSpinBox;
997 screenFPS->setValue( 1 );
998 screenFPS->setAlignment( Qt::AlignRight );
999 screenPropLayout->addWidget( screenFPS, 0, 1 );
1001 /* General connects */
1002 CONNECT( ui.deviceCombo, activated( int ) ,
1003 stackedDevLayout, setCurrentIndex( int ) );
1004 CONNECT( ui.deviceCombo, activated( int ),
1005 stackedPropLayout, setCurrentIndex( int ) );
1006 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1007 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1012 CaptureOpenPanel::~CaptureOpenPanel()
1016 void CaptureOpenPanel::clear()
1021 void CaptureOpenPanel::updateMRL()
1024 int i_devicetype = ui.deviceCombo->itemData(
1025 ui.deviceCombo->currentIndex() ).toInt();
1026 switch( i_devicetype )
1030 if( bdas->isChecked() ) mrl = "dvb-s://";
1031 else if( bdat->isChecked() ) mrl = "dvb-t://";
1032 else if( bdac->isChecked() ) mrl = "dvb-c://";
1033 else if( bdaa->isChecked() ) mrl = "atsc://";
1035 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1036 if( bdas->isChecked() || bdac->isChecked() )
1037 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1038 else if( bdat->isChecked() )
1039 mrl += " :dvb-bandwidth=" +
1040 QString("%1").arg( bdaBandBox->itemData(
1041 bdaBandBox->currentIndex() ).toInt() );
1045 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1046 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1047 if( dshowVSizeLine->isModified() )
1048 mrl += " :dshow-size=" + dshowVSizeLine->text();
1053 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1054 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1055 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1056 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1060 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1061 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1062 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1066 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1067 mrl += ":ports=" + jackPortsSelected->text();
1068 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1069 if ( jackPace->isChecked() )
1071 mrl += " --jack-input-use-vlc-pace";
1073 if ( jackConnect->isChecked() )
1075 mrl += " --jack-input-auto-connect";
1080 mrl += " :pvr-device=" + pvrDevice->text();
1081 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1082 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1083 if( pvrFreq->value() )
1084 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1085 if( pvrBitr->value() )
1086 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1090 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1091 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1092 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1097 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1102 if( !advMRL.isEmpty() ) mrl += advMRL;
1104 emit mrlUpdated( mrl );
1108 * Update the Buttons (show/hide) for the GUI as all device type don't
1109 * use the same ui. elements.
1111 void CaptureOpenPanel::updateButtons()
1113 /* Be sure to display the ui Elements in case they were hidden by
1114 * some Device Type (like Screen://) */
1115 ui.optionsBox->show();
1116 ui.advancedButton->show();
1117 /* Get the current Device Number */
1118 int i_devicetype = ui.deviceCombo->itemData(
1119 ui.deviceCombo->currentIndex() ).toInt();
1120 switch( i_devicetype )
1124 if( bdas->isChecked() || bdac->isChecked() )
1127 bdaSrateLabel->show();
1129 bdaBandLabel->hide();
1131 else if( bdat->isChecked() )
1134 bdaSrateLabel->hide();
1136 bdaBandLabel->show();
1141 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1142 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1146 //ui.optionsBox->hide();
1147 ui.advancedButton->hide();
1154 void CaptureOpenPanel::advancedDialog()
1156 /* Get selected device type */
1157 int i_devicetype = ui.deviceCombo->itemData(
1158 ui.deviceCombo->currentIndex() ).toInt();
1160 /* Get the corresponding module */
1161 module_t *p_module =
1162 module_find( psz_devModule[i_devicetype] );
1163 if( NULL == p_module ) return;
1166 QList<ConfigControl *> controls;
1168 /* Get the confsize */
1169 unsigned int i_confsize;
1170 module_config_t *p_config;
1171 p_config = module_config_get( p_module, &i_confsize );
1173 /* New Adv Prop dialog */
1174 adv = new QDialog( this );
1175 adv->setWindowTitle( qtr( "Advanced Options" ) );
1177 /* A main Layout with a Frame */
1178 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1179 QScrollArea *scroll = new QScrollArea;
1180 mainLayout->addWidget( scroll );
1182 QFrame *advFrame = new QFrame;
1183 /* GridLayout inside the Frame */
1184 QGridLayout *gLayout = new QGridLayout( advFrame );
1186 scroll->setWidgetResizable( true );
1187 scroll->setWidget( advFrame );
1189 /* Create the options inside the FrameLayout */
1190 for( int n = 0; n < i_confsize; n++ )
1192 module_config_t *p_item = p_config + n;
1193 ConfigControl *config = ConfigControl::createControl(
1194 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1195 controls.append( config );
1199 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1200 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1201 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1203 CONNECT( closeButton, clicked(), adv, accept() );
1204 CONNECT( cancelButton, clicked(), adv, reject() );
1206 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1207 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1209 mainLayout->addWidget( advButtonBox );
1211 /* Creation of the MRL */
1214 QString tempMRL = "";
1215 for( int i = 0; i < controls.size(); i++ )
1217 ConfigControl *control = controls[i];
1220 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1224 tempMRL += (i ? " :" : ":");
1226 if( control->getType() == CONFIG_ITEM_BOOL )
1227 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1230 tempMRL += control->getName();
1232 switch( control->getType() )
1234 case CONFIG_ITEM_STRING:
1235 case CONFIG_ITEM_FILE:
1236 case CONFIG_ITEM_DIRECTORY:
1237 case CONFIG_ITEM_MODULE:
1238 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1240 case CONFIG_ITEM_INTEGER:
1241 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1243 case CONFIG_ITEM_FLOAT:
1244 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1250 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1253 module_config_free( p_config );
1254 module_release (p_module);