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>
44 /**************************************************************************
45 * Open Files and subtitles *
46 **************************************************************************/
47 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
48 OpenPanel( _parent, _p_intf )
50 /* Classic UI Setup */
53 /** BEGIN QFileDialog tweaking **/
54 /* Use a QFileDialog and customize it because we don't want to
55 rewrite it all. Be careful to your eyes cause there are a few hacks.
56 Be very careful and test correctly when you modify this. */
58 /* Set Filters for file selection */
59 QString fileTypes = "";
60 ADD_FILTER_MEDIA( fileTypes );
61 ADD_FILTER_VIDEO( fileTypes );
62 ADD_FILTER_AUDIO( fileTypes );
63 ADD_FILTER_PLAYLIST( fileTypes );
64 ADD_FILTER_ALL( fileTypes );
65 fileTypes.replace( QString(";*"), QString(" *"));
67 /* retrieve last known path used in file browsing */
68 char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
69 if( EMPTY_STR( psz_filepath ) )
71 psz_filepath = p_intf->p_libvlc->psz_homedir;
74 // Make this QFileDialog a child of tempWidget from the ui.
75 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
76 qfu( psz_filepath ), fileTypes );
79 dialogBox->setFileMode( QFileDialog::ExistingFiles );
80 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
82 /* We don't want to see a grip in the middle of the window, do we? */
83 dialogBox->setSizeGripEnabled( false );
86 dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
88 // But hide the two OK/Cancel buttons. Enable them for debug.
89 QDialogButtonBox *fileDialogAcceptBox =
90 dialogBox->findChildren<QDialogButtonBox*>()[0];
91 fileDialogAcceptBox->hide();
93 /* Ugly hacks to get the good Widget */
94 //This lineEdit is the normal line in the fileDialog.
96 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
98 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
100 /* Make a list of QLabel inside the QFileDialog to access the good ones */
101 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
103 /* Hide the FileNames one. Enable it for debug */
104 listLabel[1]->setText( qtr( "File names:" ) );
105 /* Change the text that was uncool in the usual box */
106 listLabel[2]->setText( qtr( "Filter:" ) );
108 dialogBox->layout()->setMargin( 0 );
109 dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
111 /** END of QFileDialog tweaking **/
113 // Add the DialogBox to the layout
114 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
116 //TODO later: fill the fileCompleteList with previous items played.
117 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
118 fileCompleter->setModel( new QDirModel( fileCompleter ) );
119 lineFileEdit->setCompleter( fileCompleter );
121 // Hide the subtitles control by default.
124 /* Build the subs size combo box */
125 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
126 ui.sizeSubComboBox );
128 /* Build the subs align combo box */
129 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
132 BUTTONACT( ui.subBrowseButton, browseFileSub() );
133 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
135 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
136 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
137 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
138 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
141 FileOpenPanel::~FileOpenPanel(){}
143 /* Show a fileBrowser to select a subtitle */
144 void FileOpenPanel::browseFileSub()
146 // TODO Handle selection of more than one subtitles file
147 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
149 dialogBox->directory().absolutePath() );
150 if( files.isEmpty() ) return;
151 ui.subInput->setText( files.join(" ") );
155 /* Update the current MRL */
156 void FileOpenPanel::updateMRL()
159 foreach( QString file, dialogBox->selectedFiles() ) {
160 mrl += "\"" + file + "\" ";
163 if( ui.subCheckBox->isChecked() ) {
164 mrl.append( " :sub-file=" + ui.subInput->text() );
165 int align = ui.alignSubComboBox->itemData(
166 ui.alignSubComboBox->currentIndex() ).toInt();
167 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
168 int size = ui.sizeSubComboBox->itemData(
169 ui.sizeSubComboBox->currentIndex() ).toInt();
170 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
173 emit mrlUpdated( mrl );
174 emit methodChanged( "file-caching" );
177 /* Function called by Open Dialog when clicke on Play/Enqueue */
178 void FileOpenPanel::accept()
180 //TODO set the completer
181 const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
182 if( ( NULL == psz_filepath )
183 || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
185 /* set dialog box current directory as last known path */
186 config_PutPsz( p_intf, "qt-filedialog-path",
187 qtu( dialogBox->directory().absolutePath() ) );
192 void FileOpenBox::accept()
194 OpenDialog::getInstance( NULL, NULL )->play();
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 #if WIN32 /* Disc drives probing for Windows */
233 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
235 char *drive = szDrives;
236 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
239 if( GetDriveTypeA(drive) == DRIVE_CDROM )
240 ui.deviceCombo->addItem( drive );
242 /* go to next drive */
245 SetErrorMode(oldMode);
247 #else /* Use a Completer under Linux */
248 QCompleter *discCompleter = new QCompleter( this );
249 discCompleter->setModel( new QDirModel( discCompleter ) );
250 ui.deviceCombo->setCompleter( discCompleter );
254 BUTTONACT( ui.dvdRadioButton, updateButtons() );
255 BUTTONACT( ui.vcdRadioButton, updateButtons() );
256 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
257 BUTTONACT( ui.dvdsimple, updateButtons() );
258 BUTTONACT( ui.browseDiscButton, browseDevice() );
260 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
261 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
262 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
263 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
264 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
266 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
270 DiscOpenPanel::~DiscOpenPanel()
272 delete psz_dvddiscpath;
273 delete psz_vcddiscpath;
274 delete psz_cddadiscpath;
277 void DiscOpenPanel::clear()
279 ui.titleSpin->setValue( 0 );
280 ui.chapterSpin->setValue( 0 );
287 #define setDrive( psz_name ) {\
288 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
289 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
291 #define setDrive( psz_name ) {\
292 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
295 /* update the buttons according the type of device */
296 void DiscOpenPanel::updateButtons()
298 if ( ui.dvdRadioButton->isChecked() )
302 setDrive( psz_dvddiscpath );
305 ui.titleLabel->setText( qtr("Title") );
306 ui.chapterLabel->show();
307 ui.chapterSpin->show();
308 ui.diskOptionBox_2->show();
310 else if ( ui.vcdRadioButton->isChecked() )
314 setDrive( psz_vcddiscpath );
317 ui.titleLabel->setText( qtr("Entry") );
318 ui.chapterLabel->hide();
319 ui.chapterSpin->hide();
320 ui.diskOptionBox_2->show();
326 setDrive( psz_cddadiscpath );
329 ui.titleLabel->setText( qtr("Track") );
330 ui.chapterLabel->hide();
331 ui.chapterSpin->hide();
332 ui.diskOptionBox_2->hide();
338 /* Update the current MRL */
339 void DiscOpenPanel::updateMRL()
343 /* CDDAX and VCDX not implemented. TODO ? */
345 if( ui.dvdRadioButton->isChecked() ) {
346 if( !ui.dvdsimple->isChecked() )
349 mrl = "dvdsimple://";
350 mrl += ui.deviceCombo->currentText();
351 emit methodChanged( "dvdnav-caching" );
353 if ( ui.titleSpin->value() > 0 ) {
354 mrl += QString("@%1").arg( ui.titleSpin->value() );
355 if ( ui.chapterSpin->value() > 0 ) {
356 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
361 } else if ( ui.vcdRadioButton->isChecked() ) {
362 mrl = "vcd://" + ui.deviceCombo->currentText();
363 emit methodChanged( "vcd-caching" );
365 if( ui.titleSpin->value() > 0 ) {
366 mrl += QString("@E%1").arg( ui.titleSpin->value() );
371 mrl = "cdda://" + ui.deviceCombo->currentText();
372 if( ui.titleSpin->value() > 0 ) {
373 QString("@%1").arg( ui.titleSpin->value() );
377 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
379 if ( ui.audioSpin->value() >= 0 ) {
380 mrl += " :audio-track=" +
381 QString("%1").arg( ui.audioSpin->value() );
383 if ( ui.subtitlesSpin->value() >= 0 ) {
384 mrl += " :sub-track=" +
385 QString("%1").arg( ui.subtitlesSpin->value() );
388 emit mrlUpdated( mrl );
391 void DiscOpenPanel::browseDevice()
393 QString dir = QFileDialog::getExistingDirectory( 0,
394 qtr("Open a device or a VIDEO_TS directory") );
395 if (!dir.isEmpty()) {
396 ui.deviceCombo->setEditText( dir );
401 void DiscOpenPanel::accept()
404 /**************************************************************************
405 * Open Network streams and URL pages *
406 **************************************************************************/
407 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
408 OpenPanel( _parent, _p_intf )
413 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
414 this, updateProtocol( int ) );
415 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
416 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
417 CONNECT( ui.timeShift, clicked(), this, updateMRL());
418 CONNECT( ui.ipv6, clicked(), this, updateMRL());
420 ui.protocolCombo->addItem("HTTP", QVariant("http"));
421 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
422 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
423 ui.protocolCombo->addItem("MMS", QVariant("mms"));
424 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
425 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
426 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
429 NetOpenPanel::~NetOpenPanel()
432 void NetOpenPanel::clear()
435 /* update the widgets according the type of protocol */
436 void NetOpenPanel::updateProtocol( int idx ) {
437 QString addr = ui.addressText->text();
438 QString proto = ui.protocolCombo->itemData( idx ).toString();
440 ui.timeShift->setEnabled( idx >= 5 );
441 ui.ipv6->setEnabled( idx == 5 );
442 ui.addressText->setEnabled( idx != 5 );
443 ui.portSpin->setEnabled( idx >= 5 );
445 /* If we already have a protocol in the address, replace it */
446 if( addr.contains( "://")) {
447 msg_Err( p_intf, "replace");
448 addr.replace( QRegExp("^.*://"), proto + "://");
449 ui.addressText->setText( addr );
454 void NetOpenPanel::updateMRL() {
456 QString addr = ui.addressText->text();
457 int proto = ui.protocolCombo->currentIndex();
459 if( addr.contains( "://") && proto != 5 ) {
464 mrl = "http://" + addr;
465 emit methodChanged("http-caching");
468 mrl = "https://" + addr;
469 emit methodChanged("http-caching");
472 mrl = "mms://" + addr;
473 emit methodChanged("mms-caching");
476 mrl = "ftp://" + addr;
477 emit methodChanged("ftp-caching");
480 mrl = "rtsp://" + addr;
481 emit methodChanged("rtsp-caching");
485 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
488 mrl += QString(":%1").arg( ui.portSpin->value() );
489 emit methodChanged("udp-caching");
491 case 6: /* UDP multicast */
494 if ( addr.contains(':') && !addr.contains('[') ) {
495 mrl += "[" + addr + "]";
497 mrl += QString(":%1").arg( ui.portSpin->value() );
498 emit methodChanged("udp-caching");
501 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
502 mrl += " :access-filter=timeshift";
504 emit mrlUpdated( mrl );
507 /**************************************************************************
508 * Open Capture device ( DVB, PVR, V4L, and similar ) *
509 **************************************************************************/
510 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
511 OpenPanel( _parent, _p_intf )
515 BUTTONACT( ui.advancedButton, advancedDialog() );
517 /* Create two stacked layouts in the main comboBoxes */
518 QStackedLayout *stackedDevLayout = new QStackedLayout;
519 ui.cardBox->setLayout( stackedDevLayout );
521 QStackedLayout *stackedPropLayout = new QStackedLayout;
522 ui.optionsBox->setLayout( stackedPropLayout );
524 /* Creation and connections of the WIdgets in the stacked layout */
525 #define addModuleAndLayouts( number, name, label ) \
526 QWidget * name ## DevPage = new QWidget( this ); \
527 QWidget * name ## PropPage = new QWidget( this ); \
528 stackedDevLayout->addWidget( name ## DevPage ); \
529 stackedPropLayout->addWidget( name ## PropPage ); \
530 QGridLayout * name ## DevLayout = new QGridLayout; \
531 QGridLayout * name ## PropLayout = new QGridLayout; \
532 name ## DevPage->setLayout( name ## DevLayout ); \
533 name ## PropPage->setLayout( name ## PropLayout ); \
534 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
536 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
542 if( module_Exists( p_intf, "v4l" ) ){
543 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
546 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
547 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
549 v4lVideoDevice = new QLineEdit;
550 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
552 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
553 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
555 v4lAudioDevice = new QLineEdit;
556 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
558 /* V4l Props panel */
559 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
560 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
562 v4lNormBox = new QComboBox;
563 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
564 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
566 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
567 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
569 v4lFreq = new QSpinBox;
570 v4lFreq->setAlignment( Qt::AlignRight );
571 v4lFreq->setSuffix(" kHz");
572 setSpinBoxFreq( v4lFreq );
573 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
574 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
578 CuMRL( v4lVideoDevice, textChanged( QString ) );
579 CuMRL( v4lAudioDevice, textChanged( QString ) );
580 CuMRL( v4lFreq, valueChanged ( int ) );
581 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
587 if( module_Exists( p_intf, "v4l2" ) ){
588 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
591 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
592 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
594 v4l2VideoDevice = new QLineEdit;
595 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
597 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
598 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
600 v4l2AudioDevice = new QLineEdit;
601 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
603 /* v4l2 Props panel */
604 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
605 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
607 v4l2StdBox = new QComboBox;
608 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
609 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
610 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
614 CuMRL( v4l2VideoDevice, textChanged( QString ) );
615 CuMRL( v4l2AudioDevice, textChanged( QString ) );
616 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
622 if( module_Exists( p_intf, "jack" ) ){
623 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
625 /* Jack Main panel */
627 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
628 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
630 jackChannels = new QSpinBox;
631 setSpinBoxFreq( jackChannels );
632 jackChannels->setMaximum(255);
633 jackChannels->setValue(2);
634 jackChannels->setAlignment( Qt::AlignRight );
635 jackDevLayout->addWidget( jackChannels, 1, 1 );
637 /* Jack Props panel */
640 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
641 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
643 jackPortsSelected = new QLineEdit( qtr( ".*") );
644 jackPortsSelected->setAlignment( Qt::AlignRight );
645 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
648 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
649 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
650 jackCaching = new QSpinBox;
651 setSpinBoxFreq( jackCaching );
652 jackCaching->setSuffix( " ms" );
653 jackCaching->setValue(1000);
654 jackCaching->setAlignment( Qt::AlignRight );
655 jackPropLayout->addWidget( jackCaching, 1 , 1 );
658 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
659 jackPropLayout->addWidget( jackPace, 2, 1 );
662 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
663 jackPropLayout->addWidget( jackConnect, 3, 1 );
666 CuMRL( jackChannels, valueChanged( int ) );
667 CuMRL( jackCaching, valueChanged( int ) );
668 CuMRL( jackPace, stateChanged( int ) );
669 CuMRL( jackConnect, stateChanged( int ) );
670 CuMRL( jackPortsSelected, textChanged( QString ) );
676 if( module_Exists( p_intf, "pvr" ) ){
677 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
680 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
681 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
683 pvrDevice = new QLineEdit;
684 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
686 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
687 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
689 pvrRadioDevice = new QLineEdit;
690 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
692 /* PVR props panel */
693 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
694 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
696 pvrNormBox = new QComboBox;
697 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
698 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
700 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
701 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
703 pvrFreq = new QSpinBox;
704 pvrFreq->setAlignment( Qt::AlignRight );
705 pvrFreq->setSuffix(" kHz");
706 setSpinBoxFreq( pvrFreq );
707 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
709 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
710 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
712 pvrBitr = new QSpinBox;
713 pvrBitr->setAlignment( Qt::AlignRight );
714 pvrBitr->setSuffix(" kHz");
715 setSpinBoxFreq( pvrBitr );
716 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
717 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
721 CuMRL( pvrDevice, textChanged( QString ) );
722 CuMRL( pvrRadioDevice, textChanged( QString ) );
724 CuMRL( pvrFreq, valueChanged ( int ) );
725 CuMRL( pvrBitr, valueChanged ( int ) );
726 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
732 if( module_Exists( p_intf, "dvb" ) ){
733 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
736 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
737 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
739 dvbCard = new QSpinBox;
740 dvbCard->setAlignment( Qt::AlignRight );
741 dvbCard->setPrefix( "/dev/dvb/adapter" );
743 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
744 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
746 dvbs = new QRadioButton( "DVB-S" );
747 dvbs->setChecked( true );
748 dvbc = new QRadioButton( "DVB-C" );
749 dvbt = new QRadioButton( "DVB-T" );
751 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
752 dvbDevLayout->addWidget( dvbs, 1, 1 );
753 dvbDevLayout->addWidget( dvbc, 1, 2 );
754 dvbDevLayout->addWidget( dvbt, 1, 3 );
756 /* DVB Props panel */
757 QLabel *dvbFreqLabel =
758 new QLabel( qtr( "Transponder/multiplex frequency" ) );
759 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
761 dvbFreq = new QSpinBox;
762 dvbFreq->setAlignment( Qt::AlignRight );
763 dvbFreq->setSuffix(" kHz");
764 setSpinBoxFreq( dvbFreq );
765 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
767 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
768 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
770 dvbSrate = new QSpinBox;
771 dvbSrate->setAlignment( Qt::AlignRight );
772 dvbSrate->setSuffix(" kHz");
773 setSpinBoxFreq( dvbSrate );
774 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
775 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
779 CuMRL( dvbCard, valueChanged ( int ) );
780 CuMRL( dvbFreq, valueChanged ( int ) );
781 CuMRL( dvbSrate, valueChanged ( int ) );
783 BUTTONACT( dvbs, updateButtons() );
784 BUTTONACT( dvbt, updateButtons() );
785 BUTTONACT( dvbc, updateButtons() );
790 /*********************
791 * DirectShow Stuffs *
792 *********************/
793 if( module_Exists( p_intf, "dshow" ) ){
794 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
798 module_config_t *p_config =
799 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
800 vdevDshowW = new StringListConfigControl(
801 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
804 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
805 adevDshowW = new StringListConfigControl(
806 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
809 /* dshow Properties */
810 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
811 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
813 dshowVSizeLine = new QLineEdit;
814 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
815 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
819 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
820 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
821 CuMRL( dshowVSizeLine, textChanged( QString ) );
827 if( module_Exists( p_intf, "bda" ) ){
828 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
831 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
833 bdas = new QRadioButton( "DVB-S" );
834 bdas->setChecked( true );
835 bdac = new QRadioButton( "DVB-C" );
836 bdat = new QRadioButton( "DVB-T" );
838 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
839 bdaDevLayout->addWidget( bdas, 0, 1 );
840 bdaDevLayout->addWidget( bdac, 0, 2 );
841 bdaDevLayout->addWidget( bdat, 0, 3 );
844 QLabel *bdaFreqLabel =
845 new QLabel( qtr( "Transponder/multiplex frequency" ) );
846 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
848 bdaFreq = new QSpinBox;
849 bdaFreq->setAlignment( Qt::AlignRight );
850 bdaFreq->setSuffix(" kHz");
851 bdaFreq->setSingleStep( 1000 );
852 setSpinBoxFreq( bdaFreq )
853 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
855 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
856 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
858 bdaSrate = new QSpinBox;
859 bdaSrate->setAlignment( Qt::AlignRight );
860 bdaSrate->setSuffix(" kHz");
861 setSpinBoxFreq( bdaSrate );
862 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
864 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
865 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
867 bdaBandBox = new QComboBox;
868 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
869 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
871 bdaBandLabel->hide();
873 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
877 CuMRL( bdaFreq, valueChanged ( int ) );
878 CuMRL( bdaSrate, valueChanged ( int ) );
879 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
880 BUTTONACT( bdas, updateButtons() );
881 BUTTONACT( bdat, updateButtons() );
882 BUTTONACT( bdac, updateButtons() );
883 BUTTONACT( bdas, updateMRL() );
884 BUTTONACT( bdat, updateMRL() );
885 BUTTONACT( bdac, updateMRL() );
893 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
894 QLabel *screenLabel = new QLabel( "This option will open your own "
895 "desktop in order to save or stream it.");
896 screenLabel->setWordWrap( true );
897 screenDevLayout->addWidget( screenLabel, 0, 0 );
899 /* General connects */
900 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
901 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
902 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
903 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
904 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
905 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
910 CaptureOpenPanel::~CaptureOpenPanel()
912 if( adv ) delete adv;
915 void CaptureOpenPanel::clear()
920 void CaptureOpenPanel::updateMRL()
923 int i_devicetype = ui.deviceCombo->itemData(
924 ui.deviceCombo->currentIndex() ).toInt();
925 switch( i_devicetype )
930 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
931 mrl += " :v4l-adev=" + v4lAudioDevice->text();
932 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
933 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
937 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
938 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
939 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
943 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
944 mrl += ":ports=" + jackPortsSelected->text();
945 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
946 if ( jackPace->isChecked() )
948 mrl += " --jack-input-use-vlc-pace";
950 if ( jackConnect->isChecked() )
952 mrl += " --jack-input-auto-connect";
957 mrl += " :pvr-device=" + pvrDevice->text();
958 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
959 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
960 if( pvrFreq->value() )
961 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
962 if( pvrBitr->value() )
963 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
967 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
968 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
969 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
973 if( bdas->isChecked() ) mrl = "dvb-s://";
974 else if( bdat->isChecked() ) mrl = "dvb-t://";
975 else if( bdac->isChecked() ) mrl = "dvb-c://";
977 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
978 if( bdas->isChecked() || bdac->isChecked() )
979 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
981 mrl += " :dvb-bandwidth=" +
982 QString("%1").arg( bdaBandBox->itemData(
983 bdaBandBox->currentIndex() ).toInt() );
987 mrl += " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
988 mrl += " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
989 if( dshowVSizeLine->isModified() )
990 mrl += " :dshow-size=" + dshowVSizeLine->text();
999 if( !advMRL.isEmpty() ) mrl += advMRL;
1001 emit mrlUpdated( mrl );
1005 * Update the Buttons (show/hide) for the GUI as all device type don't
1006 * use the same ui. elements.
1008 void CaptureOpenPanel::updateButtons()
1010 /* Be sure to display the ui Elements in case they were hidden by
1011 * some Device Type (like Screen://) */
1012 ui.optionsBox->show();
1013 ui.advancedButton->show();
1014 /* Get the current Device Number */
1015 int i_devicetype = ui.deviceCombo->itemData(
1016 ui.deviceCombo->currentIndex() ).toInt();
1017 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
1018 switch( i_devicetype )
1022 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1023 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1027 if( bdas->isChecked() || bdac->isChecked() )
1030 bdaSrateLabel->show();
1032 bdaBandLabel->hide();
1037 bdaSrateLabel->hide();
1039 bdaBandLabel->show();
1044 ui.optionsBox->hide();
1045 ui.advancedButton->hide();
1056 void CaptureOpenPanel::advancedDialog()
1058 int i_devicetype = ui.deviceCombo->itemData(
1059 ui.deviceCombo->currentIndex() ).toInt();
1060 module_t *p_module =
1061 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1062 if( NULL == p_module ) return;
1064 unsigned int i_confsize;
1065 QList<ConfigControl *> controls;
1067 module_config_t *p_config;
1068 p_config = module_GetConfig( p_module, &i_confsize );
1070 adv = new QDialog( this );
1071 adv->setWindowTitle( qtr( "Advanced options..." ) );
1073 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1075 QFrame *advFrame = new QFrame;
1076 mainLayout->addWidget( advFrame );
1078 QGridLayout *gLayout = new QGridLayout( advFrame );
1080 for( int n = 0; n < i_confsize; n++ )
1082 module_config_t *p_item = p_config + n;
1083 ConfigControl *config = ConfigControl::createControl(
1084 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1085 controls.append( config );
1088 /* QGroupBox *optionGroup = new QGroupBox( qtr( "Advanced options..." ) );
1089 QHBoxLayout *grLayout = new QHBoxLayout( optionGroup );
1091 QLabel *optionLabel = new QLabel( qtr( "Options" ) + ":" );
1092 grLayout->addWidget( optionLabel );
1094 QLineEdit *optionLine = new QLineEdit;
1095 grLayout->addWidget( optionLine );
1097 gLayout->addWidget( optionGroup, i_confsize, 0, 1, -1 );*/
1099 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1100 QPushButton *closeButton = new QPushButton( qtr( "Ok" ) );
1101 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1103 CONNECT( closeButton, clicked(), adv, accept() );
1104 CONNECT( cancelButton, clicked(), adv, reject() );
1106 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1107 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1109 gLayout->addWidget( advButtonBox, i_confsize + 1, 0, 1, -1 );
1113 QString tempMRL = "";
1114 for( int i = 0; i < controls.size(); i++ )
1116 ConfigControl *control = controls[i];
1119 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1123 tempMRL += (i ? " :" : ":");
1125 if( control->getType() == CONFIG_ITEM_BOOL )
1126 if( !( qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1129 tempMRL += control->getName();
1131 switch( control->getType() )
1133 case CONFIG_ITEM_STRING:
1134 case CONFIG_ITEM_FILE:
1135 case CONFIG_ITEM_DIRECTORY:
1136 case CONFIG_ITEM_MODULE:
1137 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1139 case CONFIG_ITEM_INTEGER:
1140 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1142 case CONFIG_ITEM_FLOAT:
1143 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1148 msg_Dbg( p_intf, "%s", qtu( advMRL ) );