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 /* retrieve last known path used in file browsing */
69 char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
70 if( EMPTY_STR( psz_filepath ) )
72 psz_filepath = p_intf->p_libvlc->psz_homedir;
75 // Make this QFileDialog a child of tempWidget from the ui.
76 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
77 qfu( psz_filepath ), fileTypes );
80 dialogBox->setFileMode( QFileDialog::ExistingFiles );
81 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
83 /* We don't want to see a grip in the middle of the window, do we? */
84 dialogBox->setSizeGripEnabled( false );
87 dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
89 // But hide the two OK/Cancel buttons. Enable them for debug.
90 QDialogButtonBox *fileDialogAcceptBox =
91 dialogBox->findChildren<QDialogButtonBox*>()[0];
92 fileDialogAcceptBox->hide();
94 /* Ugly hacks to get the good Widget */
95 //This lineEdit is the normal line in the fileDialog.
97 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
99 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
101 /* Make a list of QLabel inside the QFileDialog to access the good ones */
102 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
104 /* Hide the FileNames one. Enable it for debug */
105 listLabel[1]->setText( qtr( "File names:" ) );
106 /* Change the text that was uncool in the usual box */
107 listLabel[2]->setText( qtr( "Filter:" ) );
109 dialogBox->layout()->setMargin( 0 );
110 dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
112 /** END of QFileDialog tweaking **/
114 // Add the DialogBox to the layout
115 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
117 //TODO later: fill the fileCompleteList with previous items played.
118 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
119 fileCompleter->setModel( new QDirModel( fileCompleter ) );
120 lineFileEdit->setCompleter( fileCompleter );
122 // Hide the subtitles control by default.
125 /* Build the subs size combo box */
126 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
127 ui.sizeSubComboBox );
129 /* Build the subs align combo box */
130 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
133 BUTTONACT( ui.subBrowseButton, browseFileSub() );
134 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
136 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
137 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
138 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
139 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
142 FileOpenPanel::~FileOpenPanel(){}
144 /* Show a fileBrowser to select a subtitle */
145 void FileOpenPanel::browseFileSub()
147 // TODO Handle selection of more than one subtitles file
148 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
150 dialogBox->directory().absolutePath() );
151 if( files.isEmpty() ) return;
152 ui.subInput->setText( files.join(" ") );
156 /* Update the current MRL */
157 void FileOpenPanel::updateMRL()
160 foreach( QString file, dialogBox->selectedFiles() ) {
161 mrl += "\"" + file + "\" ";
164 if( ui.subCheckBox->isChecked() ) {
165 mrl.append( " :sub-file=" + ui.subInput->text() );
166 int align = ui.alignSubComboBox->itemData(
167 ui.alignSubComboBox->currentIndex() ).toInt();
168 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
169 int size = ui.sizeSubComboBox->itemData(
170 ui.sizeSubComboBox->currentIndex() ).toInt();
171 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
174 emit mrlUpdated( mrl );
175 emit methodChanged( "file-caching" );
178 /* Function called by Open Dialog when clicke on Play/Enqueue */
179 void FileOpenPanel::accept()
181 //TODO set the completer
182 const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
183 if( ( NULL == psz_filepath )
184 || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
186 /* set dialog box current directory as last known path */
187 config_PutPsz( p_intf, "qt-filedialog-path",
188 qtu( dialogBox->directory().absolutePath() ) );
193 void FileOpenBox::accept()
195 OpenDialog::getInstance( NULL, NULL )->play();
198 /* Function called by Open Dialog when clicked on cancel */
199 void FileOpenPanel::clear()
201 lineFileEdit->clear();
202 ui.subInput->clear();
205 void FileOpenPanel::toggleSubtitleFrame()
207 TOGGLEV( ui.subFrame );
213 /**************************************************************************
214 * Open Discs ( DVD, CD, VCD and similar devices ) *
215 **************************************************************************/
216 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
217 OpenPanel( _parent, _p_intf )
221 /* Get the default configuration path for the devices */
222 psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
223 psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
224 psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
226 /* State to avoid overwritting the users changes with the configuration */
231 #if WIN32 /* Disc drives probing for Windows */
234 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
236 char *drive = szDrives;
237 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
240 if( GetDriveTypeA(drive) == DRIVE_CDROM )
241 ui.deviceCombo->addItem( drive );
243 /* go to next drive */
246 SetErrorMode(oldMode);
248 #else /* Use a Completer under Linux */
249 QCompleter *discCompleter = new QCompleter( this );
250 discCompleter->setModel( new QDirModel( discCompleter ) );
251 ui.deviceCombo->setCompleter( discCompleter );
255 BUTTONACT( ui.dvdRadioButton, updateButtons() );
256 BUTTONACT( ui.vcdRadioButton, updateButtons() );
257 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
258 BUTTONACT( ui.dvdsimple, updateButtons() );
259 BUTTONACT( ui.browseDiscButton, browseDevice() );
261 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
262 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
263 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
264 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
265 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
267 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
271 DiscOpenPanel::~DiscOpenPanel()
273 delete psz_dvddiscpath;
274 delete psz_vcddiscpath;
275 delete psz_cddadiscpath;
278 void DiscOpenPanel::clear()
280 ui.titleSpin->setValue( 0 );
281 ui.chapterSpin->setValue( 0 );
288 #define setDrive( psz_name ) {\
289 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
290 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
292 #define setDrive( psz_name ) {\
293 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
296 /* update the buttons according the type of device */
297 void DiscOpenPanel::updateButtons()
299 if ( ui.dvdRadioButton->isChecked() )
303 setDrive( psz_dvddiscpath );
306 ui.titleLabel->setText( qtr("Title") );
307 ui.chapterLabel->show();
308 ui.chapterSpin->show();
309 ui.diskOptionBox_2->show();
311 else if ( ui.vcdRadioButton->isChecked() )
315 setDrive( psz_vcddiscpath );
318 ui.titleLabel->setText( qtr("Entry") );
319 ui.chapterLabel->hide();
320 ui.chapterSpin->hide();
321 ui.diskOptionBox_2->show();
327 setDrive( psz_cddadiscpath );
330 ui.titleLabel->setText( qtr("Track") );
331 ui.chapterLabel->hide();
332 ui.chapterSpin->hide();
333 ui.diskOptionBox_2->hide();
339 /* Update the current MRL */
340 void DiscOpenPanel::updateMRL()
344 /* CDDAX and VCDX not implemented. TODO ? */
346 if( ui.dvdRadioButton->isChecked() ) {
347 if( !ui.dvdsimple->isChecked() )
350 mrl = "dvdsimple://";
351 mrl += ui.deviceCombo->currentText();
352 emit methodChanged( "dvdnav-caching" );
354 if ( ui.titleSpin->value() > 0 ) {
355 mrl += QString("@%1").arg( ui.titleSpin->value() );
356 if ( ui.chapterSpin->value() > 0 ) {
357 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
362 } else if ( ui.vcdRadioButton->isChecked() ) {
363 mrl = "vcd://" + ui.deviceCombo->currentText();
364 emit methodChanged( "vcd-caching" );
366 if( ui.titleSpin->value() > 0 ) {
367 mrl += QString("@E%1").arg( ui.titleSpin->value() );
372 mrl = "cdda://" + ui.deviceCombo->currentText();
373 if( ui.titleSpin->value() > 0 ) {
374 QString("@%1").arg( ui.titleSpin->value() );
378 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
380 if ( ui.audioSpin->value() >= 0 ) {
381 mrl += " :audio-track=" +
382 QString("%1").arg( ui.audioSpin->value() );
384 if ( ui.subtitlesSpin->value() >= 0 ) {
385 mrl += " :sub-track=" +
386 QString("%1").arg( ui.subtitlesSpin->value() );
389 emit mrlUpdated( mrl );
392 void DiscOpenPanel::browseDevice()
394 QString dir = QFileDialog::getExistingDirectory( 0,
395 qtr("Open a device or a VIDEO_TS directory") );
396 if (!dir.isEmpty()) {
397 ui.deviceCombo->setEditText( dir );
402 void DiscOpenPanel::accept()
405 /**************************************************************************
406 * Open Network streams and URL pages *
407 **************************************************************************/
408 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
409 OpenPanel( _parent, _p_intf )
414 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
415 this, updateProtocol( int ) );
416 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
417 CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
418 CONNECT( ui.timeShift, clicked(), this, updateMRL());
419 CONNECT( ui.ipv6, clicked(), this, updateMRL());
421 ui.protocolCombo->addItem("HTTP", QVariant("http"));
422 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
423 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
424 ui.protocolCombo->addItem("MMS", QVariant("mms"));
425 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
426 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
427 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
430 NetOpenPanel::~NetOpenPanel()
433 void NetOpenPanel::clear()
436 /* update the widgets according the type of protocol */
437 void NetOpenPanel::updateProtocol( int idx ) {
438 QString addr = ui.addressText->text();
439 QString proto = ui.protocolCombo->itemData( idx ).toString();
441 ui.timeShift->setEnabled( idx >= 5 );
442 ui.ipv6->setEnabled( idx == 5 );
443 ui.addressText->setEnabled( idx != 5 );
444 ui.portSpin->setEnabled( idx >= 5 );
446 /* If we already have a protocol in the address, replace it */
447 if( addr.contains( "://")) {
448 msg_Err( p_intf, "replace");
449 addr.replace( QRegExp("^.*://"), proto + "://");
450 ui.addressText->setText( addr );
455 void NetOpenPanel::updateMRL() {
457 QString addr = ui.addressText->text();
458 int proto = ui.protocolCombo->currentIndex();
460 if( addr.contains( "://") && proto != 5 ) {
465 mrl = "http://" + addr;
466 emit methodChanged("http-caching");
469 mrl = "https://" + addr;
470 emit methodChanged("http-caching");
473 mrl = "mms://" + addr;
474 emit methodChanged("mms-caching");
477 mrl = "ftp://" + addr;
478 emit methodChanged("ftp-caching");
481 mrl = "rtsp://" + addr;
482 emit methodChanged("rtsp-caching");
486 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
489 mrl += QString(":%1").arg( ui.portSpin->value() );
490 emit methodChanged("udp-caching");
492 case 6: /* UDP multicast */
495 if ( addr.contains(':') && !addr.contains('[') ) {
496 mrl += "[" + addr + "]";
498 mrl += QString(":%1").arg( ui.portSpin->value() );
499 emit methodChanged("udp-caching");
503 // Encode the boring stuffs
504 mrl = QUrl( mrl ).toEncoded();
505 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
506 mrl += " :access-filter=timeshift";
508 emit mrlUpdated( mrl );
511 /**************************************************************************
512 * Open Capture device ( DVB, PVR, V4L, and similar ) *
513 **************************************************************************/
514 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
515 OpenPanel( _parent, _p_intf )
519 BUTTONACT( ui.advancedButton, advancedDialog() );
521 /* Create two stacked layouts in the main comboBoxes */
522 QStackedLayout *stackedDevLayout = new QStackedLayout;
523 ui.cardBox->setLayout( stackedDevLayout );
525 QStackedLayout *stackedPropLayout = new QStackedLayout;
526 ui.optionsBox->setLayout( stackedPropLayout );
528 /* Creation and connections of the WIdgets in the stacked layout */
529 #define addModuleAndLayouts( number, name, label ) \
530 QWidget * name ## DevPage = new QWidget( this ); \
531 QWidget * name ## PropPage = new QWidget( this ); \
532 stackedDevLayout->addWidget( name ## DevPage ); \
533 stackedPropLayout->addWidget( name ## PropPage ); \
534 QGridLayout * name ## DevLayout = new QGridLayout; \
535 QGridLayout * name ## PropLayout = new QGridLayout; \
536 name ## DevPage->setLayout( name ## DevLayout ); \
537 name ## PropPage->setLayout( name ## PropLayout ); \
538 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
540 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
546 if( module_Exists( p_intf, "v4l" ) ){
547 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
550 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
551 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
553 v4lVideoDevice = new QLineEdit;
554 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
556 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
557 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
559 v4lAudioDevice = new QLineEdit;
560 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
562 /* V4l Props panel */
563 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
564 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
566 v4lNormBox = new QComboBox;
567 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
568 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
570 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
571 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
573 v4lFreq = new QSpinBox;
574 v4lFreq->setAlignment( Qt::AlignRight );
575 v4lFreq->setSuffix(" kHz");
576 setSpinBoxFreq( v4lFreq );
577 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
578 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
582 CuMRL( v4lVideoDevice, textChanged( QString ) );
583 CuMRL( v4lAudioDevice, textChanged( QString ) );
584 CuMRL( v4lFreq, valueChanged ( int ) );
585 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
591 if( module_Exists( p_intf, "v4l2" ) ){
592 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
595 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
596 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
598 v4l2VideoDevice = new QLineEdit;
599 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
601 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
602 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
604 v4l2AudioDevice = new QLineEdit;
605 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
607 /* v4l2 Props panel */
608 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
609 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
611 v4l2StdBox = new QComboBox;
612 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
613 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
614 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
618 CuMRL( v4l2VideoDevice, textChanged( QString ) );
619 CuMRL( v4l2AudioDevice, textChanged( QString ) );
620 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
626 if( module_Exists( p_intf, "jack" ) ){
627 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
629 /* Jack Main panel */
631 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
632 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
634 jackChannels = new QSpinBox;
635 setSpinBoxFreq( jackChannels );
636 jackChannels->setMaximum(255);
637 jackChannels->setValue(2);
638 jackChannels->setAlignment( Qt::AlignRight );
639 jackDevLayout->addWidget( jackChannels, 1, 1 );
641 /* Jack Props panel */
644 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
645 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
647 jackPortsSelected = new QLineEdit( qtr( ".*") );
648 jackPortsSelected->setAlignment( Qt::AlignRight );
649 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
652 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
653 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
654 jackCaching = new QSpinBox;
655 setSpinBoxFreq( jackCaching );
656 jackCaching->setSuffix( " ms" );
657 jackCaching->setValue(1000);
658 jackCaching->setAlignment( Qt::AlignRight );
659 jackPropLayout->addWidget( jackCaching, 1 , 1 );
662 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
663 jackPropLayout->addWidget( jackPace, 2, 1 );
666 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
667 jackPropLayout->addWidget( jackConnect, 3, 1 );
670 CuMRL( jackChannels, valueChanged( int ) );
671 CuMRL( jackCaching, valueChanged( int ) );
672 CuMRL( jackPace, stateChanged( int ) );
673 CuMRL( jackConnect, stateChanged( int ) );
674 CuMRL( jackPortsSelected, textChanged( QString ) );
680 if( module_Exists( p_intf, "pvr" ) ){
681 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
684 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
685 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
687 pvrDevice = new QLineEdit;
688 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
690 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
691 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
693 pvrRadioDevice = new QLineEdit;
694 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
696 /* PVR props panel */
697 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
698 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
700 pvrNormBox = new QComboBox;
701 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
702 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
704 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
705 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
707 pvrFreq = new QSpinBox;
708 pvrFreq->setAlignment( Qt::AlignRight );
709 pvrFreq->setSuffix(" kHz");
710 setSpinBoxFreq( pvrFreq );
711 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
713 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
714 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
716 pvrBitr = new QSpinBox;
717 pvrBitr->setAlignment( Qt::AlignRight );
718 pvrBitr->setSuffix(" kHz");
719 setSpinBoxFreq( pvrBitr );
720 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
721 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
725 CuMRL( pvrDevice, textChanged( QString ) );
726 CuMRL( pvrRadioDevice, textChanged( QString ) );
728 CuMRL( pvrFreq, valueChanged ( int ) );
729 CuMRL( pvrBitr, valueChanged ( int ) );
730 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
736 if( module_Exists( p_intf, "dvb" ) ){
737 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
740 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
741 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
743 dvbCard = new QSpinBox;
744 dvbCard->setAlignment( Qt::AlignRight );
745 dvbCard->setPrefix( "/dev/dvb/adapter" );
747 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
748 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
750 dvbs = new QRadioButton( "DVB-S" );
751 dvbs->setChecked( true );
752 dvbc = new QRadioButton( "DVB-C" );
753 dvbt = new QRadioButton( "DVB-T" );
755 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
756 dvbDevLayout->addWidget( dvbs, 1, 1 );
757 dvbDevLayout->addWidget( dvbc, 1, 2 );
758 dvbDevLayout->addWidget( dvbt, 1, 3 );
760 /* DVB Props panel */
761 QLabel *dvbFreqLabel =
762 new QLabel( qtr( "Transponder/multiplex frequency" ) );
763 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
765 dvbFreq = new QSpinBox;
766 dvbFreq->setAlignment( Qt::AlignRight );
767 dvbFreq->setSuffix(" kHz");
768 setSpinBoxFreq( dvbFreq );
769 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
771 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
772 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
774 dvbSrate = new QSpinBox;
775 dvbSrate->setAlignment( Qt::AlignRight );
776 dvbSrate->setSuffix(" kHz");
777 setSpinBoxFreq( dvbSrate );
778 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
779 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
783 CuMRL( dvbCard, valueChanged ( int ) );
784 CuMRL( dvbFreq, valueChanged ( int ) );
785 CuMRL( dvbSrate, valueChanged ( int ) );
787 BUTTONACT( dvbs, updateButtons() );
788 BUTTONACT( dvbt, updateButtons() );
789 BUTTONACT( dvbc, updateButtons() );
794 /*********************
795 * DirectShow Stuffs *
796 *********************/
797 if( module_Exists( p_intf, "dshow" ) ){
798 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
802 module_config_t *p_config =
803 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
804 vdevDshowW = new StringListConfigControl(
805 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
808 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
809 adevDshowW = new StringListConfigControl(
810 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
813 /* dshow Properties */
814 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
815 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
817 dshowVSizeLine = new QLineEdit;
818 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
819 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
823 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
824 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
825 CuMRL( dshowVSizeLine, textChanged( QString ) );
831 if( module_Exists( p_intf, "bda" ) ){
832 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
835 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
837 bdas = new QRadioButton( "DVB-S" );
838 bdas->setChecked( true );
839 bdac = new QRadioButton( "DVB-C" );
840 bdat = new QRadioButton( "DVB-T" );
842 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
843 bdaDevLayout->addWidget( bdas, 0, 1 );
844 bdaDevLayout->addWidget( bdac, 0, 2 );
845 bdaDevLayout->addWidget( bdat, 0, 3 );
848 QLabel *bdaFreqLabel =
849 new QLabel( qtr( "Transponder/multiplex frequency" ) );
850 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
852 bdaFreq = new QSpinBox;
853 bdaFreq->setAlignment( Qt::AlignRight );
854 bdaFreq->setSuffix(" kHz");
855 bdaFreq->setSingleStep( 1000 );
856 setSpinBoxFreq( bdaFreq )
857 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
859 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
860 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
862 bdaSrate = new QSpinBox;
863 bdaSrate->setAlignment( Qt::AlignRight );
864 bdaSrate->setSuffix(" kHz");
865 setSpinBoxFreq( bdaSrate );
866 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
868 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
869 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
871 bdaBandBox = new QComboBox;
872 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
873 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
875 bdaBandLabel->hide();
877 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
881 CuMRL( bdaFreq, valueChanged ( int ) );
882 CuMRL( bdaSrate, valueChanged ( int ) );
883 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
884 BUTTONACT( bdas, updateButtons() );
885 BUTTONACT( bdat, updateButtons() );
886 BUTTONACT( bdac, updateButtons() );
887 BUTTONACT( bdas, updateMRL() );
888 BUTTONACT( bdat, updateMRL() );
889 BUTTONACT( bdac, updateMRL() );
897 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
898 QLabel *screenLabel = new QLabel( "This option will open your own "
899 "desktop in order to save or stream it.");
900 screenLabel->setWordWrap( true );
901 screenDevLayout->addWidget( screenLabel, 0, 0 );
903 /* General connects */
904 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
905 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
906 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
907 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
908 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
909 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
914 CaptureOpenPanel::~CaptureOpenPanel()
918 void CaptureOpenPanel::clear()
923 void CaptureOpenPanel::updateMRL()
926 int i_devicetype = ui.deviceCombo->itemData(
927 ui.deviceCombo->currentIndex() ).toInt();
928 switch( i_devicetype )
933 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
934 mrl += " :v4l-adev=" + v4lAudioDevice->text();
935 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
936 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
940 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
941 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
942 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
946 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
947 mrl += ":ports=" + jackPortsSelected->text();
948 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
949 if ( jackPace->isChecked() )
951 mrl += " --jack-input-use-vlc-pace";
953 if ( jackConnect->isChecked() )
955 mrl += " --jack-input-auto-connect";
960 mrl += " :pvr-device=" + pvrDevice->text();
961 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
962 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
963 if( pvrFreq->value() )
964 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
965 if( pvrBitr->value() )
966 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
970 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
971 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
972 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
976 if( bdas->isChecked() ) mrl = "dvb-s://";
977 else if( bdat->isChecked() ) mrl = "dvb-t://";
978 else if( bdac->isChecked() ) mrl = "dvb-c://";
980 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
981 if( bdas->isChecked() || bdac->isChecked() )
982 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
984 mrl += " :dvb-bandwidth=" +
985 QString("%1").arg( bdaBandBox->itemData(
986 bdaBandBox->currentIndex() ).toInt() );
990 mrl += " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
991 mrl += " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
992 if( dshowVSizeLine->isModified() )
993 mrl += " :dshow-size=" + dshowVSizeLine->text();
1002 if( !advMRL.isEmpty() ) mrl += advMRL;
1004 emit mrlUpdated( mrl );
1008 * Update the Buttons (show/hide) for the GUI as all device type don't
1009 * use the same ui. elements.
1011 void CaptureOpenPanel::updateButtons()
1013 /* Be sure to display the ui Elements in case they were hidden by
1014 * some Device Type (like Screen://) */
1015 ui.optionsBox->show();
1016 ui.advancedButton->show();
1017 /* Get the current Device Number */
1018 int i_devicetype = ui.deviceCombo->itemData(
1019 ui.deviceCombo->currentIndex() ).toInt();
1020 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
1021 switch( i_devicetype )
1025 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
1026 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
1030 if( bdas->isChecked() || bdac->isChecked() )
1033 bdaSrateLabel->show();
1035 bdaBandLabel->hide();
1040 bdaSrateLabel->hide();
1042 bdaBandLabel->show();
1047 ui.optionsBox->hide();
1048 ui.advancedButton->hide();
1055 void CaptureOpenPanel::advancedDialog()
1057 /* Get selected device type */
1058 int i_devicetype = ui.deviceCombo->itemData(
1059 ui.deviceCombo->currentIndex() ).toInt();
1061 /* Get the corresponding module */
1062 module_t *p_module =
1063 module_Find( VLC_OBJECT(p_intf), psz_devModule[i_devicetype] );
1064 if( NULL == p_module ) return;
1067 QList<ConfigControl *> controls;
1069 /* Get the confsize */
1070 unsigned int i_confsize;
1071 module_config_t *p_config;
1072 p_config = module_GetConfig( p_module, &i_confsize );
1074 /* New Adv Prop dialog */
1075 adv = new QDialog( this );
1076 adv->setWindowTitle( qtr( "Advanced options..." ) );
1078 /* A main Layout with a Frame */
1079 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1081 QFrame *advFrame = new QFrame;
1082 mainLayout->addWidget( advFrame );
1084 /* GridLayout inside the Frame */
1085 QGridLayout *gLayout = new QGridLayout( advFrame );
1087 /* Create the options inside the FrameLayout */
1088 for( int n = 0; n < i_confsize; n++ )
1090 module_config_t *p_item = p_config + n;
1091 ConfigControl *config = ConfigControl::createControl(
1092 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1093 controls.append( config );
1097 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1098 QPushButton *closeButton = new QPushButton( qtr( "Ok" ) );
1099 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1101 CONNECT( closeButton, clicked(), adv, accept() );
1102 CONNECT( cancelButton, clicked(), adv, reject() );
1104 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1105 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1107 gLayout->addWidget( advButtonBox, i_confsize + 1, 0, 1, -1 );
1109 /* Creation of the MRL */
1112 QString tempMRL = "";
1113 for( int i = 0; i < controls.size(); i++ )
1115 ConfigControl *control = controls[i];
1118 msg_Dbg( p_intf, "This shouldn't happen, please report" );
1122 tempMRL += (i ? " :" : ":");
1124 if( control->getType() == CONFIG_ITEM_BOOL )
1125 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1128 tempMRL += control->getName();
1130 switch( control->getType() )
1132 case CONFIG_ITEM_STRING:
1133 case CONFIG_ITEM_FILE:
1134 case CONFIG_ITEM_DIRECTORY:
1135 case CONFIG_ITEM_MODULE:
1136 tempMRL += QString("=\"%1\"").arg( qobject_cast<VStringConfigControl *>(control)->getValue() );
1138 case CONFIG_ITEM_INTEGER:
1139 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1141 case CONFIG_ITEM_FLOAT:
1142 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1148 msg_Dbg( p_intf, "%s", qtu( advMRL ) );