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
9 * Authors: Clément Stenac <zorglub@videolan.org>
10 * Jean-Baptiste Kempf <jb@videolan.org>
11 * Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
30 #include "components/open.hpp"
31 #include "dialogs/open.hpp"
32 #include "dialogs_provider.hpp"
33 #include "util/customwidgets.hpp"
35 #include <QFileDialog>
36 #include <QDialogButtonBox>
38 #include <QStackedLayout>
43 /**************************************************************************
44 * Open Files and subtitles *
45 **************************************************************************/
46 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
47 OpenPanel( _parent, _p_intf )
49 /* Classic UI Setup */
52 /** BEGIN QFileDialog tweaking **/
53 /* Use a QFileDialog and customize it because we don't want to
54 rewrite it all. Be careful to your eyes cause there are a few hacks.
55 Be very careful and test correctly when you modify this. */
57 /* Set Filters for file selection */
58 QString fileTypes = "";
59 ADD_FILTER_MEDIA( fileTypes );
60 ADD_FILTER_VIDEO( fileTypes );
61 ADD_FILTER_AUDIO( fileTypes );
62 ADD_FILTER_PLAYLIST( fileTypes );
63 ADD_FILTER_ALL( fileTypes );
64 fileTypes.replace( QString(";*"), QString(" *"));
66 /* retrieve last known path used in file browsing */
67 char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
68 if( EMPTY_STR( psz_filepath ) )
70 psz_filepath = p_intf->p_libvlc->psz_homedir;
72 // Make this QFileDialog a child of tempWidget from the ui.
73 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
74 qfu( psz_filepath ), fileTypes );
77 dialogBox->setFileMode( QFileDialog::ExistingFiles );
78 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
80 /* We don't want to see a grip in the middle of the window, do we? */
81 dialogBox->setSizeGripEnabled( false );
84 dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
86 // But hide the two OK/Cancel buttons. Enable them for debug.
87 QDialogButtonBox *fileDialogAcceptBox =
88 dialogBox->findChildren<QDialogButtonBox*>()[0];
89 fileDialogAcceptBox->hide();
91 /* Ugly hacks to get the good Widget */
92 //This lineEdit is the normal line in the fileDialog.
94 lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
97 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() );
137 CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
138 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
140 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this,
144 FileOpenPanel::~FileOpenPanel()
147 QStringList FileOpenPanel::browse( QString help )
149 return THEDP->showSimpleOpen( help );
153 void FileOpenPanel::browseFileSub()
155 // FIXME Handle selection of more than one subtitles file
156 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
158 dialogBox->directory().absolutePath() );
159 if( files.isEmpty() ) return;
160 ui.subInput->setText( files.join(" ") );
164 void FileOpenPanel::updateMRL()
167 foreach( QString file, dialogBox->selectedFiles() ) {
168 mrl += "\"" + file + "\" ";
171 if( ui.subCheckBox->isChecked() ) {
172 mrl.append( " :sub-file=" + ui.subInput->text() );
173 int align = ui.alignSubComboBox->itemData(
174 ui.alignSubComboBox->currentIndex() ).toInt();
175 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
176 int size = ui.sizeSubComboBox->itemData(
177 ui.sizeSubComboBox->currentIndex() ).toInt();
178 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
181 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() ) );
191 emit mrlUpdated( mrl );
192 emit methodChanged( "file-caching" );
196 /* Function called by Open Dialog when clicke on Play/Enqueue */
197 void FileOpenPanel::accept()
199 //FIXME set the completer
202 void FileOpenBox::accept()
204 OpenDialog::getInstance( NULL, NULL )->play();
207 /* Function called by Open Dialog when clicked on cancel */
208 void FileOpenPanel::clear()
210 lineFileEdit->clear();
211 ui.subInput->clear();
214 void FileOpenPanel::toggleSubtitleFrame()
216 TOGGLEV( ui.subFrame );
222 /**************************************************************************
223 * Open Discs ( DVD, CD, VCD and similar devices ) *
224 **************************************************************************/
225 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
226 OpenPanel( _parent, _p_intf )
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 #endif /* Disc Probing under Windows */
250 BUTTONACT( ui.dvdRadioButton, updateButtons() );
251 BUTTONACT( ui.vcdRadioButton, updateButtons() );
252 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
253 BUTTONACT( ui.dvdsimple, updateButtons() );
254 BUTTONACT( ui.browseDiscButton, browseDevice() );
256 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
257 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
258 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
259 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
260 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
263 DiscOpenPanel::~DiscOpenPanel()
266 void DiscOpenPanel::clear()
268 ui.titleSpin->setValue( 0 );
269 ui.chapterSpin->setValue( 0 );
272 void DiscOpenPanel::updateButtons()
274 if ( ui.dvdRadioButton->isChecked() )
276 ui.titleLabel->setText( qtr("Title") );
277 ui.chapterLabel->show();
278 ui.chapterSpin->show();
279 ui.diskOptionBox_2->show();
281 else if ( ui.vcdRadioButton->isChecked() )
283 ui.titleLabel->setText( qtr("Entry") );
284 ui.chapterLabel->hide();
285 ui.chapterSpin->hide();
286 ui.diskOptionBox_2->show();
290 ui.titleLabel->setText( qtr("Track") );
291 ui.chapterLabel->hide();
292 ui.chapterSpin->hide();
293 ui.diskOptionBox_2->hide();
300 void DiscOpenPanel::updateMRL()
304 /* CDDAX and VCDX not implemented. FIXME ? */
306 if( ui.dvdRadioButton->isChecked() ) {
307 if( !ui.dvdsimple->isChecked() )
310 mrl = "dvdsimple://";
311 mrl += ui.deviceCombo->currentText();
312 emit methodChanged( "dvdnav-caching" );
314 if ( ui.titleSpin->value() > 0 ) {
315 mrl += QString("@%1").arg( ui.titleSpin->value() );
316 if ( ui.chapterSpin->value() > 0 ) {
317 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
322 } else if ( ui.vcdRadioButton->isChecked() ) {
323 mrl = "vcd://" + ui.deviceCombo->currentText();
324 emit methodChanged( "vcd-caching" );
326 if( ui.titleSpin->value() > 0 ) {
327 mrl += QString("@E%1").arg( ui.titleSpin->value() );
332 mrl = "cdda://" + ui.deviceCombo->currentText();
333 if( ui.titleSpin->value() > 0 ) {
334 QString("@%1").arg( ui.titleSpin->value() );
338 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
340 if ( ui.audioSpin->value() >= 0 ) {
341 mrl += " :audio-track=" +
342 QString("%1").arg( ui.audioSpin->value() );
344 if ( ui.subtitlesSpin->value() >= 0 ) {
345 mrl += " :sub-track=" +
346 QString("%1").arg( ui.subtitlesSpin->value() );
349 emit mrlUpdated( mrl );
352 void DiscOpenPanel::browseDevice()
354 QString dir = QFileDialog::getExistingDirectory( 0,
355 qtr("Open a device or a VIDEO_TS directory") );
356 if (!dir.isEmpty()) {
357 ui.deviceCombo->setEditText( dir );
362 /**************************************************************************
363 * Open Network streams and URL pages *
364 **************************************************************************/
365 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
366 OpenPanel( _parent, _p_intf )
371 CONNECT( ui.protocolCombo, currentIndexChanged( int ),
372 this, updateProtocol( int ) );
373 CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
374 CONNECT( ui.addressText, textChanged( QString ), this, updateAddress());
375 CONNECT( ui.timeShift, clicked(), this, updateMRL());
376 CONNECT( ui.ipv6, clicked(), this, updateMRL());
378 ui.protocolCombo->addItem("HTTP", QVariant("http"));
379 ui.protocolCombo->addItem("HTTPS", QVariant("https"));
380 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
381 ui.protocolCombo->addItem("MMS", QVariant("mms"));
382 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
383 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
384 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
387 NetOpenPanel::~NetOpenPanel()
390 void NetOpenPanel::clear()
393 void NetOpenPanel::updateProtocol( int idx ) {
394 QString addr = ui.addressText->text();
395 QString proto = ui.protocolCombo->itemData( idx ).toString();
397 ui.timeShift->setEnabled( idx >= 5 );
398 ui.ipv6->setEnabled( idx == 5 );
399 ui.addressText->setEnabled( idx != 5 );
400 ui.portSpin->setEnabled( idx >= 5 );
402 /* If we already have a protocol in the address, replace it */
403 if( addr.contains( "://")) {
404 msg_Err( p_intf, "replace");
405 addr.replace( QRegExp("^.*://"), proto + "://");
406 ui.addressText->setText( addr );
411 void NetOpenPanel::updateAddress() {
415 void NetOpenPanel::updateMRL() {
417 QString addr = ui.addressText->text();
418 int proto = ui.protocolCombo->currentIndex();
420 if( addr.contains( "://") && proto != 5 ) {
425 mrl = "http://" + addr;
426 emit methodChanged("http-caching");
429 mrl = "https://" + addr;
430 emit methodChanged("http-caching");
433 mrl = "mms://" + addr;
434 emit methodChanged("mms-caching");
437 mrl = "ftp://" + addr;
438 emit methodChanged("ftp-caching");
441 mrl = "rtsp://" + addr;
442 emit methodChanged("rtsp-caching");
446 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
449 mrl += QString(":%1").arg( ui.portSpin->value() );
450 emit methodChanged("udp-caching");
452 case 6: /* UDP multicast */
455 if ( addr.contains(':') && !addr.contains('[') ) {
456 mrl += "[" + addr + "]";
458 mrl += QString(":%1").arg( ui.portSpin->value() );
459 emit methodChanged("udp-caching");
462 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
463 mrl += " :access-filter=timeshift";
465 emit mrlUpdated( mrl );
468 /**************************************************************************
469 * Open Capture device ( DVB, PVR, V4L, and similar ) *
470 **************************************************************************/
471 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
472 OpenPanel( _parent, _p_intf )
476 /* Create two stacked layouts in the main comboBoxes */
477 QStackedLayout *stackedDevLayout = new QStackedLayout;
478 ui.cardBox->setLayout( stackedDevLayout );
480 QStackedLayout *stackedPropLayout = new QStackedLayout;
481 ui.optionsBox->setLayout( stackedPropLayout );
483 /* Creation and connections of the WIdgets in the stacked layout */
484 #define addModuleAndLayouts( number, name, label ) \
485 QWidget * name ## DevPage = new QWidget( this ); \
486 QWidget * name ## PropPage = new QWidget( this ); \
487 stackedDevLayout->addWidget( name ## DevPage ); \
488 stackedPropLayout->addWidget( name ## PropPage ); \
489 QGridLayout * name ## DevLayout = new QGridLayout; \
490 QGridLayout * name ## PropLayout = new QGridLayout; \
491 name ## DevPage->setLayout( name ## DevLayout ); \
492 name ## PropPage->setLayout( name ## PropLayout ); \
493 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
495 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
500 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
503 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
504 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
506 v4lVideoDevice = new QLineEdit;
507 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
509 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
510 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
512 v4lAudioDevice = new QLineEdit;
513 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
515 /* V4l Props panel */
516 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
517 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
519 v4lNormBox = new QComboBox;
520 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
521 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
523 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
524 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
526 v4lFreq = new QSpinBox;
527 v4lFreq->setAlignment( Qt::AlignRight );
528 v4lFreq->setSuffix(" kHz");
529 setSpinBoxFreq( v4lFreq );
530 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
531 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
535 CuMRL( v4lVideoDevice, textChanged( QString ) );
536 CuMRL( v4lAudioDevice, textChanged( QString ) );
537 CuMRL( v4lFreq, valueChanged ( int ) );
538 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
543 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
546 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
547 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
549 v4l2VideoDevice = new QLineEdit;
550 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
552 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
553 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
555 v4l2AudioDevice = new QLineEdit;
556 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
558 /* v4l2 Props panel */
559 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
560 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
562 v4l2StdBox = new QComboBox;
563 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
564 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
565 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
569 CuMRL( v4l2VideoDevice, textChanged( QString ) );
570 CuMRL( v4l2AudioDevice, textChanged( QString ) );
571 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
576 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
578 /* Jack Main panel */
580 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
581 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
583 jackChannels = new QSpinBox;
584 setSpinBoxFreq( jackChannels );
585 jackChannels->setMaximum(255);
586 jackChannels->setValue(2);
587 jackChannels->setAlignment( Qt::AlignRight );
588 jackDevLayout->addWidget( jackChannels, 1, 1 );
590 /* Jack Props panel */
593 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
594 jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
596 jackPortsSelected = new QLineEdit( qtr( ".*") );
597 jackPortsSelected->setAlignment( Qt::AlignRight );
598 jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
601 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
602 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
603 jackCaching = new QSpinBox;
604 setSpinBoxFreq( jackCaching );
605 jackCaching->setSuffix( " ms" );
606 jackCaching->setValue(1000);
607 jackCaching->setAlignment( Qt::AlignRight );
608 jackPropLayout->addWidget( jackCaching, 1 , 1 );
611 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
612 jackPropLayout->addWidget( jackPace, 2, 1 );
615 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
616 jackPropLayout->addWidget( jackConnect, 3, 1 );
619 CuMRL( jackChannels, valueChanged( int ) );
620 CuMRL( jackCaching, valueChanged( int ) );
621 CuMRL( jackPace, stateChanged( int ) );
622 CuMRL( jackConnect, stateChanged( int ) );
623 CuMRL( jackPortsSelected, textChanged( QString ) );
628 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
631 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
632 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
634 pvrDevice = new QLineEdit;
635 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
637 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
638 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
640 pvrRadioDevice = new QLineEdit;
641 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
643 /* PVR props panel */
644 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
645 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
647 pvrNormBox = new QComboBox;
648 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
649 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
651 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
652 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
654 pvrFreq = new QSpinBox;
655 pvrFreq->setAlignment( Qt::AlignRight );
656 pvrFreq->setSuffix(" kHz");
657 setSpinBoxFreq( pvrFreq );
658 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
660 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
661 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
663 pvrBitr = new QSpinBox;
664 pvrBitr->setAlignment( Qt::AlignRight );
665 pvrBitr->setSuffix(" kHz");
666 setSpinBoxFreq( pvrBitr );
667 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
668 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
672 CuMRL( pvrDevice, textChanged( QString ) );
673 CuMRL( pvrRadioDevice, textChanged( QString ) );
675 CuMRL( pvrFreq, valueChanged ( int ) );
676 CuMRL( pvrBitr, valueChanged ( int ) );
677 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
679 /*********************
680 * DirectShow Stuffs *
681 *********************/
682 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
686 QLabel *dshowVDeviceLabel = new QLabel( qtr( "Video Device Name " ) );
687 dshowDevLayout->addWidget( dshowVDeviceLabel, 0, 0 );
689 QLabel *dshowADeviceLabel = new QLabel( qtr( "Audio Device Name " ) );
690 dshowDevLayout->addWidget( dshowADeviceLabel, 1, 0 );
692 QComboBox *dshowVDevice = new QComboBox;
693 dshowDevLayout->addWidget( dshowVDevice, 0, 1 );
695 QComboBox *dshowADevice = new QComboBox;
696 dshowDevLayout->addWidget( dshowADevice, 1, 1 );
698 QPushButton *dshowVRefresh = new QPushButton( qtr( "Update List" ) );
699 dshowDevLayout->addWidget( dshowVRefresh, 0, 2 );
701 QPushButton *dshowARefresh = new QPushButton( qtr( "Update List" ) );
702 dshowDevLayout->addWidget( dshowARefresh, 1, 2 );
704 QPushButton *dshowVConfig = new QPushButton( qtr( "Configure" ) );
705 dshowDevLayout->addWidget( dshowVConfig, 0, 3 );
707 QPushButton *dshowAConfig = new QPushButton( qtr( "Configure" ) );
708 dshowDevLayout->addWidget( dshowAConfig, 1, 3 );
710 /* dshow Properties */
712 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
713 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
715 QLineEdit *dshowVSizeLine = new QLineEdit;
716 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
717 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
721 CuMRL( dshowVDevice, currentIndexChanged ( int ) );
722 CuMRL( dshowADevice, currentIndexChanged ( int ) );
723 CuMRL( dshowVSizeLine, textChanged( QString ) );
728 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
731 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
733 bdas = new QRadioButton( "DVB-S" );
734 bdas->setChecked( true );
735 bdac = new QRadioButton( "DVB-C" );
736 bdat = new QRadioButton( "DVB-T" );
738 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
739 bdaDevLayout->addWidget( bdas, 0, 1 );
740 bdaDevLayout->addWidget( bdac, 0, 2 );
741 bdaDevLayout->addWidget( bdat, 0, 3 );
744 QLabel *bdaFreqLabel =
745 new QLabel( qtr( "Transponder/multiplex frequency" ) );
746 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
748 bdaFreq = new QSpinBox;
749 bdaFreq->setAlignment( Qt::AlignRight );
750 bdaFreq->setSuffix(" kHz");
751 bdaFreq->setSingleStep( 1000 );
752 setSpinBoxFreq( bdaFreq )
753 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
755 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
756 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
758 bdaSrate = new QSpinBox;
759 bdaSrate->setAlignment( Qt::AlignRight );
760 bdaSrate->setSuffix(" kHz");
761 setSpinBoxFreq( bdaSrate );
762 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
764 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
765 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
767 bdaBandBox = new QComboBox;
768 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
769 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
771 bdaBandLabel->hide();
773 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
777 CuMRL( bdaFreq, valueChanged ( int ) );
778 CuMRL( bdaSrate, valueChanged ( int ) );
779 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
780 BUTTONACT( bdas, updateButtons() );
781 BUTTONACT( bdat, updateButtons() );
782 BUTTONACT( bdac, updateButtons() );
783 BUTTONACT( bdas, updateMRL() );
784 BUTTONACT( bdat, updateMRL() );
785 BUTTONACT( bdac, updateMRL() );
790 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
793 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
794 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
796 dvbCard = new QSpinBox;
797 dvbCard->setAlignment( Qt::AlignRight );
798 dvbCard->setPrefix( "/dev/dvb/adapter" );
800 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
801 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
803 dvbs = new QRadioButton( "DVB-S" );
804 dvbs->setChecked( true );
805 dvbc = new QRadioButton( "DVB-C" );
806 dvbt = new QRadioButton( "DVB-T" );
808 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
809 dvbDevLayout->addWidget( dvbs, 1, 1 );
810 dvbDevLayout->addWidget( dvbc, 1, 2 );
811 dvbDevLayout->addWidget( dvbt, 1, 3 );
813 /* DVB Props panel */
814 QLabel *dvbFreqLabel =
815 new QLabel( qtr( "Transponder/multiplex frequency" ) );
816 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
818 dvbFreq = new QSpinBox;
819 dvbFreq->setAlignment( Qt::AlignRight );
820 dvbFreq->setSuffix(" kHz");
821 setSpinBoxFreq( dvbFreq );
822 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
824 QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
825 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
827 dvbSrate = new QSpinBox;
828 dvbSrate->setAlignment( Qt::AlignRight );
829 dvbSrate->setSuffix(" kHz");
830 setSpinBoxFreq( dvbSrate );
831 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
832 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
836 CuMRL( dvbCard, valueChanged ( int ) );
837 CuMRL( dvbFreq, valueChanged ( int ) );
838 CuMRL( dvbSrate, valueChanged ( int ) );
840 BUTTONACT( dvbs, updateButtons() );
841 BUTTONACT( dvbt, updateButtons() );
842 BUTTONACT( dvbc, updateButtons() );
847 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
848 QLabel *screenLabel = new QLabel( "This option will open your own "
849 "desktop in order to save or stream it.");
850 screenLabel->setWordWrap( true );
851 screenDevLayout->addWidget( screenLabel, 0, 0 );
853 /* General connects */
854 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
855 stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
856 connect( ui.deviceCombo, SIGNAL( activated( int ) ),
857 stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
858 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
859 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
864 CaptureOpenPanel::~CaptureOpenPanel()
867 void CaptureOpenPanel::clear()
870 void CaptureOpenPanel::updateMRL()
873 int i_devicetype = ui.deviceCombo->itemData(
874 ui.deviceCombo->currentIndex() ).toInt();
875 switch( i_devicetype )
879 mrl += " :v4l-vdev=" + v4lVideoDevice->text();
880 mrl += " :v4l-adev=" + v4lAudioDevice->text();
881 mrl += " :v4l-norm=" + QString("%1").arg( v4lNormBox->currentIndex() );
882 mrl += " :v4l-frequency=" + QString("%1").arg( v4lFreq->value() );
886 mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
887 mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
888 mrl += " :v4l2-standard=" + QString("%1").arg( v4l2StdBox->currentIndex() );
892 mrl += "channels=" + QString("%1").arg( jackChannels->value() );
893 mrl += ":ports=" + jackPortsSelected->text();
894 mrl += " --jack-input-caching=" + QString("%1").arg( jackCaching->value() );
895 if ( jackPace->isChecked() )
897 mrl += " --jack-input-use-vlc-pace";
899 if ( jackConnect->isChecked() )
901 mrl += " --jack-input-auto-connect";
906 mrl += " :pvr-device=" + pvrDevice->text();
907 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
908 mrl += " :pvr-norm=" + QString("%1").arg( pvrNormBox->currentIndex() );
909 if( pvrFreq->value() )
910 mrl += " :pvr-frequency=" + QString("%1").arg( pvrFreq->value() );
911 if( pvrBitr->value() )
912 mrl += " :pvr-bitrate=" + QString("%1").arg( pvrBitr->value() );
916 mrl += " :dvb-adapter=" + QString("%1").arg( dvbCard->value() );
917 mrl += " :dvb-frequency=" + QString("%1").arg( dvbFreq->value() );
918 mrl += " :dvb-srate=" + QString("%1").arg( dvbSrate->value() );
921 if( bdas->isChecked() ) mrl = "dvb-s://";
922 else if( bdat->isChecked() ) mrl = "dvb-t://";
923 else if( bdac->isChecked() ) mrl = "dvb-c://";
925 mrl += " :dvb-frequency=" + QString("%1").arg( bdaFreq->value() );
926 if( bdas->isChecked() || bdac->isChecked() )
927 mrl += " :dvb-srate=" + QString("%1").arg( bdaSrate->value() );
929 mrl += " :dvb-bandwidth=" +
930 QString("%1").arg( bdaBandBox->itemData(
931 bdaBandBox->currentIndex() ).toInt() );
940 emit mrlUpdated( mrl );
944 * Update the Buttons (show/hide) for the GUI as all device type don't
945 * use the same ui. elements.
947 void CaptureOpenPanel::updateButtons()
949 /* Be sure to display the ui Elements in case they were hidden by
950 * some Device Type (like Screen://) */
951 ui.optionsBox->show();
952 ui.advancedButton->show();
953 /* Get the current Device Number */
954 int i_devicetype = ui.deviceCombo->itemData(
955 ui.deviceCombo->currentIndex() ).toInt();
956 msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
957 switch( i_devicetype )
960 if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
961 if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
964 if( bdas->isChecked() || bdac->isChecked() )
967 bdaSrateLabel->show();
969 bdaBandLabel->hide();
974 bdaSrateLabel->hide();
976 bdaBandLabel->show();
980 ui.optionsBox->hide();
981 ui.advancedButton->hide();