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>
48 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
50 /**************************************************************************
51 * Open Files and subtitles *
52 **************************************************************************/
53 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
54 OpenPanel( _parent, _p_intf )
56 /* Classic UI Setup */
59 /** BEGIN QFileDialog tweaking **/
60 /* Use a QFileDialog and customize it because we don't want to
61 rewrite it all. Be careful to your eyes cause there are a few hacks.
62 Be very careful and test correctly when you modify this. */
64 /* Set Filters for file selection */
65 QString fileTypes = "";
66 ADD_FILTER_MEDIA( fileTypes );
67 ADD_FILTER_VIDEO( fileTypes );
68 ADD_FILTER_AUDIO( fileTypes );
69 ADD_FILTER_PLAYLIST( fileTypes );
70 ADD_FILTER_ALL( fileTypes );
71 fileTypes.replace( QString(";*"), QString(" *"));
73 // Make this QFileDialog a child of tempWidget from the ui.
74 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
75 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
77 dialogBox->setFileMode( QFileDialog::ExistingFiles );
78 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
80 dialogBox->restoreState(
81 getSettings()->value( "file-dialog-state" ).toByteArray() );
84 /* We don't want to see a grip in the middle of the window, do we? */
85 dialogBox->setSizeGripEnabled( false );
88 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
89 dialogBox->setMinimumHeight( 250 );
91 // But hide the two OK/Cancel buttons. Enable them for debug.
92 QDialogButtonBox *fileDialogAcceptBox =
93 dialogBox->findChildren<QDialogButtonBox*>()[0];
94 fileDialogAcceptBox->hide();
96 /* Ugly hacks to get the good Widget */
97 //This lineEdit is the normal line in the fileDialog.
99 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
101 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
103 /* Make a list of QLabel inside the QFileDialog to access the good ones */
104 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
106 /* Hide the FileNames one. Enable it for debug */
107 listLabel[1]->setText( qtr( "File names:" ) );
108 /* Change the text that was uncool in the usual box */
109 listLabel[2]->setText( qtr( "Filter:" ) );
111 dialogBox->layout()->setMargin( 0 );
112 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
114 /** END of QFileDialog tweaking **/
116 // Add the DialogBox to the layout
117 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
119 //TODO later: fill the fileCompleteList with previous items played.
120 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
121 fileCompleter->setModel( new QDirModel( fileCompleter ) );
122 lineFileEdit->setCompleter( fileCompleter );
124 // Hide the subtitles control by default.
127 /* Build the subs size combo box */
128 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
129 ui.sizeSubComboBox );
131 /* Build the subs align combo box */
132 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
135 BUTTONACT( ui.subBrowseButton, browseFileSub() );
136 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
138 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
139 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
140 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
141 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
144 FileOpenPanel::~FileOpenPanel()
147 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
151 /* Show a fileBrowser to select a subtitle */
152 void FileOpenPanel::browseFileSub()
154 // TODO Handle selection of more than one subtitles file
155 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
157 dialogBox->directory().absolutePath() );
158 if( files.isEmpty() ) return;
159 ui.subInput->setText( files.join(" ") );
163 /* Update the current MRL */
164 void FileOpenPanel::updateMRL()
167 foreach( QString file, dialogBox->selectedFiles() ) {
168 mrl += "\"" + file + "\" ";
171 if( ui.subCheckBox->isChecked() ) {
172 mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
173 int align = ui.alignSubComboBox->itemData(
174 ui.alignSubComboBox->currentIndex() ).toInt();
175 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
176 int size = ui.sizeSubComboBox->itemData(
177 ui.sizeSubComboBox->currentIndex() ).toInt();
178 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
181 emit mrlUpdated( mrl );
182 emit methodChanged( "file-caching" );
185 /* Function called by Open Dialog when clicke on Play/Enqueue */
186 void FileOpenPanel::accept()
188 //TODO set the completer
189 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
192 void FileOpenBox::accept()
194 OpenDialog::getInstance( NULL, NULL, true )->selectSlots();
197 /* Function called by Open Dialog when clicked on cancel */
198 void FileOpenPanel::clear()
200 lineFileEdit->clear();
201 ui.subInput->clear();
204 void FileOpenPanel::toggleSubtitleFrame()
206 TOGGLEV( ui.subFrame );
212 /**************************************************************************
213 * Open Discs ( DVD, CD, VCD and similar devices ) *
214 **************************************************************************/
215 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
216 OpenPanel( _parent, _p_intf )
220 /* Get the default configuration path for the devices */
221 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
222 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
223 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
225 /* State to avoid overwritting the users changes with the configuration */
230 ui.browseDiscButton->setToolTip( I_DEVICE_TOOLTIP );
231 ui.deviceCombo->setToolTip( I_DEVICE_TOOLTIP );
233 #if WIN32 /* Disc drives probing for Windows */
236 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
238 char *drive = szDrives;
239 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
242 if( GetDriveTypeA(drive) == DRIVE_CDROM )
243 ui.deviceCombo->addItem( drive );
245 /* go to next drive */
248 SetErrorMode(oldMode);
250 #else /* Use a Completer under Linux */
251 QCompleter *discCompleter = new QCompleter( this );
252 discCompleter->setModel( new QDirModel( discCompleter ) );
253 ui.deviceCombo->setCompleter( discCompleter );
257 BUTTONACT( ui.dvdRadioButton, updateButtons() );
258 BUTTONACT( ui.vcdRadioButton, updateButtons() );
259 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
260 BUTTONACT( ui.dvdsimple, updateButtons() );
261 BUTTONACT( ui.browseDiscButton, browseDevice() );
262 BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
265 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
266 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
267 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
268 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
269 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
271 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
275 DiscOpenPanel::~DiscOpenPanel()
277 free( psz_dvddiscpath );
278 free( psz_vcddiscpath );
279 free( psz_cddadiscpath );
282 void DiscOpenPanel::clear()
284 ui.titleSpin->setValue( 0 );
285 ui.chapterSpin->setValue( 0 );
292 #define setDrive( psz_name ) {\
293 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
294 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
296 #define setDrive( psz_name ) {\
297 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
300 /* update the buttons according the type of device */
301 void DiscOpenPanel::updateButtons()
303 if ( ui.dvdRadioButton->isChecked() )
307 setDrive( psz_dvddiscpath );
310 ui.titleLabel->setText( qtr("Title") );
311 ui.chapterLabel->show();
312 ui.chapterSpin->show();
313 ui.diskOptionBox_2->show();
314 ui.dvdsimple->setEnabled( true );
316 else if ( ui.vcdRadioButton->isChecked() )
320 setDrive( psz_vcddiscpath );
323 ui.titleLabel->setText( qtr("Entry") );
324 ui.chapterLabel->hide();
325 ui.chapterSpin->hide();
326 ui.diskOptionBox_2->show();
327 ui.dvdsimple->setEnabled( false );
333 setDrive( psz_cddadiscpath );
336 ui.titleLabel->setText( qtr("Track") );
337 ui.chapterLabel->hide();
338 ui.chapterSpin->hide();
339 ui.diskOptionBox_2->hide();
340 ui.dvdsimple->setEnabled( false );
346 /* Update the current MRL */
347 void DiscOpenPanel::updateMRL()
351 /* CDDAX and VCDX not implemented. TODO ? */
353 if( ui.dvdRadioButton->isChecked() ) {
354 if( !ui.dvdsimple->isChecked() )
357 mrl = "\"dvdsimple://";
358 mrl += ui.deviceCombo->currentText();
359 emit methodChanged( "dvdnav-caching" );
361 if ( ui.titleSpin->value() > 0 ) {
362 mrl += QString("@%1").arg( ui.titleSpin->value() );
363 if ( ui.chapterSpin->value() > 0 ) {
364 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
369 } else if ( ui.vcdRadioButton->isChecked() ) {
370 mrl = "\"vcd://" + ui.deviceCombo->currentText();
371 emit methodChanged( "vcd-caching" );
373 if( ui.titleSpin->value() > 0 ) {
374 mrl += QString("@E%1").arg( ui.titleSpin->value() );
379 mrl = "\"cdda://" + ui.deviceCombo->currentText();
380 if( ui.titleSpin->value() > 0 ) {
381 QString("@%1").arg( ui.titleSpin->value() );
387 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
389 if ( ui.audioSpin->value() >= 0 ) {
390 mrl += " :audio-track=" +
391 QString("%1").arg( ui.audioSpin->value() );
393 if ( ui.subtitlesSpin->value() >= 0 ) {
394 mrl += " :sub-track=" +
395 QString("%1").arg( ui.subtitlesSpin->value() );
398 emit mrlUpdated( mrl );
401 void DiscOpenPanel::browseDevice()
403 QString dir = QFileDialog::getExistingDirectory( 0,
404 qtr( I_DEVICE_TOOLTIP ) );
405 if (!dir.isEmpty()) {
406 ui.deviceCombo->setEditText( dir );
411 void DiscOpenPanel::eject()
413 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
416 void DiscOpenPanel::accept()
419 /**************************************************************************
420 * Open Network streams and URL pages *
421 **************************************************************************/
422 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
423 OpenPanel( _parent, _p_intf )
428 CONNECT( ui.protocolCombo, activated( int ),
429 this, updateProtocol( int ) );
430 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
431 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
432 CONNECT( ui.timeShift, clicked(), this, updateMRL());
434 ui.protocolCombo->addItem( "" );
435 ui.protocolCombo->addItem("HTTP", QVariant("http"));
436 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
437 ui.protocolCombo->addItem("MMS", QVariant("mms"));
438 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
439 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
440 ui.protocolCombo->addItem("RTP", QVariant("rtp"));
441 ui.protocolCombo->addItem("UDP", QVariant("udp"));
442 ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
444 updateProtocol( ui.protocolCombo->currentIndex() );
447 NetOpenPanel::~NetOpenPanel()
450 void NetOpenPanel::clear()
453 /* update the widgets according the type of protocol */
454 void NetOpenPanel::updateProtocol( int idx_proto ) {
455 QString addr = ui.addressText->text();
456 QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
458 ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
459 ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
460 idx_proto == RTP_PROTO );
462 if( idx_proto == NO_PROTO ) return;
464 /* If we already have a protocol in the address, replace it */
465 if( addr.contains( "://"))
467 if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
468 addr.replace( QRegExp("^.*://@*"), proto + "://");
470 addr.replace( QRegExp("^.*://"), proto + "://@");
471 ui.addressText->setText( addr );
476 void NetOpenPanel::updateMRL() {
478 QString addr = ui.addressText->text();
479 addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
480 int idx_proto = ui.protocolCombo->currentIndex();
482 if( addr.contains( "://"))
484 /* Match the correct item in the comboBox */
485 ui.protocolCombo->setCurrentIndex(
486 ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
488 if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
493 switch( idx_proto ) {
495 mrl = "http://" + addr;
496 emit methodChanged("http-caching");
499 mrl = "https://" + addr;
500 emit methodChanged("http-caching");
503 mrl = "mms://" + addr;
504 emit methodChanged("mms-caching");
507 mrl = "ftp://" + addr;
508 emit methodChanged("ftp-caching");
511 mrl = "rtsp://" + addr;
512 emit methodChanged("rtsp-caching");
517 if ( addr.contains(':') && !addr.contains('[') )
519 mrl += "[" + addr + "]";
522 mrl += QString(":%1").arg( ui.portSpin->value() );
523 emit methodChanged("udp-caching");
527 if ( addr.contains(':') && !addr.contains('[') )
528 mrl += "[" + addr + "]"; /* Add [] to IPv6 */
531 mrl += QString(":%1").arg( ui.portSpin->value() );
532 emit methodChanged("rtp-caching");
535 mrl = "rtmp://" + addr;
536 emit methodChanged("rtmp-caching");
541 // Encode the boring stuffs
543 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
544 mrl += " :access-filter=timeshift";
546 emit mrlUpdated( mrl );
549 /**************************************************************************
550 * Open Capture device ( DVB, PVR, V4L, and similar ) *
551 **************************************************************************/
552 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
553 OpenPanel( _parent, _p_intf )
557 BUTTONACT( ui.advancedButton, advancedDialog() );
559 /* Create two stacked layouts in the main comboBoxes */
560 QStackedLayout *stackedDevLayout = new QStackedLayout;
561 ui.cardBox->setLayout( stackedDevLayout );
563 QStackedLayout *stackedPropLayout = new QStackedLayout;
564 ui.optionsBox->setLayout( stackedPropLayout );
566 /* Creation and connections of the WIdgets in the stacked layout */
567 #define addModuleAndLayouts( number, name, label ) \
568 QWidget * name ## DevPage = new QWidget( this ); \
569 QWidget * name ## PropPage = new QWidget( this ); \
570 stackedDevLayout->addWidget( name ## DevPage ); \
571 stackedPropLayout->addWidget( name ## PropPage ); \
572 QGridLayout * name ## DevLayout = new QGridLayout; \
573 QGridLayout * name ## PropLayout = new QGridLayout; \
574 name ## DevPage->setLayout( name ## DevLayout ); \
575 name ## PropPage->setLayout( name ## PropLayout ); \
576 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
578 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
581 /*********************
582 * DirectShow Stuffs *
583 *********************/
584 if( module_Exists( p_intf, "dshow" ) ){
585 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
587 devLayout = dshowDevLayout;
588 /* dshow Properties */
589 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
590 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
592 dshowVSizeLine = new QLineEdit;
593 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
594 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
598 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
599 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
600 CuMRL( dshowVSizeLine, textChanged( QString ) );
606 if( module_Exists( p_intf, "bda" ) ){
607 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
610 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
612 bdas = new QRadioButton( "DVB-S" );
613 bdas->setChecked( true );
614 bdac = new QRadioButton( "DVB-C" );
615 bdat = new QRadioButton( "DVB-T" );
617 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
618 bdaDevLayout->addWidget( bdas, 0, 1 );
619 bdaDevLayout->addWidget( bdac, 0, 2 );
620 bdaDevLayout->addWidget( bdat, 0, 3 );
623 QLabel *bdaFreqLabel =
624 new QLabel( qtr( "Transponder/multiplex frequency" ) );
625 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
627 bdaFreq = new QSpinBox;
628 bdaFreq->setAlignment( Qt::AlignRight );
629 bdaFreq->setSuffix(" kHz");
630 bdaFreq->setSingleStep( 1000 );
631 setSpinBoxFreq( bdaFreq )
632 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
634 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
635 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
637 bdaSrate = new QSpinBox;
638 bdaSrate->setAlignment( Qt::AlignRight );
639 bdaSrate->setSuffix(" kHz");
640 setSpinBoxFreq( bdaSrate );
641 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
643 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
644 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
646 bdaBandBox = new QComboBox;
647 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
648 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
650 bdaBandLabel->hide();
652 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
656 CuMRL( bdaFreq, valueChanged ( int ) );
657 CuMRL( bdaSrate, valueChanged ( int ) );
658 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
659 BUTTONACT( bdas, updateButtons() );
660 BUTTONACT( bdat, updateButtons() );
661 BUTTONACT( bdac, updateButtons() );
662 BUTTONACT( bdas, updateMRL() );
663 BUTTONACT( bdat, updateMRL() );
664 BUTTONACT( bdac, updateMRL() );
671 if( module_Exists( p_intf, "v4l2" ) ){
672 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
675 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
676 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
678 v4l2VideoDevice = new QLineEdit;
679 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
681 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
682 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
684 v4l2AudioDevice = new QLineEdit;
685 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
687 /* v4l2 Props panel */
688 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
689 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
691 v4l2StdBox = new QComboBox;
692 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
693 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
694 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
698 CuMRL( v4l2VideoDevice, textChanged( QString ) );
699 CuMRL( v4l2AudioDevice, textChanged( QString ) );
700 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
706 if( module_Exists( p_intf, "v4l" ) ){
707 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
710 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
711 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
713 v4lVideoDevice = new QLineEdit;
714 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
716 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
717 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
719 v4lAudioDevice = new QLineEdit;
720 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
722 /* V4l Props panel */
723 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
724 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
726 v4lNormBox = new QComboBox;
727 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
728 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
730 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
731 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
733 v4lFreq = new QSpinBox;
734 v4lFreq->setAlignment( Qt::AlignRight );
735 v4lFreq->setSuffix(" kHz");
736 setSpinBoxFreq( v4lFreq );
737 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
738 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
742 CuMRL( v4lVideoDevice, textChanged( QString ) );
743 CuMRL( v4lAudioDevice, textChanged( QString ) );
744 CuMRL( v4lFreq, valueChanged ( int ) );
745 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
751 if( module_Exists( p_intf, "jack" ) ){
752 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
754 /* Jack Main panel */
756 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
757 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
759 jackChannels = new QSpinBox;
760 setSpinBoxFreq( jackChannels );
761 jackChannels->setMaximum(255);
762 jackChannels->setValue(2);
763 jackChannels->setAlignment( Qt::AlignRight );
764 jackDevLayout->addWidget( jackChannels, 1, 1 );
766 /* Jack Props panel */
769 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
770 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
772 jackPortsSelected = new QLineEdit( qtr( ".*") );
773 jackPortsSelected->setAlignment( Qt::AlignRight );
774 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
777 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
778 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
779 jackCaching = new QSpinBox;
780 setSpinBoxFreq( jackCaching );
781 jackCaching->setSuffix( " ms" );
782 jackCaching->setValue(1000);
783 jackCaching->setAlignment( Qt::AlignRight );
784 jackPropLayout->addWidget( jackCaching, 1 , 1 );
787 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
788 jackPropLayout->addWidget( jackPace, 2, 1 );
791 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
792 jackPropLayout->addWidget( jackConnect, 3, 1 );
795 CuMRL( jackChannels, valueChanged( int ) );
796 CuMRL( jackCaching, valueChanged( int ) );
797 CuMRL( jackPace, stateChanged( int ) );
798 CuMRL( jackConnect, stateChanged( int ) );
799 CuMRL( jackPortsSelected, textChanged( QString ) );
805 if( module_Exists( p_intf, "pvr" ) ){
806 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
809 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
810 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
812 pvrDevice = new QLineEdit;
813 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
815 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
816 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
818 pvrRadioDevice = new QLineEdit;
819 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
821 /* PVR props panel */
822 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
823 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
825 pvrNormBox = new QComboBox;
826 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
827 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
829 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
830 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
832 pvrFreq = new QSpinBox;
833 pvrFreq->setAlignment( Qt::AlignRight );
834 pvrFreq->setSuffix(" kHz");
835 setSpinBoxFreq( pvrFreq );
836 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
838 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
839 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
841 pvrBitr = new QSpinBox;
842 pvrBitr->setAlignment( Qt::AlignRight );
843 pvrBitr->setSuffix(" kHz");
844 setSpinBoxFreq( pvrBitr );
845 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
846 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
850 CuMRL( pvrDevice, textChanged( QString ) );
851 CuMRL( pvrRadioDevice, textChanged( QString ) );
853 CuMRL( pvrFreq, valueChanged ( int ) );
854 CuMRL( pvrBitr, valueChanged ( int ) );
855 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
861 if( module_Exists( p_intf, "dvb" ) ){
862 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
865 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
866 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
868 dvbCard = new QSpinBox;
869 dvbCard->setAlignment( Qt::AlignRight );
870 dvbCard->setPrefix( "/dev/dvb/adapter" );
872 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
873 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
875 dvbs = new QRadioButton( "DVB-S" );
876 dvbs->setChecked( true );
877 dvbc = new QRadioButton( "DVB-C" );
878 dvbt = new QRadioButton( "DVB-T" );
880 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
881 dvbDevLayout->addWidget( dvbs, 1, 1 );
882 dvbDevLayout->addWidget( dvbc, 1, 2 );
883 dvbDevLayout->addWidget( dvbt, 1, 3 );
885 /* DVB Props panel */
886 QLabel *dvbFreqLabel =
887 new QLabel( qtr( "Transponder/multiplex frequency" ) );
888 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
890 dvbFreq = new QSpinBox;
891 dvbFreq->setAlignment( Qt::AlignRight );
892 dvbFreq->setSuffix(" kHz");
893 setSpinBoxFreq( dvbFreq );
894 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
896 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
897 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
899 dvbSrate = new QSpinBox;
900 dvbSrate->setAlignment( Qt::AlignRight );
901 dvbSrate->setSuffix(" kHz");
902 setSpinBoxFreq( dvbSrate );
903 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
904 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
908 CuMRL( dvbCard, valueChanged ( int ) );
909 CuMRL( dvbFreq, valueChanged ( int ) );
910 CuMRL( dvbSrate, valueChanged ( int ) );
912 BUTTONACT( dvbs, updateButtons() );
913 BUTTONACT( dvbt, updateButtons() );
914 BUTTONACT( dvbc, updateButtons() );
923 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
924 QLabel *screenLabel = new QLabel( "This option will open your own "
925 "desktop in order to save or stream it.");
926 screenLabel->setWordWrap( true );
927 screenDevLayout->addWidget( screenLabel, 0, 0 );
929 /* General connects */
930 CONNECT( ui.deviceCombo, activated( int ) ,
931 stackedDevLayout, setCurrentIndex( int ) );
932 CONNECT( ui.deviceCombo, activated( int ),
933 stackedPropLayout, setCurrentIndex( int ) );
934 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
935 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
940 CaptureOpenPanel::~CaptureOpenPanel()
944 void CaptureOpenPanel::clear()
949 void CaptureOpenPanel::updateMRL()
952 int i_devicetype = ui.deviceCombo->itemData(
953 ui.deviceCombo->currentIndex() ).toInt();
954 switch( i_devicetype )
958 if( bdas->isChecked() ) mrl = "dvb-s://";
959 else if( bdat->isChecked() ) mrl = "dvb-t://";
960 else if( bdac->isChecked() ) mrl = "dvb-c://";
962 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
963 if( bdas->isChecked() || bdac->isChecked() )
964 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
966 mrl += " :dvb-bandwidth=" +
967 QString("%1").arg( bdaBandBox->itemData(
968 bdaBandBox->currentIndex() ).toInt() );
972 mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
973 mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
974 if( dshowVSizeLine->isModified() )
975 mrl += " :dshow-size=" + dshowVSizeLine->text();
980 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
981 mrl += " :v4l-adev=" + v4lAudioDevice->text();
982 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
983 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
987 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
988 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
989 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
993 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
994 mrl += ":ports=" + jackPortsSelected->text();
995 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
996 if ( jackPace->isChecked() )
998 mrl += " --jack-input-use-vlc-pace";
1000 if ( jackConnect->isChecked() )
1002 mrl += " --jack-input-auto-connect";
1007 mrl += " :pvr-device=" + pvrDevice->text();
1008 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1009 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
1010 if( pvrFreq->value() )
1011 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
1012 if( pvrBitr->value() )
1013 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
1017 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
1018 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
1019 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
1028 if( !advMRL.isEmpty() ) mrl += advMRL;
1030 emit mrlUpdated( mrl );
1034 * Update the Buttons (show/hide) for the GUI as all device type don't
1035 * use the same ui. elements.
1037 void CaptureOpenPanel::updateButtons()
1039 /* Be sure to display the ui Elements in case they were hidden by
1040 * some Device Type (like Screen://) */
1041 ui.optionsBox->show();
1042 ui.advancedButton->show();
1043 /* Get the current Device Number */
1044 int i_devicetype = ui.deviceCombo->itemData(
1045 ui.deviceCombo->currentIndex() ).toInt();
1046 switch( i_devicetype )
1050 if( bdas->isChecked() || bdac->isChecked() )
1053 bdaSrateLabel->show();
1055 bdaBandLabel->hide();
1060 bdaSrateLabel->hide();
1062 bdaBandLabel->show();
1068 module_config_t *p_config =
1069 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
1070 vdevDshowW = new StringListConfigControl(
1071 VLC_OBJECT(p_intf), p_config, this, false, devLayout, line );
1074 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
1075 adevDshowW = new StringListConfigControl(
1076 VLC_OBJECT(p_intf), p_config, this, false, devLayout, line );
1081 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1082 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1086 ui.optionsBox->hide();
1087 ui.advancedButton->hide();
1094 void CaptureOpenPanel::advancedDialog()
1096 /* Get selected device type */
1097 int i_devicetype = ui.deviceCombo->itemData(
1098 ui.deviceCombo->currentIndex() ).toInt();
1100 /* Get the corresponding module */
1101 module_t *p_module =
1102 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1103 if( NULL == p_module ) return;
1106 QList<ConfigControl *> controls;
1108 /* Get the confsize */
1109 unsigned int i_confsize;
1110 module_config_t *p_config;
1111 p_config = module_GetConfig( p_module, &i_confsize );
1113 /* New Adv Prop dialog */
1114 adv = new QDialog( this );
1115 adv->setWindowTitle( qtr( "Advanced Options" ) );
1117 /* A main Layout with a Frame */
1118 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1119 QFrame *advFrame = new QFrame;
1120 QScrollArea *scroll = new QScrollArea;
1121 mainLayout->addWidget( scroll );
1123 /* GridLayout inside the Frame */
1124 QGridLayout *gLayout = new QGridLayout( advFrame );
1125 gLayout->setSizeConstraint( QLayout::SetFixedSize );
1127 scroll->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
1128 scroll->setWidgetResizable( true );
1129 scroll->setWidget( advFrame );
1131 /* Create the options inside the FrameLayout */
1132 for( int n = 0; n < i_confsize; n++ )
1134 module_config_t *p_item = p_config + n;
1135 ConfigControl *config = ConfigControl::createControl(
1136 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1137 controls.append( config );
1141 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1142 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1143 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1145 CONNECT( closeButton, clicked(), adv, accept() );
1146 CONNECT( cancelButton, clicked(), adv, reject() );
1148 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1149 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1151 mainLayout->addWidget( advButtonBox );
1153 /* Creation of the MRL */
1156 QString tempMRL = "";
1157 for( int i = 0; i < controls.size(); i++ )
1159 ConfigControl *control = controls[i];
1162 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1166 tempMRL += (i ? " :" : ":");
1168 if( control->getType() == CONFIG_ITEM_BOOL )
1169 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1172 tempMRL += control->getName();
1174 switch( control->getType() )
1176 case CONFIG_ITEM_STRING:
1177 case CONFIG_ITEM_FILE:
1178 case CONFIG_ITEM_DIRECTORY:
1179 case CONFIG_ITEM_MODULE:
1180 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1182 case CONFIG_ITEM_INTEGER:
1183 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1185 case CONFIG_ITEM_FLOAT:
1186 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1192 msg_Dbg( p_intf, "%s", qtu( advMRL ) );