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 );
81 dialogBox->restoreState(
82 getSettings()->value( "file-dialog-state" ).toByteArray() );
85 /* We don't want to see a grip in the middle of the window, do we? */
86 dialogBox->setSizeGripEnabled( false );
89 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
90 dialogBox->setMinimumHeight( 250 );
92 // But hide the two OK/Cancel buttons. Enable them for debug.
93 QDialogButtonBox *fileDialogAcceptBox =
94 dialogBox->findChildren<QDialogButtonBox*>()[0];
95 fileDialogAcceptBox->hide();
97 /* Ugly hacks to get the good Widget */
98 //This lineEdit is the normal line in the fileDialog.
100 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
102 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
104 /* Make a list of QLabel inside the QFileDialog to access the good ones */
105 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
107 /* Hide the FileNames one. Enable it for debug */
108 listLabel[1]->setText( qtr( "File names:" ) );
109 /* Change the text that was uncool in the usual box */
110 listLabel[2]->setText( qtr( "Filter:" ) );
112 dialogBox->layout()->setMargin( 0 );
113 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
115 /** END of QFileDialog tweaking **/
117 // Add the DialogBox to the layout
118 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
120 //TODO later: fill the fileCompleteList with previous items played.
121 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
122 fileCompleter->setModel( new QDirModel( fileCompleter ) );
123 lineFileEdit->setCompleter( fileCompleter );
125 // Hide the subtitles control by default.
128 /* Build the subs size combo box */
129 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
130 ui.sizeSubComboBox );
132 /* Build the subs align combo box */
133 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
136 BUTTONACT( ui.subBrowseButton, browseFileSub() );
137 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
139 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
140 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
141 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
142 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
145 FileOpenPanel::~FileOpenPanel()
148 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
152 /* Show a fileBrowser to select a subtitle */
153 void FileOpenPanel::browseFileSub()
155 // TODO Handle selection of more than one subtitles file
156 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
158 dialogBox->directory().absolutePath() );
159 if( files.isEmpty() ) return;
160 ui.subInput->setText( files.join(" ") );
164 /* Update the current MRL */
165 void FileOpenPanel::updateMRL()
168 foreach( QString file, dialogBox->selectedFiles() ) {
169 mrl += "\"" + file + "\" ";
172 if( ui.subCheckBox->isChecked() ) {
173 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
174 int align = ui.alignSubComboBox->itemData(
175 ui.alignSubComboBox->currentIndex() ).toInt();
176 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
177 int size = ui.sizeSubComboBox->itemData(
178 ui.sizeSubComboBox->currentIndex() ).toInt();
179 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
182 emit mrlUpdated( mrl );
183 emit methodChanged( "file-caching" );
186 /* Function called by Open Dialog when clicke on Play/Enqueue */
187 void FileOpenPanel::accept()
189 //TODO set the completer
190 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
193 void FileOpenBox::accept()
195 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
198 void FileOpenBox::reject()
200 OpenDialog::getInstance( NULL, NULL, true )->cancel();
203 /* Function called by Open Dialog when clicked on cancel */
204 void FileOpenPanel::clear()
206 lineFileEdit->clear();
207 ui.subInput->clear();
210 void FileOpenPanel::toggleSubtitleFrame()
212 TOGGLEV( ui.subFrame );
218 /**************************************************************************
219 * Open Discs ( DVD, CD, VCD and similar devices ) *
220 **************************************************************************/
221 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
222 OpenPanel( _parent, _p_intf )
226 /* Get the default configuration path for the devices */
227 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
228 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
229 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
231 /* State to avoid overwritting the users changes with the configuration */
236 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
237 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
239 #ifdef WIN32 /* Disc drives probing for Windows */
242 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
244 char *drive = szDrives;
245 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
248 if( GetDriveTypeA(drive) == DRIVE_CDROM )
249 ui.deviceCombo->addItem( drive );
251 /* go to next drive */
254 SetErrorMode(oldMode);
256 #else /* Use a Completer under Linux */
257 QCompleter *discCompleter = new QCompleter( this );
258 discCompleter->setModel( new QDirModel( discCompleter ) );
259 ui.deviceCombo->setCompleter( discCompleter );
263 BUTTONACT( ui.dvdRadioButton, updateButtons() );
264 BUTTONACT( ui.vcdRadioButton, updateButtons() );
265 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
266 BUTTONACT( ui.dvdsimple, updateButtons() );
267 BUTTONACT( ui.browseDiscButton, browseDevice() );
268 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
271 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
272 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
273 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
274 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
275 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
277 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
281 DiscOpenPanel::~DiscOpenPanel()
283 free( psz_dvddiscpath );
284 free( psz_vcddiscpath );
285 free( psz_cddadiscpath );
288 void DiscOpenPanel::clear()
290 ui.titleSpin->setValue( 0 );
291 ui.chapterSpin->setValue( 0 );
298 #define setDrive( psz_name ) {\
299 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
300 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
302 #define setDrive( psz_name ) {\
303 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
306 /* update the buttons according the type of device */
307 void DiscOpenPanel::updateButtons()
309 if ( ui.dvdRadioButton->isChecked() )
313 setDrive( psz_dvddiscpath );
316 ui.titleLabel->setText( qtr("Title") );
317 ui.chapterLabel->show();
318 ui.chapterSpin->show();
319 ui.diskOptionBox_2->show();
320 ui.dvdsimple->setEnabled( true );
322 else if ( ui.vcdRadioButton->isChecked() )
326 setDrive( psz_vcddiscpath );
329 ui.titleLabel->setText( qtr("Entry") );
330 ui.chapterLabel->hide();
331 ui.chapterSpin->hide();
332 ui.diskOptionBox_2->show();
333 ui.dvdsimple->setEnabled( false );
339 setDrive( psz_cddadiscpath );
342 ui.titleLabel->setText( qtr("Track") );
343 ui.chapterLabel->hide();
344 ui.chapterSpin->hide();
345 ui.diskOptionBox_2->hide();
346 ui.dvdsimple->setEnabled( false );
352 /* Update the current MRL */
353 void DiscOpenPanel::updateMRL()
357 /* CDDAX and VCDX not implemented. TODO ? */
359 if( ui.dvdRadioButton->isChecked() ) {
360 if( !ui.dvdsimple->isChecked() )
363 mrl = "\"dvdsimple://";
364 mrl += ui.deviceCombo->currentText();
365 emit methodChanged( "dvdnav-caching" );
367 if ( ui.titleSpin->value() > 0 ) {
368 mrl += QString("@%1").arg( ui.titleSpin->value() );
369 if ( ui.chapterSpin->value() > 0 ) {
370 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
375 } else if ( ui.vcdRadioButton->isChecked() ) {
376 mrl = "\"vcd://" + ui.deviceCombo->currentText();
377 emit methodChanged( "vcd-caching" );
379 if( ui.titleSpin->value() > 0 ) {
380 mrl += QString("@E%1").arg( ui.titleSpin->value() );
385 mrl = "\"cdda://" + ui.deviceCombo->currentText();
386 if( ui.titleSpin->value() > 0 ) {
387 QString("@%1").arg( ui.titleSpin->value() );
393 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
395 if ( ui.audioSpin->value() >= 0 ) {
396 mrl += " :audio-track=" +
397 QString("%1").arg( ui.audioSpin->value() );
399 if ( ui.subtitlesSpin->value() >= 0 ) {
400 mrl += " :sub-track=" +
401 QString("%1").arg( ui.subtitlesSpin->value() );
404 emit mrlUpdated( mrl );
407 void DiscOpenPanel::browseDevice()
409 QString dir = QFileDialog::getExistingDirectory( this,
410 qtr( I_DEVICE_TOOLTIP ) );
412 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
417 void DiscOpenPanel::eject()
419 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
422 void DiscOpenPanel::accept()
425 /**************************************************************************
426 * Open Network streams and URL pages *
427 **************************************************************************/
428 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
429 OpenPanel( _parent, _p_intf )
434 CONNECT( ui.protocolCombo, activated( int ),
435 this, updateProtocol( int ) );
436 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
437 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
438 CONNECT( ui.timeShift, clicked(), this, updateMRL());
440 ui.protocolCombo->addItem( "" );
441 ui.protocolCombo->addItem("HTTP", QVariant("http"));
442 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
443 ui.protocolCombo->addItem("MMS", QVariant("mms"));
444 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
445 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
446 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
447 ui.protocolCombo->addItem("UDP", QVariant("udp"));
448 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
450 updateProtocol( ui.protocolCombo->currentIndex() );
452 if( config_GetInt( p_intf, "qt-recentplay" ) )
454 mrlList = new QStringListModel(
455 getSettings()->value( "Open/netMRL" ).toStringList() );
456 QCompleter *completer = new QCompleter( mrlList, this );
457 ui.addressText->setCompleter( completer );
459 CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
465 NetOpenPanel::~NetOpenPanel()
467 if( !mrlList ) return;
469 QStringList tempL = mrlList->stringList();
470 while( tempL.size() > 8 ) tempL.removeFirst();
472 getSettings()->setValue( "Open/netMRL", tempL );
475 void NetOpenPanel::clear()
478 /* update the widgets according the type of protocol */
479 void NetOpenPanel::updateProtocol( int idx_proto ) {
480 QString addr = ui.addressText->text();
481 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
483 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
484 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
485 idx_proto == RTP_PROTO );
487 if( idx_proto == NO_PROTO ) return;
489 /* If we already have a protocol in the address, replace it */
490 if( addr.contains( "://"))
492 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
493 addr.replace( QRegExp("^.*://@*"), proto + "://");
494 else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
495 ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
496 !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
497 addr.replace( QRegExp("^.*://"), proto + "://@");
499 addr.replace( QRegExp("^.*://"), proto + "://");
500 addr.replace( QRegExp("@+"), "@");
501 ui.addressText->setText( addr );
506 void NetOpenPanel::updateMRL() {
508 QString addr = ui.addressText->text();
509 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
510 int idx_proto = ui.protocolCombo->currentIndex();
511 int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
512 int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
513 int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
514 int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
515 if( addr.contains( "://"))
517 /* Match the correct item in the comboBox */
518 ui.protocolCombo->setCurrentIndex(
519 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
524 switch( idx_proto ) {
526 mrl = "http://" + addr;
527 emit methodChanged("http-caching");
530 mrl = "https://" + addr;
531 emit methodChanged("http-caching");
534 mrl = "mms://" + addr;
535 emit methodChanged("mms-caching");
538 mrl = "ftp://" + addr;
539 emit methodChanged("ftp-caching");
542 mrl = "rtsp://" + addr;
543 emit methodChanged("rtsp-caching");
546 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
551 if ( addr_is_ipv6 && !addr.contains('[') )
553 mrl += "[" + addr + "]";
557 mrl += QString(":%1").arg( ui.portSpin->value() );
558 emit methodChanged("udp-caching");
561 if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
565 if ( addr_is_ipv6 && !addr.contains('[') )
566 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
570 mrl += QString(":%1").arg( ui.portSpin->value() );
571 emit methodChanged("rtp-caching");
574 mrl = "rtmp://" + addr;
575 emit methodChanged("rtmp-caching");
580 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
581 mrl += " :access-filter=timeshift";
583 emit mrlUpdated( mrl );
586 void NetOpenPanel::updateCompleter()
589 QStringList tempL = mrlList->stringList();
590 tempL.append( ui.addressText->text() );
591 mrlList->setStringList( tempL );
594 /**************************************************************************
595 * Open Capture device ( DVB, PVR, V4L, and similar ) *
596 **************************************************************************/
597 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
598 OpenPanel( _parent, _p_intf )
600 isInitialized = false;
603 void CaptureOpenPanel::initialize()
605 if( isInitialized ) return;
607 msg_Dbg( p_intf, "Initialization of Capture device panel" );
608 isInitialized = true;
612 BUTTONACT( ui.advancedButton, advancedDialog() );
614 /* Create two stacked layouts in the main comboBoxes */
615 QStackedLayout *stackedDevLayout = new QStackedLayout;
616 ui.cardBox->setLayout( stackedDevLayout );
618 QStackedLayout *stackedPropLayout = new QStackedLayout;
619 ui.optionsBox->setLayout( stackedPropLayout );
621 /* Creation and connections of the WIdgets in the stacked layout */
622 #define addModuleAndLayouts( number, name, label ) \
623 QWidget * name ## DevPage = new QWidget( this ); \
624 QWidget * name ## PropPage = new QWidget( this ); \
625 stackedDevLayout->addWidget( name ## DevPage ); \
626 stackedPropLayout->addWidget( name ## PropPage ); \
627 QGridLayout * name ## DevLayout = new QGridLayout; \
628 QGridLayout * name ## PropLayout = new QGridLayout; \
629 name ## DevPage->setLayout( name ## DevLayout ); \
630 name ## PropPage->setLayout( name ## PropLayout ); \
631 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
633 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
636 /*********************
637 * DirectShow Stuffs *
638 *********************/
639 if( module_exists( "dshow" ) ){
640 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
644 module_config_t *p_config =
645 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
646 vdevDshowW = new StringListConfigControl(
647 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
650 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
651 adevDshowW = new StringListConfigControl(
652 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
655 /* dshow Properties */
656 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
657 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
659 dshowVSizeLine = new QLineEdit;
660 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
661 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
665 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
666 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
667 CuMRL( dshowVSizeLine, textChanged( QString ) );
673 if( module_exists( "bda" ) ){
674 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
677 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
679 bdas = new QRadioButton( "DVB-S" );
680 bdas->setChecked( true );
681 bdac = new QRadioButton( "DVB-C" );
682 bdat = new QRadioButton( "DVB-T" );
684 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
685 bdaDevLayout->addWidget( bdas, 0, 1 );
686 bdaDevLayout->addWidget( bdac, 0, 2 );
687 bdaDevLayout->addWidget( bdat, 0, 3 );
690 QLabel *bdaFreqLabel =
691 new QLabel( qtr( "Transponder/multiplex frequency" ) );
692 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
694 bdaFreq = new QSpinBox;
695 bdaFreq->setAlignment( Qt::AlignRight );
696 bdaFreq->setSuffix(" kHz");
697 bdaFreq->setSingleStep( 1000 );
698 setSpinBoxFreq( bdaFreq )
699 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
701 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
702 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
704 bdaSrate = new QSpinBox;
705 bdaSrate->setAlignment( Qt::AlignRight );
706 bdaSrate->setSuffix(" kHz");
707 setSpinBoxFreq( bdaSrate );
708 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
710 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
711 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
713 bdaBandBox = new QComboBox;
714 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
715 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
717 bdaBandLabel->hide();
719 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
723 CuMRL( bdaFreq, valueChanged ( int ) );
724 CuMRL( bdaSrate, valueChanged ( int ) );
725 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
726 BUTTONACT( bdas, updateButtons() );
727 BUTTONACT( bdat, updateButtons() );
728 BUTTONACT( bdac, updateButtons() );
729 BUTTONACT( bdas, updateMRL() );
730 BUTTONACT( bdat, updateMRL() );
731 BUTTONACT( bdac, updateMRL() );
738 if( module_exists( "v4l2" ) ){
739 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
742 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
743 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
745 v4l2VideoDevice = new QLineEdit;
746 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
748 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
749 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
751 v4l2AudioDevice = new QLineEdit;
752 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
754 /* v4l2 Props panel */
755 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
756 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
758 v4l2StdBox = new QComboBox;
759 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
760 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
761 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
765 CuMRL( v4l2VideoDevice, textChanged( QString ) );
766 CuMRL( v4l2AudioDevice, textChanged( QString ) );
767 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
773 if( module_exists( "v4l" ) ){
774 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
777 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
778 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
780 v4lVideoDevice = new QLineEdit;
781 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
783 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
784 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
786 v4lAudioDevice = new QLineEdit;
787 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
789 /* V4l Props panel */
790 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
791 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
793 v4lNormBox = new QComboBox;
794 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
795 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
797 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
798 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
800 v4lFreq = new QSpinBox;
801 v4lFreq->setAlignment( Qt::AlignRight );
802 v4lFreq->setSuffix(" kHz");
803 setSpinBoxFreq( v4lFreq );
804 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
805 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
809 CuMRL( v4lVideoDevice, textChanged( QString ) );
810 CuMRL( v4lAudioDevice, textChanged( QString ) );
811 CuMRL( v4lFreq, valueChanged ( int ) );
812 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
818 if( module_exists( "jack" ) ){
819 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
821 /* Jack Main panel */
823 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
824 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
826 jackChannels = new QSpinBox;
827 setSpinBoxFreq( jackChannels );
828 jackChannels->setMaximum(255);
829 jackChannels->setValue(2);
830 jackChannels->setAlignment( Qt::AlignRight );
831 jackDevLayout->addWidget( jackChannels, 1, 1 );
833 /* Jack Props panel */
836 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
837 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
839 jackPortsSelected = new QLineEdit( qtr( ".*") );
840 jackPortsSelected->setAlignment( Qt::AlignRight );
841 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
844 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
845 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
846 jackCaching = new QSpinBox;
847 setSpinBoxFreq( jackCaching );
848 jackCaching->setSuffix( " ms" );
849 jackCaching->setValue(1000);
850 jackCaching->setAlignment( Qt::AlignRight );
851 jackPropLayout->addWidget( jackCaching, 1 , 1 );
854 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
855 jackPropLayout->addWidget( jackPace, 2, 1 );
858 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
859 jackPropLayout->addWidget( jackConnect, 3, 1 );
862 CuMRL( jackChannels, valueChanged( int ) );
863 CuMRL( jackCaching, valueChanged( int ) );
864 CuMRL( jackPace, stateChanged( int ) );
865 CuMRL( jackConnect, stateChanged( int ) );
866 CuMRL( jackPortsSelected, textChanged( QString ) );
872 if( module_exists( "pvr" ) ){
873 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
876 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
877 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
879 pvrDevice = new QLineEdit;
880 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
882 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
883 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
885 pvrRadioDevice = new QLineEdit;
886 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
888 /* PVR props panel */
889 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
890 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
892 pvrNormBox = new QComboBox;
893 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
894 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
896 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
897 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
899 pvrFreq = new QSpinBox;
900 pvrFreq->setAlignment( Qt::AlignRight );
901 pvrFreq->setSuffix(" kHz");
902 setSpinBoxFreq( pvrFreq );
903 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
905 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
906 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
908 pvrBitr = new QSpinBox;
909 pvrBitr->setAlignment( Qt::AlignRight );
910 pvrBitr->setSuffix(" kHz");
911 setSpinBoxFreq( pvrBitr );
912 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
913 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
917 CuMRL( pvrDevice, textChanged( QString ) );
918 CuMRL( pvrRadioDevice, textChanged( QString ) );
920 CuMRL( pvrFreq, valueChanged ( int ) );
921 CuMRL( pvrBitr, valueChanged ( int ) );
922 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
928 if( module_exists( "dvb" ) ){
929 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
932 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
933 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
935 dvbCard = new QSpinBox;
936 dvbCard->setAlignment( Qt::AlignRight );
937 dvbCard->setPrefix( "/dev/dvb/adapter" );
939 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
940 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
942 dvbs = new QRadioButton( "DVB-S" );
943 dvbs->setChecked( true );
944 dvbc = new QRadioButton( "DVB-C" );
945 dvbt = new QRadioButton( "DVB-T" );
947 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
948 dvbDevLayout->addWidget( dvbs, 1, 1 );
949 dvbDevLayout->addWidget( dvbc, 1, 2 );
950 dvbDevLayout->addWidget( dvbt, 1, 3 );
952 /* DVB Props panel */
953 QLabel *dvbFreqLabel =
954 new QLabel( qtr( "Transponder/multiplex frequency" ) );
955 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
957 dvbFreq = new QSpinBox;
958 dvbFreq->setAlignment( Qt::AlignRight );
959 dvbFreq->setSuffix(" kHz");
960 setSpinBoxFreq( dvbFreq );
961 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
963 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
964 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
966 dvbSrate = new QSpinBox;
967 dvbSrate->setAlignment( Qt::AlignRight );
968 dvbSrate->setSuffix(" kHz");
969 setSpinBoxFreq( dvbSrate );
970 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
971 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
975 CuMRL( dvbCard, valueChanged ( int ) );
976 CuMRL( dvbFreq, valueChanged ( int ) );
977 CuMRL( dvbSrate, valueChanged ( int ) );
979 BUTTONACT( dvbs, updateButtons() );
980 BUTTONACT( dvbt, updateButtons() );
981 BUTTONACT( dvbc, updateButtons() );
990 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
991 QLabel *screenLabel = new QLabel( "This option will open your own "
992 "desktop in order to save or stream it.");
993 screenLabel->setWordWrap( true );
994 screenDevLayout->addWidget( screenLabel, 0, 0 );
996 QLabel *screenFPSLabel = new QLabel(
997 qtr( "Desired frame rate for the capture." ) );
998 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1000 screenFPS = new QSpinBox;
1001 screenFPS->setValue( 1 );
1002 screenFPS->setAlignment( Qt::AlignRight );
1003 screenPropLayout->addWidget( screenFPS, 0, 1 );
1005 /* General connects */
1006 CONNECT( ui.deviceCombo, activated( int ) ,
1007 stackedDevLayout, setCurrentIndex( int ) );
1008 CONNECT( ui.deviceCombo, activated( int ),
1009 stackedPropLayout, setCurrentIndex( int ) );
1010 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1011 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1016 CaptureOpenPanel::~CaptureOpenPanel()
1020 void CaptureOpenPanel::clear()
1025 void CaptureOpenPanel::updateMRL()
1028 int i_devicetype = ui.deviceCombo->itemData(
1029 ui.deviceCombo->currentIndex() ).toInt();
1030 switch( i_devicetype )
1034 if( bdas->isChecked() ) mrl = "dvb-s://";
1035 else if( bdat->isChecked() ) mrl = "dvb-t://";
1036 else if( bdac->isChecked() ) mrl = "dvb-c://";
1038 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
1039 if( bdas->isChecked() || bdac->isChecked() )
1040 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
1042 mrl += " :dvb-bandwidth=" +
1043 QString("%1").arg( bdaBandBox->itemData(
1044 bdaBandBox->currentIndex() ).toInt() );
1048 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
1049 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
1050 if( dshowVSizeLine->isModified() )
1051 mrl += " :dshow-size=" + dshowVSizeLine->text();
1056 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
1057 mrl += " :v4l-adev=" + v4lAudioDevice->text();
1058 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
1059 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
1063 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
1064 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
1065 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
1069 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
1070 mrl += ":ports=" + jackPortsSelected->text();
1071 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
1072 if ( jackPace->isChecked() )
1074 mrl += " --jack-input-use-vlc-pace";
1076 if ( jackConnect->isChecked() )
1078 mrl += " --jack-input-auto-connect";
1083 mrl += " :pvr-device=" + pvrDevice->text();
1084 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1085 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1086 if( pvrFreq->value() )
1087 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1088 if( pvrBitr->value() )
1089 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1093 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1094 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1095 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1100 mrl += " :screen-fps=" + QString("%1").arg( screenFPS->value() );
1105 if( !advMRL.isEmpty() ) mrl += advMRL;
1107 emit mrlUpdated( mrl );
1111 * Update the Buttons (show/hide) for the GUI as all device type don't
1112 * use the same ui. elements.
1114 void CaptureOpenPanel::updateButtons()
1116 /* Be sure to display the ui Elements in case they were hidden by
1117 * some Device Type (like Screen://) */
1118 ui.optionsBox->show();
1119 ui.advancedButton->show();
1120 /* Get the current Device Number */
1121 int i_devicetype = ui.deviceCombo->itemData(
1122 ui.deviceCombo->currentIndex() ).toInt();
1123 switch( i_devicetype )
1127 if( bdas->isChecked() || bdac->isChecked() )
1130 bdaSrateLabel->show();
1132 bdaBandLabel->hide();
1137 bdaSrateLabel->hide();
1139 bdaBandLabel->show();
1144 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1145 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1149 //ui.optionsBox->hide();
1150 ui.advancedButton->hide();
1157 void CaptureOpenPanel::advancedDialog()
1159 /* Get selected device type */
1160 int i_devicetype = ui.deviceCombo->itemData(
1161 ui.deviceCombo->currentIndex() ).toInt();
1163 /* Get the corresponding module */
1164 module_t *p_module =
1165 module_find( psz_devModule[i_devicetype] );
1166 if( NULL == p_module ) return;
1169 QList<ConfigControl *> controls;
1171 /* Get the confsize */
1172 unsigned int i_confsize;
1173 module_config_t *p_config;
1174 p_config = module_config_get( p_module, &i_confsize );
1176 /* New Adv Prop dialog */
1177 adv = new QDialog( this );
1178 adv->setWindowTitle( qtr( "Advanced Options" ) );
1180 /* A main Layout with a Frame */
1181 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1182 QScrollArea *scroll = new QScrollArea;
1183 mainLayout->addWidget( scroll );
1185 QFrame *advFrame = new QFrame;
1186 /* GridLayout inside the Frame */
1187 QGridLayout *gLayout = new QGridLayout( advFrame );
1189 scroll->setWidgetResizable( true );
1190 scroll->setWidget( advFrame );
1192 /* Create the options inside the FrameLayout */
1193 for( int n = 0; n < i_confsize; n++ )
1195 module_config_t *p_item = p_config + n;
1196 ConfigControl *config = ConfigControl::createControl(
1197 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1198 controls.append( config );
1202 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1203 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1204 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1206 CONNECT( closeButton, clicked(), adv, accept() );
1207 CONNECT( cancelButton, clicked(), adv, reject() );
1209 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1210 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1212 mainLayout->addWidget( advButtonBox );
1214 /* Creation of the MRL */
1217 QString tempMRL = "";
1218 for( int i = 0; i < controls.size(); i++ )
1220 ConfigControl *control = controls[i];
1223 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1227 tempMRL += (i ? " :" : ":");
1229 if( control->getType() == CONFIG_ITEM_BOOL )
1230 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1233 tempMRL += control->getName();
1235 switch( control->getType() )
1237 case CONFIG_ITEM_STRING:
1238 case CONFIG_ITEM_FILE:
1239 case CONFIG_ITEM_DIRECTORY:
1240 case CONFIG_ITEM_MODULE:
1241 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1243 case CONFIG_ITEM_INTEGER:
1244 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1246 case CONFIG_ITEM_FLOAT:
1247 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1253 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1256 module_config_free( p_config );
1257 module_release (p_module);