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.hpp"
32 #include "dialogs/open.hpp"
33 #include "dialogs_provider.hpp"
34 #include "util/customwidgets.hpp"
36 #include <QFileDialog>
37 #include <QDialogButtonBox>
39 #include <QStackedLayout>
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];
99 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
102 /* Make a list of QLabel inside the QFileDialog to access the good ones */
103 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
105 /* Hide the FileNames one. Enable it for debug */
106 listLabel[1]->setText( qtr( "File names:" ) );
107 /* Change the text that was uncool in the usual box */
108 listLabel[2]->setText( qtr( "Filter:" ) );
110 dialogBox->layout()->setMargin( 0 );
111 dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
113 /** END of QFileDialog tweaking **/
115 // Add the DialogBox to the layout
116 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
118 //TODO later: fill the fileCompleteList with previous items played.
119 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
120 fileCompleter->setModel( new QDirModel( fileCompleter ) );
121 lineFileEdit->setCompleter( fileCompleter );
123 // Hide the subtitles control by default.
126 /* Build the subs size combo box */
127 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
128 ui.sizeSubComboBox );
130 /* Build the subs align combo box */
131 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
134 BUTTONACT( ui.subBrowseButton, browseFileSub() );
135 BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
137 CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
139 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
140 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
142 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this,
146 FileOpenPanel::~FileOpenPanel()
149 QStringList FileOpenPanel::browse( QString help )
151 return THEDP->showSimpleOpen( help );
155 void FileOpenPanel::browseFileSub()
157 // FIXME Handle selection of more than one subtitles file
158 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
160 dialogBox->directory().absolutePath() );
161 if( files.isEmpty() ) return;
162 ui.subInput->setText( files.join(" ") );
166 void FileOpenPanel::updateMRL()
169 foreach( QString file, dialogBox->selectedFiles() ) {
170 mrl += "\"" + file + "\" ";
173 if( ui.subCheckBox->isChecked() ) {
174 mrl.append( " :sub-file=" + ui.subInput->text() );
175 int align = ui.alignSubComboBox->itemData(
176 ui.alignSubComboBox->currentIndex() ).toInt();
177 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
178 int size = ui.sizeSubComboBox->itemData(
179 ui.sizeSubComboBox->currentIndex() ).toInt();
180 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
183 emit mrlUpdated( mrl );
184 emit methodChanged( "file-caching" );
188 /* Function called by Open Dialog when clicke on Play/Enqueue */
189 void FileOpenPanel::accept()
191 //FIXME set the completer
192 const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
193 if( ( NULL == psz_filepath )
194 || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
196 /* set dialog box current directory as last known path */
197 config_PutPsz( p_intf, "qt-filedialog-path",
198 qtu( dialogBox->directory().absolutePath() ) );
204 void FileOpenBox::accept()
206 OpenDialog::getInstance( NULL, NULL )->play();
209 /* Function called by Open Dialog when clicked on cancel */
210 void FileOpenPanel::clear()
212 lineFileEdit->clear();
213 ui.subInput->clear();
216 void FileOpenPanel::toggleSubtitleFrame()
218 TOGGLEV( ui.subFrame );
224 /**************************************************************************
225 * Open Discs ( DVD, CD, VCD and similar devices ) *
226 **************************************************************************/
227 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
228 OpenPanel( _parent, _p_intf )
232 char *psz_discpath = config_GetPsz( p_intf, "qt-discdialog-path" );
234 #if WIN32 /* Disc drives probing for Windows */
237 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
239 char *drive = szDrives;
240 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
243 if( GetDriveTypeA(drive) == DRIVE_CDROM )
244 ui.deviceCombo->addItem( drive );
246 /* go to next drive */
249 SetErrorMode(oldMode);
252 int index = ui.deviceCombo->findText( qfu( psz_discpath ) );
253 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );
255 #endif /* Disc Probing under Windows */
257 ui.deviceCombo->setEditText( qfu( psz_discpath ) );
262 BUTTONACT( ui.dvdRadioButton, updateButtons() );
263 BUTTONACT( ui.vcdRadioButton, updateButtons() );
264 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
265 BUTTONACT( ui.dvdsimple, updateButtons() );
266 BUTTONACT( ui.browseDiscButton, browseDevice() );
268 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
269 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
270 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
271 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
272 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
275 DiscOpenPanel::~DiscOpenPanel()
278 void DiscOpenPanel::clear()
280 ui.titleSpin->setValue( 0 );
281 ui.chapterSpin->setValue( 0 );
284 void DiscOpenPanel::updateButtons()
286 if ( ui.dvdRadioButton->isChecked() )
288 ui.titleLabel->setText( qtr("Title") );
289 ui.chapterLabel->show();
290 ui.chapterSpin->show();
291 ui.diskOptionBox_2->show();
293 else if ( ui.vcdRadioButton->isChecked() )
295 ui.titleLabel->setText( qtr("Entry") );
296 ui.chapterLabel->hide();
297 ui.chapterSpin->hide();
298 ui.diskOptionBox_2->show();
302 ui.titleLabel->setText( qtr("Track") );
303 ui.chapterLabel->hide();
304 ui.chapterSpin->hide();
305 ui.diskOptionBox_2->hide();
312 void DiscOpenPanel::updateMRL()
316 /* CDDAX and VCDX not implemented. FIXME ? */
318 if( ui.dvdRadioButton->isChecked() ) {
319 if( !ui.dvdsimple->isChecked() )
322 mrl = "dvdsimple://";
323 mrl += ui.deviceCombo->currentText();
324 emit methodChanged( "dvdnav-caching" );
326 if ( ui.titleSpin->value() > 0 ) {
327 mrl += QString("@%1").arg( ui.titleSpin->value() );
328 if ( ui.chapterSpin->value() > 0 ) {
329 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
334 } else if ( ui.vcdRadioButton->isChecked() ) {
335 mrl = "vcd://" + ui.deviceCombo->currentText();
336 emit methodChanged( "vcd-caching" );
338 if( ui.titleSpin->value() > 0 ) {
339 mrl += QString("@E%1").arg( ui.titleSpin->value() );
344 mrl = "cdda://" + ui.deviceCombo->currentText();
345 if( ui.titleSpin->value() > 0 ) {
346 QString("@%1").arg( ui.titleSpin->value() );
350 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
352 if ( ui.audioSpin->value() >= 0 ) {
353 mrl += " :audio-track=" +
354 QString("%1").arg( ui.audioSpin->value() );
356 if ( ui.subtitlesSpin->value() >= 0 ) {
357 mrl += " :sub-track=" +
358 QString("%1").arg( ui.subtitlesSpin->value() );
361 emit mrlUpdated( mrl );
364 void DiscOpenPanel::browseDevice()
366 QString dir = QFileDialog::getExistingDirectory( 0,
367 qtr("Open a device or a VIDEO_TS directory") );
368 if (!dir.isEmpty()) {
369 ui.deviceCombo->setEditText( dir );
374 void DiscOpenPanel::accept()
376 /* set dialog box current directory as last known path */
377 config_PutPsz( p_intf, "qt-discdialog-path",
378 qtu( ui.deviceCombo->currentText() ) );
381 /**************************************************************************
382 * Open Network streams and URL pages *
383 **************************************************************************/
384 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
385 OpenPanel( _parent, _p_intf )
390 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
391 this, updateProtocol( int ) );
392 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
393 CONNECT( ui.addressText, textChanged( QString ), this, updateAddress());
394 CONNECT( ui.timeShift, clicked(), this, updateMRL());
395 CONNECT( ui.ipv6, clicked(), this, updateMRL());
397 ui.protocolCombo->addItem("HTTP", QVariant("http"));
398 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
399 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
400 ui.protocolCombo->addItem("MMS", QVariant("mms"));
401 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
402 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
403 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
406 NetOpenPanel::~NetOpenPanel()
409 void NetOpenPanel::clear()
412 void NetOpenPanel::updateProtocol( int idx ) {
413 QString addr = ui.addressText->text();
414 QString proto = ui.protocolCombo->itemData( idx ).toString();
416 ui.timeShift->setEnabled( idx >= 5 );
417 ui.ipv6->setEnabled( idx == 5 );
418 ui.addressText->setEnabled( idx != 5 );
419 ui.portSpin->setEnabled( idx >= 5 );
421 /* If we already have a protocol in the address, replace it */
422 if( addr.contains( "://")) {
423 msg_Err( p_intf, "replace");
424 addr.replace( QRegExp("^.*://"), proto + "://");
425 ui.addressText->setText( addr );
430 void NetOpenPanel::updateAddress() {
434 void NetOpenPanel::updateMRL() {
436 QString addr = ui.addressText->text();
437 int proto = ui.protocolCombo->currentIndex();
439 if( addr.contains( "://") && proto != 5 ) {
444 mrl = "http://" + addr;
445 emit methodChanged("http-caching");
448 mrl = "https://" + addr;
449 emit methodChanged("http-caching");
452 mrl = "mms://" + addr;
453 emit methodChanged("mms-caching");
456 mrl = "ftp://" + addr;
457 emit methodChanged("ftp-caching");
460 mrl = "rtsp://" + addr;
461 emit methodChanged("rtsp-caching");
465 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
468 mrl += QString(":%1").arg( ui.portSpin->value() );
469 emit methodChanged("udp-caching");
471 case 6: /* UDP multicast */
474 if ( addr.contains(':') && !addr.contains('[') ) {
475 mrl += "[" + addr + "]";
477 mrl += QString(":%1").arg( ui.portSpin->value() );
478 emit methodChanged("udp-caching");
481 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
482 mrl += " :access-filter=timeshift";
484 emit mrlUpdated( mrl );
487 /**************************************************************************
488 * Open Capture device ( DVB, PVR, V4L, and similar ) *
489 **************************************************************************/
490 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
491 OpenPanel( _parent, _p_intf )
495 /* Create two stacked layouts in the main comboBoxes */
496 QStackedLayout *stackedDevLayout = new QStackedLayout;
497 ui.cardBox->setLayout( stackedDevLayout );
499 QStackedLayout *stackedPropLayout = new QStackedLayout;
500 ui.optionsBox->setLayout( stackedPropLayout );
502 /* Creation and connections of the WIdgets in the stacked layout */
503 #define addModuleAndLayouts( number, name, label ) \
504 QWidget * name ## DevPage = new QWidget( this ); \
505 QWidget * name ## PropPage = new QWidget( this ); \
506 stackedDevLayout->addWidget( name ## DevPage ); \
507 stackedPropLayout->addWidget( name ## PropPage ); \
508 QGridLayout * name ## DevLayout = new QGridLayout; \
509 QGridLayout * name ## PropLayout = new QGridLayout; \
510 name ## DevPage->setLayout( name ## DevLayout ); \
511 name ## PropPage->setLayout( name ## PropLayout ); \
512 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
514 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
519 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
522 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
523 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
525 v4lVideoDevice = new QLineEdit;
526 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
528 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
529 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
531 v4lAudioDevice = new QLineEdit;
532 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
534 /* V4l Props panel */
535 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
536 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
538 v4lNormBox = new QComboBox;
539 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
540 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
542 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
543 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
545 v4lFreq = new QSpinBox;
546 v4lFreq->setAlignment( Qt::AlignRight );
547 v4lFreq->setSuffix(" kHz");
548 setSpinBoxFreq( v4lFreq );
549 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
550 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
554 CuMRL( v4lVideoDevice, textChanged( QString ) );
555 CuMRL( v4lAudioDevice, textChanged( QString ) );
556 CuMRL( v4lFreq, valueChanged ( int ) );
557 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
562 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
565 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
566 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
568 v4l2VideoDevice = new QLineEdit;
569 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
571 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
572 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
574 v4l2AudioDevice = new QLineEdit;
575 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
577 /* v4l2 Props panel */
578 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
579 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
581 v4l2StdBox = new QComboBox;
582 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
583 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
584 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
588 CuMRL( v4l2VideoDevice, textChanged( QString ) );
589 CuMRL( v4l2AudioDevice, textChanged( QString ) );
590 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
595 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
597 /* Jack Main panel */
599 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
600 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
602 jackChannels = new QSpinBox;
603 setSpinBoxFreq( jackChannels );
604 jackChannels->setMaximum(255);
605 jackChannels->setValue(2);
606 jackChannels->setAlignment( Qt::AlignRight );
607 jackDevLayout->addWidget( jackChannels, 1, 1 );
609 /* Jack Props panel */
612 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
613 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
615 jackPortsSelected = new QLineEdit( qtr( ".*") );
616 jackPortsSelected->setAlignment( Qt::AlignRight );
617 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
620 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
621 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
622 jackCaching = new QSpinBox;
623 setSpinBoxFreq( jackCaching );
624 jackCaching->setSuffix( " ms" );
625 jackCaching->setValue(1000);
626 jackCaching->setAlignment( Qt::AlignRight );
627 jackPropLayout->addWidget( jackCaching, 1 , 1 );
630 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
631 jackPropLayout->addWidget( jackPace, 2, 1 );
634 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
635 jackPropLayout->addWidget( jackConnect, 3, 1 );
638 CuMRL( jackChannels, valueChanged( int ) );
639 CuMRL( jackCaching, valueChanged( int ) );
640 CuMRL( jackPace, stateChanged( int ) );
641 CuMRL( jackConnect, stateChanged( int ) );
642 CuMRL( jackPortsSelected, textChanged( QString ) );
647 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
650 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
651 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
653 pvrDevice = new QLineEdit;
654 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
656 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
657 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
659 pvrRadioDevice = new QLineEdit;
660 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
662 /* PVR props panel */
663 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
664 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
666 pvrNormBox = new QComboBox;
667 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
668 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
670 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
671 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
673 pvrFreq = new QSpinBox;
674 pvrFreq->setAlignment( Qt::AlignRight );
675 pvrFreq->setSuffix(" kHz");
676 setSpinBoxFreq( pvrFreq );
677 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
679 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
680 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
682 pvrBitr = new QSpinBox;
683 pvrBitr->setAlignment( Qt::AlignRight );
684 pvrBitr->setSuffix(" kHz");
685 setSpinBoxFreq( pvrBitr );
686 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
687 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
691 CuMRL( pvrDevice, textChanged( QString ) );
692 CuMRL( pvrRadioDevice, textChanged( QString ) );
694 CuMRL( pvrFreq, valueChanged ( int ) );
695 CuMRL( pvrBitr, valueChanged ( int ) );
696 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
698 /*********************
699 * DirectShow Stuffs *
700 *********************/
701 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
705 QLabel *dshowVDeviceLabel = new QLabel( qtr( "Video Device Name " ) );
706 dshowDevLayout->addWidget( dshowVDeviceLabel, 0, 0 );
708 QLabel *dshowADeviceLabel = new QLabel( qtr( "Audio Device Name " ) );
709 dshowDevLayout->addWidget( dshowADeviceLabel, 1, 0 );
711 QComboBox *dshowVDevice = new QComboBox;
712 dshowDevLayout->addWidget( dshowVDevice, 0, 1 );
714 QComboBox *dshowADevice = new QComboBox;
715 dshowDevLayout->addWidget( dshowADevice, 1, 1 );
717 QPushButton *dshowVRefresh = new QPushButton( qtr( "Update List" ) );
718 dshowDevLayout->addWidget( dshowVRefresh, 0, 2 );
720 QPushButton *dshowARefresh = new QPushButton( qtr( "Update List" ) );
721 dshowDevLayout->addWidget( dshowARefresh, 1, 2 );
723 QPushButton *dshowVConfig = new QPushButton( qtr( "Configure" ) );
724 dshowDevLayout->addWidget( dshowVConfig, 0, 3 );
726 QPushButton *dshowAConfig = new QPushButton( qtr( "Configure" ) );
727 dshowDevLayout->addWidget( dshowAConfig, 1, 3 );
729 /* dshow Properties */
731 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
732 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
734 QLineEdit *dshowVSizeLine = new QLineEdit;
735 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
736 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
740 CuMRL( dshowVDevice, currentIndexChanged ( int ) );
741 CuMRL( dshowADevice, currentIndexChanged ( int ) );
742 CuMRL( dshowVSizeLine, textChanged( QString ) );
747 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
750 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
752 bdas = new QRadioButton( "DVB-S" );
753 bdas->setChecked( true );
754 bdac = new QRadioButton( "DVB-C" );
755 bdat = new QRadioButton( "DVB-T" );
757 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
758 bdaDevLayout->addWidget( bdas, 0, 1 );
759 bdaDevLayout->addWidget( bdac, 0, 2 );
760 bdaDevLayout->addWidget( bdat, 0, 3 );
763 QLabel *bdaFreqLabel =
764 new QLabel( qtr( "Transponder/multiplex frequency" ) );
765 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
767 bdaFreq = new QSpinBox;
768 bdaFreq->setAlignment( Qt::AlignRight );
769 bdaFreq->setSuffix(" kHz");
770 bdaFreq->setSingleStep( 1000 );
771 setSpinBoxFreq( bdaFreq )
772 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
774 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
775 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
777 bdaSrate = new QSpinBox;
778 bdaSrate->setAlignment( Qt::AlignRight );
779 bdaSrate->setSuffix(" kHz");
780 setSpinBoxFreq( bdaSrate );
781 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
783 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
784 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
786 bdaBandBox = new QComboBox;
787 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
788 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
790 bdaBandLabel->hide();
792 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
796 CuMRL( bdaFreq, valueChanged ( int ) );
797 CuMRL( bdaSrate, valueChanged ( int ) );
798 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
799 BUTTONACT( bdas, updateButtons() );
800 BUTTONACT( bdat, updateButtons() );
801 BUTTONACT( bdac, updateButtons() );
802 BUTTONACT( bdas, updateMRL() );
803 BUTTONACT( bdat, updateMRL() );
804 BUTTONACT( bdac, updateMRL() );
809 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
812 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
813 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
815 dvbCard = new QSpinBox;
816 dvbCard->setAlignment( Qt::AlignRight );
817 dvbCard->setPrefix( "/dev/dvb/adapter" );
819 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
820 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
822 dvbs = new QRadioButton( "DVB-S" );
823 dvbs->setChecked( true );
824 dvbc = new QRadioButton( "DVB-C" );
825 dvbt = new QRadioButton( "DVB-T" );
827 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
828 dvbDevLayout->addWidget( dvbs, 1, 1 );
829 dvbDevLayout->addWidget( dvbc, 1, 2 );
830 dvbDevLayout->addWidget( dvbt, 1, 3 );
832 /* DVB Props panel */
833 QLabel *dvbFreqLabel =
834 new QLabel( qtr( "Transponder/multiplex frequency" ) );
835 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
837 dvbFreq = new QSpinBox;
838 dvbFreq->setAlignment( Qt::AlignRight );
839 dvbFreq->setSuffix(" kHz");
840 setSpinBoxFreq( dvbFreq );
841 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
843 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
844 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
846 dvbSrate = new QSpinBox;
847 dvbSrate->setAlignment( Qt::AlignRight );
848 dvbSrate->setSuffix(" kHz");
849 setSpinBoxFreq( dvbSrate );
850 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
851 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
855 CuMRL( dvbCard, valueChanged ( int ) );
856 CuMRL( dvbFreq, valueChanged ( int ) );
857 CuMRL( dvbSrate, valueChanged ( int ) );
859 BUTTONACT( dvbs, updateButtons() );
860 BUTTONACT( dvbt, updateButtons() );
861 BUTTONACT( dvbc, updateButtons() );
866 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
867 QLabel *screenLabel = new QLabel( "This option will open your own "
868 "desktop in order to save or stream it.");
869 screenLabel->setWordWrap( true );
870 screenDevLayout->addWidget( screenLabel, 0, 0 );
872 /* General connects */
873 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
874 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
875 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
876 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
877 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
878 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
883 CaptureOpenPanel::~CaptureOpenPanel()
886 void CaptureOpenPanel::clear()
889 void CaptureOpenPanel::updateMRL()
892 int i_devicetype = ui.deviceCombo->itemData(
893 ui.deviceCombo->currentIndex() ).toInt();
894 switch( i_devicetype )
898 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
899 mrl += " :v4l-adev=" + v4lAudioDevice->text();
900 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
901 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
905 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
906 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
907 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
911 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
912 mrl += ":ports=" + jackPortsSelected->text();
913 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
914 if ( jackPace->isChecked() )
916 mrl += " --jack-input-use-vlc-pace";
918 if ( jackConnect->isChecked() )
920 mrl += " --jack-input-auto-connect";
925 mrl += " :pvr-device=" + pvrDevice->text();
926 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
927 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
928 if( pvrFreq->value() )
929 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
930 if( pvrBitr->value() )
931 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
935 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
936 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
937 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
940 if( bdas->isChecked() ) mrl = "dvb-s://";
941 else if( bdat->isChecked() ) mrl = "dvb-t://";
942 else if( bdac->isChecked() ) mrl = "dvb-c://";
944 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
945 if( bdas->isChecked() || bdac->isChecked() )
946 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
948 mrl += " :dvb-bandwidth=" +
949 QString("%1").arg( bdaBandBox->itemData(
950 bdaBandBox->currentIndex() ).toInt() );
959 emit mrlUpdated( mrl );
963 * Update the Buttons (show/hide) for the GUI as all device type don't
964 * use the same ui. elements.
966 void CaptureOpenPanel::updateButtons()
968 /* Be sure to display the ui Elements in case they were hidden by
969 * some Device Type (like Screen://) */
970 ui.optionsBox->show();
971 ui.advancedButton->show();
972 /* Get the current Device Number */
973 int i_devicetype = ui.deviceCombo->itemData(
974 ui.deviceCombo->currentIndex() ).toInt();
975 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
976 switch( i_devicetype )
979 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
980 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
983 if( bdas->isChecked() || bdac->isChecked() )
986 bdaSrateLabel->show();
988 bdaBandLabel->hide();
993 bdaSrateLabel->hide();
995 bdaBandLabel->show();
999 ui.optionsBox->hide();
1000 ui.advancedButton->hide();