1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2007 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 *****************************************************************************/
31 #include "components/open_panels.hpp"
32 #include "dialogs/open.hpp"
33 #include "dialogs_provider.hpp"
35 #include <QFileDialog>
36 #include <QDialogButtonBox>
38 #include <QStackedLayout>
42 #include <QScrollArea>
45 /**************************************************************************
46 * Open Files and subtitles *
47 **************************************************************************/
48 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
49 OpenPanel( _parent, _p_intf )
51 /* Classic UI Setup */
54 /** BEGIN QFileDialog tweaking **/
55 /* Use a QFileDialog and customize it because we don't want to
56 rewrite it all. Be careful to your eyes cause there are a few hacks.
57 Be very careful and test correctly when you modify this. */
59 /* Set Filters for file selection */
60 QString fileTypes = "";
61 ADD_FILTER_MEDIA( fileTypes );
62 ADD_FILTER_VIDEO( fileTypes );
63 ADD_FILTER_AUDIO( fileTypes );
64 ADD_FILTER_PLAYLIST( fileTypes );
65 ADD_FILTER_ALL( fileTypes );
66 fileTypes.replace( QString(";*"), QString(" *"));
68 // Make this QFileDialog a child of tempWidget from the ui.
69 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
70 qfu( p_intf->p_sys->psz_filepath ), fileTypes );
72 dialogBox->setFileMode( QFileDialog::ExistingFiles );
73 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
74 dialogBox->setViewMode( config_GetInt( p_intf, "qt-open-detail" ) ?
75 QFileDialog::Detail : QFileDialog::List );
77 /* We don't want to see a grip in the middle of the window, do we? */
78 dialogBox->setSizeGripEnabled( false );
81 dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
83 // But hide the two OK/Cancel buttons. Enable them for debug.
84 QDialogButtonBox *fileDialogAcceptBox =
85 dialogBox->findChildren<QDialogButtonBox*>()[0];
86 fileDialogAcceptBox->hide();
88 /* Ugly hacks to get the good Widget */
89 //This lineEdit is the normal line in the fileDialog.
91 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
93 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
95 /* Make a list of QLabel inside the QFileDialog to access the good ones */
96 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
98 /* Hide the FileNames one. Enable it for debug */
99 listLabel[1]->setText( qtr( "File names:" ) );
100 /* Change the text that was uncool in the usual box */
101 listLabel[2]->setText( qtr( "Filter:" ) );
103 dialogBox->layout()->setMargin( 0 );
104 dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
106 /** END of QFileDialog tweaking **/
108 // Add the DialogBox to the layout
109 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
111 //TODO later: fill the fileCompleteList with previous items played.
112 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
113 fileCompleter->setModel( new QDirModel( fileCompleter ) );
114 lineFileEdit->setCompleter( fileCompleter );
116 // Hide the subtitles control by default.
119 /* Build the subs size combo box */
120 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
121 ui.sizeSubComboBox );
123 /* Build the subs align combo box */
124 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
127 BUTTONACT( ui.subBrowseButton, browseFileSub() );
128 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
130 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
131 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
132 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
133 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
136 FileOpenPanel::~FileOpenPanel()
140 /* Show a fileBrowser to select a subtitle */
141 void FileOpenPanel::browseFileSub()
143 // TODO Handle selection of more than one subtitles file
144 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
146 dialogBox->directory().absolutePath() );
147 if( files.isEmpty() ) return;
148 ui.subInput->setText( files.join(" ") );
152 /* Update the current MRL */
153 void FileOpenPanel::updateMRL()
156 foreach( QString file, dialogBox->selectedFiles() ) {
157 mrl += "\"" + file + "\" ";
160 if( ui.subCheckBox->isChecked() ) {
161 mrl.append( " :sub-file=" + ui.subInput->text() );
162 int align = ui.alignSubComboBox->itemData(
163 ui.alignSubComboBox->currentIndex() ).toInt();
164 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
165 int size = ui.sizeSubComboBox->itemData(
166 ui.sizeSubComboBox->currentIndex() ).toInt();
167 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
170 emit mrlUpdated( mrl );
171 emit methodChanged( "file-caching" );
174 /* Function called by Open Dialog when clicke on Play/Enqueue */
175 void FileOpenPanel::accept()
177 //TODO set the completer
178 p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
181 void FileOpenBox::accept()
183 OpenDialog::getInstance( NULL, NULL )->play();
186 /* Function called by Open Dialog when clicked on cancel */
187 void FileOpenPanel::clear()
189 lineFileEdit->clear();
190 ui.subInput->clear();
193 void FileOpenPanel::toggleSubtitleFrame()
195 TOGGLEV( ui.subFrame );
201 /**************************************************************************
202 * Open Discs ( DVD, CD, VCD and similar devices ) *
203 **************************************************************************/
204 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
205 OpenPanel( _parent, _p_intf )
209 /* Get the default configuration path for the devices */
210 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
211 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
212 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
214 /* State to avoid overwritting the users changes with the configuration */
219 #if WIN32 /* Disc drives probing for Windows */
222 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
224 char *drive = szDrives;
225 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
228 if( GetDriveTypeA(drive) == DRIVE_CDROM )
229 ui.deviceCombo->addItem( drive );
231 /* go to next drive */
234 SetErrorMode(oldMode);
236 #else /* Use a Completer under Linux */
237 QCompleter *discCompleter = new QCompleter( this );
238 discCompleter->setModel( new QDirModel( discCompleter ) );
239 ui.deviceCombo->setCompleter( discCompleter );
243 BUTTONACT( ui.dvdRadioButton, updateButtons() );
244 BUTTONACT( ui.vcdRadioButton, updateButtons() );
245 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
246 BUTTONACT( ui.dvdsimple, updateButtons() );
247 BUTTONACT( ui.browseDiscButton, browseDevice() );
249 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
250 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
251 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
252 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
253 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
255 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
259 DiscOpenPanel::~DiscOpenPanel()
261 delete psz_dvddiscpath;
262 delete psz_vcddiscpath;
263 delete psz_cddadiscpath;
266 void DiscOpenPanel::clear()
268 ui.titleSpin->setValue( 0 );
269 ui.chapterSpin->setValue( 0 );
276 #define setDrive( psz_name ) {\
277 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
278 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
280 #define setDrive( psz_name ) {\
281 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
284 /* update the buttons according the type of device */
285 void DiscOpenPanel::updateButtons()
287 if ( ui.dvdRadioButton->isChecked() )
291 setDrive( psz_dvddiscpath );
294 ui.titleLabel->setText( qtr("Title") );
295 ui.chapterLabel->show();
296 ui.chapterSpin->show();
297 ui.diskOptionBox_2->show();
299 else if ( ui.vcdRadioButton->isChecked() )
303 setDrive( psz_vcddiscpath );
306 ui.titleLabel->setText( qtr("Entry") );
307 ui.chapterLabel->hide();
308 ui.chapterSpin->hide();
309 ui.diskOptionBox_2->show();
315 setDrive( psz_cddadiscpath );
318 ui.titleLabel->setText( qtr("Track") );
319 ui.chapterLabel->hide();
320 ui.chapterSpin->hide();
321 ui.diskOptionBox_2->hide();
327 /* Update the current MRL */
328 void DiscOpenPanel::updateMRL()
332 /* CDDAX and VCDX not implemented. TODO ? */
334 if( ui.dvdRadioButton->isChecked() ) {
335 if( !ui.dvdsimple->isChecked() )
338 mrl = "dvdsimple://";
339 mrl += ui.deviceCombo->currentText();
340 emit methodChanged( "dvdnav-caching" );
342 if ( ui.titleSpin->value() > 0 ) {
343 mrl += QString("@%1").arg( ui.titleSpin->value() );
344 if ( ui.chapterSpin->value() > 0 ) {
345 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
350 } else if ( ui.vcdRadioButton->isChecked() ) {
351 mrl = "vcd://" + ui.deviceCombo->currentText();
352 emit methodChanged( "vcd-caching" );
354 if( ui.titleSpin->value() > 0 ) {
355 mrl += QString("@E%1").arg( ui.titleSpin->value() );
360 mrl = "cdda://" + ui.deviceCombo->currentText();
361 if( ui.titleSpin->value() > 0 ) {
362 QString("@%1").arg( ui.titleSpin->value() );
366 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
368 if ( ui.audioSpin->value() >= 0 ) {
369 mrl += " :audio-track=" +
370 QString("%1").arg( ui.audioSpin->value() );
372 if ( ui.subtitlesSpin->value() >= 0 ) {
373 mrl += " :sub-track=" +
374 QString("%1").arg( ui.subtitlesSpin->value() );
377 emit mrlUpdated( mrl );
380 void DiscOpenPanel::browseDevice()
382 QString dir = QFileDialog::getExistingDirectory( 0,
383 qtr("Open a device or a VIDEO_TS directory") );
384 if (!dir.isEmpty()) {
385 ui.deviceCombo->setEditText( dir );
390 void DiscOpenPanel::accept()
393 /**************************************************************************
394 * Open Network streams and URL pages *
395 **************************************************************************/
396 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
397 OpenPanel( _parent, _p_intf )
402 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
403 this, updateProtocol( int ) );
404 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
405 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
406 CONNECT( ui.timeShift, clicked(), this, updateMRL());
407 CONNECT( ui.ipv6, clicked(), this, updateMRL());
409 ui.protocolCombo->addItem("HTTP", QVariant("http"));
410 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
411 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
412 ui.protocolCombo->addItem("MMS", QVariant("mms"));
413 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
414 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
415 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
418 NetOpenPanel::~NetOpenPanel()
421 void NetOpenPanel::clear()
424 /* update the widgets according the type of protocol */
425 void NetOpenPanel::updateProtocol( int idx ) {
426 QString addr = ui.addressText->text();
427 QString proto = ui.protocolCombo->itemData( idx ).toString();
429 ui.timeShift->setEnabled( idx >= 5 );
430 ui.ipv6->setEnabled( idx == 5 );
431 ui.addressText->setEnabled( idx != 5 );
432 ui.portSpin->setEnabled( idx >= 5 );
434 /* If we already have a protocol in the address, replace it */
435 if( addr.contains( "://")) {
436 msg_Err( p_intf, "replace");
437 addr.replace( QRegExp("^.*://"), proto + "://");
438 ui.addressText->setText( addr );
443 void NetOpenPanel::updateMRL() {
445 QString addr = ui.addressText->text();
446 int proto = ui.protocolCombo->currentIndex();
448 if( addr.contains( "://") && proto != 5 ) {
453 mrl = "http://" + addr;
454 emit methodChanged("http-caching");
457 mrl = "https://" + addr;
458 emit methodChanged("http-caching");
461 mrl = "mms://" + addr;
462 emit methodChanged("mms-caching");
465 mrl = "ftp://" + addr;
466 emit methodChanged("ftp-caching");
469 mrl = "rtsp://" + addr;
470 emit methodChanged("rtsp-caching");
474 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
477 mrl += QString(":%1").arg( ui.portSpin->value() );
478 emit methodChanged("udp-caching");
480 case 6: /* UDP multicast */
483 if ( addr.contains(':') && !addr.contains('[') ) {
484 mrl += "[" + addr + "]";
486 mrl += QString(":%1").arg( ui.portSpin->value() );
487 emit methodChanged("udp-caching");
491 // Encode the boring stuffs
492 mrl = QUrl( mrl ).toEncoded();
493 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
494 mrl += " :access-filter=timeshift";
496 emit mrlUpdated( mrl );
499 /**************************************************************************
500 * Open Capture device ( DVB, PVR, V4L, and similar ) *
501 **************************************************************************/
502 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
503 OpenPanel( _parent, _p_intf )
507 BUTTONACT( ui.advancedButton, advancedDialog() );
509 /* Create two stacked layouts in the main comboBoxes */
510 QStackedLayout *stackedDevLayout = new QStackedLayout;
511 ui.cardBox->setLayout( stackedDevLayout );
513 QStackedLayout *stackedPropLayout = new QStackedLayout;
514 ui.optionsBox->setLayout( stackedPropLayout );
516 /* Creation and connections of the WIdgets in the stacked layout */
517 #define addModuleAndLayouts( number, name, label ) \
518 QWidget * name ## DevPage = new QWidget( this ); \
519 QWidget * name ## PropPage = new QWidget( this ); \
520 stackedDevLayout->addWidget( name ## DevPage ); \
521 stackedPropLayout->addWidget( name ## PropPage ); \
522 QGridLayout * name ## DevLayout = new QGridLayout; \
523 QGridLayout * name ## PropLayout = new QGridLayout; \
524 name ## DevPage->setLayout( name ## DevLayout ); \
525 name ## PropPage->setLayout( name ## PropLayout ); \
526 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
528 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
534 if( module_Exists( p_intf, "v4l" ) ){
535 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
538 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
539 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
541 v4lVideoDevice = new QLineEdit;
542 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
544 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
545 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
547 v4lAudioDevice = new QLineEdit;
548 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
550 /* V4l Props panel */
551 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
552 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
554 v4lNormBox = new QComboBox;
555 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
556 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
558 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
559 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
561 v4lFreq = new QSpinBox;
562 v4lFreq->setAlignment( Qt::AlignRight );
563 v4lFreq->setSuffix(" kHz");
564 setSpinBoxFreq( v4lFreq );
565 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
566 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
570 CuMRL( v4lVideoDevice, textChanged( QString ) );
571 CuMRL( v4lAudioDevice, textChanged( QString ) );
572 CuMRL( v4lFreq, valueChanged ( int ) );
573 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
579 if( module_Exists( p_intf, "v4l2" ) ){
580 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
583 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
584 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
586 v4l2VideoDevice = new QLineEdit;
587 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
589 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
590 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
592 v4l2AudioDevice = new QLineEdit;
593 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
595 /* v4l2 Props panel */
596 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
597 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
599 v4l2StdBox = new QComboBox;
600 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
601 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
602 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
606 CuMRL( v4l2VideoDevice, textChanged( QString ) );
607 CuMRL( v4l2AudioDevice, textChanged( QString ) );
608 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
614 if( module_Exists( p_intf, "jack" ) ){
615 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
617 /* Jack Main panel */
619 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
620 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
622 jackChannels = new QSpinBox;
623 setSpinBoxFreq( jackChannels );
624 jackChannels->setMaximum(255);
625 jackChannels->setValue(2);
626 jackChannels->setAlignment( Qt::AlignRight );
627 jackDevLayout->addWidget( jackChannels, 1, 1 );
629 /* Jack Props panel */
632 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
633 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
635 jackPortsSelected = new QLineEdit( qtr( ".*") );
636 jackPortsSelected->setAlignment( Qt::AlignRight );
637 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
640 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
641 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
642 jackCaching = new QSpinBox;
643 setSpinBoxFreq( jackCaching );
644 jackCaching->setSuffix( " ms" );
645 jackCaching->setValue(1000);
646 jackCaching->setAlignment( Qt::AlignRight );
647 jackPropLayout->addWidget( jackCaching, 1 , 1 );
650 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
651 jackPropLayout->addWidget( jackPace, 2, 1 );
654 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
655 jackPropLayout->addWidget( jackConnect, 3, 1 );
658 CuMRL( jackChannels, valueChanged( int ) );
659 CuMRL( jackCaching, valueChanged( int ) );
660 CuMRL( jackPace, stateChanged( int ) );
661 CuMRL( jackConnect, stateChanged( int ) );
662 CuMRL( jackPortsSelected, textChanged( QString ) );
668 if( module_Exists( p_intf, "pvr" ) ){
669 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
672 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
673 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
675 pvrDevice = new QLineEdit;
676 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
678 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
679 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
681 pvrRadioDevice = new QLineEdit;
682 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
684 /* PVR props panel */
685 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
686 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
688 pvrNormBox = new QComboBox;
689 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
690 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
692 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
693 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
695 pvrFreq = new QSpinBox;
696 pvrFreq->setAlignment( Qt::AlignRight );
697 pvrFreq->setSuffix(" kHz");
698 setSpinBoxFreq( pvrFreq );
699 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
701 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
702 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
704 pvrBitr = new QSpinBox;
705 pvrBitr->setAlignment( Qt::AlignRight );
706 pvrBitr->setSuffix(" kHz");
707 setSpinBoxFreq( pvrBitr );
708 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
709 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
713 CuMRL( pvrDevice, textChanged( QString ) );
714 CuMRL( pvrRadioDevice, textChanged( QString ) );
716 CuMRL( pvrFreq, valueChanged ( int ) );
717 CuMRL( pvrBitr, valueChanged ( int ) );
718 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
724 if( module_Exists( p_intf, "dvb" ) ){
725 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
728 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
729 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
731 dvbCard = new QSpinBox;
732 dvbCard->setAlignment( Qt::AlignRight );
733 dvbCard->setPrefix( "/dev/dvb/adapter" );
735 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
736 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
738 dvbs = new QRadioButton( "DVB-S" );
739 dvbs->setChecked( true );
740 dvbc = new QRadioButton( "DVB-C" );
741 dvbt = new QRadioButton( "DVB-T" );
743 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
744 dvbDevLayout->addWidget( dvbs, 1, 1 );
745 dvbDevLayout->addWidget( dvbc, 1, 2 );
746 dvbDevLayout->addWidget( dvbt, 1, 3 );
748 /* DVB Props panel */
749 QLabel *dvbFreqLabel =
750 new QLabel( qtr( "Transponder/multiplex frequency" ) );
751 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
753 dvbFreq = new QSpinBox;
754 dvbFreq->setAlignment( Qt::AlignRight );
755 dvbFreq->setSuffix(" kHz");
756 setSpinBoxFreq( dvbFreq );
757 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
759 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
760 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
762 dvbSrate = new QSpinBox;
763 dvbSrate->setAlignment( Qt::AlignRight );
764 dvbSrate->setSuffix(" kHz");
765 setSpinBoxFreq( dvbSrate );
766 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
767 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
771 CuMRL( dvbCard, valueChanged ( int ) );
772 CuMRL( dvbFreq, valueChanged ( int ) );
773 CuMRL( dvbSrate, valueChanged ( int ) );
775 BUTTONACT( dvbs, updateButtons() );
776 BUTTONACT( dvbt, updateButtons() );
777 BUTTONACT( dvbc, updateButtons() );
782 /*********************
783 * DirectShow Stuffs *
784 *********************/
785 if( module_Exists( p_intf, "dshow" ) ){
786 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
790 module_config_t *p_config =
791 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
792 vdevDshowW = new StringListConfigControl(
793 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
796 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
797 adevDshowW = new StringListConfigControl(
798 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
801 /* dshow Properties */
802 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
803 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
805 dshowVSizeLine = new QLineEdit;
806 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
807 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
811 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
812 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
813 CuMRL( dshowVSizeLine, textChanged( QString ) );
819 if( module_Exists( p_intf, "bda" ) ){
820 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
823 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
825 bdas = new QRadioButton( "DVB-S" );
826 bdas->setChecked( true );
827 bdac = new QRadioButton( "DVB-C" );
828 bdat = new QRadioButton( "DVB-T" );
830 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
831 bdaDevLayout->addWidget( bdas, 0, 1 );
832 bdaDevLayout->addWidget( bdac, 0, 2 );
833 bdaDevLayout->addWidget( bdat, 0, 3 );
836 QLabel *bdaFreqLabel =
837 new QLabel( qtr( "Transponder/multiplex frequency" ) );
838 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
840 bdaFreq = new QSpinBox;
841 bdaFreq->setAlignment( Qt::AlignRight );
842 bdaFreq->setSuffix(" kHz");
843 bdaFreq->setSingleStep( 1000 );
844 setSpinBoxFreq( bdaFreq )
845 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
847 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
848 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
850 bdaSrate = new QSpinBox;
851 bdaSrate->setAlignment( Qt::AlignRight );
852 bdaSrate->setSuffix(" kHz");
853 setSpinBoxFreq( bdaSrate );
854 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
856 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
857 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
859 bdaBandBox = new QComboBox;
860 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
861 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
863 bdaBandLabel->hide();
865 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
869 CuMRL( bdaFreq, valueChanged ( int ) );
870 CuMRL( bdaSrate, valueChanged ( int ) );
871 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
872 BUTTONACT( bdas, updateButtons() );
873 BUTTONACT( bdat, updateButtons() );
874 BUTTONACT( bdac, updateButtons() );
875 BUTTONACT( bdas, updateMRL() );
876 BUTTONACT( bdat, updateMRL() );
877 BUTTONACT( bdac, updateMRL() );
885 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
886 QLabel *screenLabel = new QLabel( "This option will open your own "
887 "desktop in order to save or stream it.");
888 screenLabel->setWordWrap( true );
889 screenDevLayout->addWidget( screenLabel, 0, 0 );
891 /* General connects */
892 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
893 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
894 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
895 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
896 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
897 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
902 CaptureOpenPanel::~CaptureOpenPanel()
906 void CaptureOpenPanel::clear()
911 void CaptureOpenPanel::updateMRL()
914 int i_devicetype = ui.deviceCombo->itemData(
915 ui.deviceCombo->currentIndex() ).toInt();
916 switch( i_devicetype )
921 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
922 mrl += " :v4l-adev=" + v4lAudioDevice->text();
923 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
924 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
928 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
929 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
930 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
934 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
935 mrl += ":ports=" + jackPortsSelected->text();
936 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
937 if ( jackPace->isChecked() )
939 mrl += " --jack-input-use-vlc-pace";
941 if ( jackConnect->isChecked() )
943 mrl += " --jack-input-auto-connect";
948 mrl += " :pvr-device=" + pvrDevice->text();
949 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
950 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
951 if( pvrFreq->value() )
952 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
953 if( pvrBitr->value() )
954 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
958 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
959 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
960 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
964 if( bdas->isChecked() ) mrl = "dvb-s://";
965 else if( bdat->isChecked() ) mrl = "dvb-t://";
966 else if( bdac->isChecked() ) mrl = "dvb-c://";
968 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
969 if( bdas->isChecked() || bdac->isChecked() )
970 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
972 mrl += " :dvb-bandwidth=" +
973 QString("%1").arg( bdaBandBox->itemData(
974 bdaBandBox->currentIndex() ).toInt() );
978 mrl += " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
979 mrl += " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
980 if( dshowVSizeLine->isModified() )
981 mrl += " :dshow-size=" + dshowVSizeLine->text();
990 if( !advMRL.isEmpty() ) mrl += advMRL;
992 emit mrlUpdated( mrl );
996 * Update the Buttons (show/hide) for the GUI as all device type don't
997 * use the same ui. elements.
999 void CaptureOpenPanel::updateButtons()
1001 /* Be sure to display the ui Elements in case they were hidden by
1002 * some Device Type (like Screen://) */
1003 ui.optionsBox->show();
1004 ui.advancedButton->show();
1005 /* Get the current Device Number */
1006 int i_devicetype = ui.deviceCombo->itemData(
1007 ui.deviceCombo->currentIndex() ).toInt();
1008 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
1009 switch( i_devicetype )
1013 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1014 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1018 if( bdas->isChecked() || bdac->isChecked() )
1021 bdaSrateLabel->show();
1023 bdaBandLabel->hide();
1028 bdaSrateLabel->hide();
1030 bdaBandLabel->show();
1035 ui.optionsBox->hide();
1036 ui.advancedButton->hide();
1043 void CaptureOpenPanel::advancedDialog()
1045 /* Get selected device type */
1046 int i_devicetype = ui.deviceCombo->itemData(
1047 ui.deviceCombo->currentIndex() ).toInt();
1049 /* Get the corresponding module */
1050 module_t *p_module =
1051 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1052 if( NULL == p_module ) return;
1055 QList<ConfigControl *> controls;
1057 /* Get the confsize */
1058 unsigned int i_confsize;
1059 module_config_t *p_config;
1060 p_config = module_GetConfig( p_module, &i_confsize );
1062 /* New Adv Prop dialog */
1063 adv = new QDialog( this );
1064 adv->setWindowTitle( qtr( "Advanced options..." ) );
1066 /* A main Layout with a Frame */
1067 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1069 QFrame *advFrame = new QFrame;
1070 mainLayout->addWidget( advFrame );
1072 /* GridLayout inside the Frame */
1073 QGridLayout *gLayout = new QGridLayout( advFrame );
1075 /* Create the options inside the FrameLayout */
1076 for( int n = 0; n < i_confsize; n++ )
1078 module_config_t *p_item = p_config + n;
1079 ConfigControl *config = ConfigControl::createControl(
1080 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1081 controls.append( config );
1085 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1086 QPushButton *closeButton = new QPushButton( qtr( "Ok" ) );
1087 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1089 CONNECT( closeButton, clicked(), adv, accept() );
1090 CONNECT( cancelButton, clicked(), adv, reject() );
1092 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1093 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1095 gLayout->addWidget( advButtonBox, i_confsize + 1, 0, 1, -1 );
1097 /* Creation of the MRL */
1100 QString tempMRL = "";
1101 for( int i = 0; i < controls.size(); i++ )
1103 ConfigControl *control = controls[i];
1106 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1110 tempMRL += (i ? " :" : ":");
1112 if( control->getType() == CONFIG_ITEM_BOOL )
1113 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1116 tempMRL += control->getName();
1118 switch( control->getType() )
1120 case CONFIG_ITEM_STRING:
1121 case CONFIG_ITEM_FILE:
1122 case CONFIG_ITEM_DIRECTORY:
1123 case CONFIG_ITEM_MODULE:
1124 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1126 case CONFIG_ITEM_INTEGER:
1127 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1129 case CONFIG_ITEM_FLOAT:
1130 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1136 msg_Dbg( p_intf, "%s", qtu( advMRL ) );