qt4: allow dnd to file-input on convert-dialog
[vlc/asuraparaju-public.git] / modules / gui / qt4 / components / open_panels.cpp
blob61c397ffe75236d161d0b44c8de0a6d6ca0761de
1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006-2009 the VideoLAN team
5 * Copyright (C) 2007 Société des arts technologiques
6 * Copyright (C) 2007 Savoir-faire Linux
8 * $Id$
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 *****************************************************************************/
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
33 #include "qt4.hpp"
34 #include "components/open_panels.hpp"
35 #include "dialogs/open.hpp"
36 #include "dialogs_provider.hpp" /* Open Subtitle file */
37 #include "util/qt_dirs.hpp"
38 #include <vlc_intf_strings.h>
40 #include <QFileDialog>
41 #include <QDialogButtonBox>
42 #include <QLineEdit>
43 #include <QStackedLayout>
44 #include <QListView>
45 #include <QCompleter>
46 #include <QDirModel>
47 #include <QScrollArea>
48 #include <QUrl>
49 #include <QStringListModel>
50 #include <QDropEvent>
53 #define I_DEVICE_TOOLTIP \
54 I_DIR_OR_FOLDER( N_("Select a device or a VIDEO_TS directory"), \
55 N_("Select a device or a VIDEO_TS folder") )
57 static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
58 "dshow", "screen", "jack" };
60 /**************************************************************************
61 * Open Files and subtitles *
62 **************************************************************************/
63 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
64 OpenPanel( _parent, _p_intf ), dialogBox( NULL )
66 /* Classic UI Setup */
67 ui.setupUi( this );
69 setAcceptDrops( true );
71 /* Set Filters for file selection */
72 /* QString fileTypes = "";
73 ADD_FILTER_MEDIA( fileTypes );
74 ADD_FILTER_VIDEO( fileTypes );
75 ADD_FILTER_AUDIO( fileTypes );
76 ADD_FILTER_PLAYLIST( fileTypes );
77 ADD_FILTER_ALL( fileTypes );
78 fileTypes.replace( QString(";*"), QString(" *")); */
81 /* lineFileEdit = ui.fileEdit;
82 //TODO later: fill the fileCompleteList with previous items played.
83 QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
84 fileCompleter->setModel( new QDirModel( fileCompleter ) );
85 lineFileEdit->setCompleter( fileCompleter );*/
86 if( var_InheritBool( p_intf, "qt-embedded-open" ) )
88 ui.tempWidget->hide();
89 BuildOldPanel();
92 /* Subtitles */
93 /* Deactivate the subtitles control by default. */
94 ui.subFrame->setEnabled( false );
95 /* Build the subs size combo box */
96 setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
97 ui.sizeSubComboBox );
98 /* Build the subs align combo box */
99 setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
101 /* Connects */
102 BUTTONACT( ui.fileBrowseButton, browseFile() );
103 BUTTONACT( ui.removeFileButton, removeFile() );
105 BUTTONACT( ui.subBrowseButton, browseFileSub() );
106 CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
108 CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
109 CONNECT( ui.subInput, textChanged( const QString& ), this, updateMRL() );
110 CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
111 CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
112 updateButtons();
115 inline void FileOpenPanel::BuildOldPanel()
117 /** BEGIN QFileDialog tweaking **/
118 /* Use a QFileDialog and customize it because we don't want to
119 rewrite it all. Be careful to your eyes cause there are a few hacks.
120 Be very careful and test correctly when you modify this. */
122 /* Make this QFileDialog a child of tempWidget from the ui. */
123 dialogBox = new FileOpenBox( ui.tempWidget, NULL,
124 p_intf->p_sys->filepath, "" );
126 dialogBox->setFileMode( QFileDialog::ExistingFiles );
127 dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
128 dialogBox->restoreState(
129 getSettings()->value( "file-dialog-state" ).toByteArray() );
131 /* We don't want to see a grip in the middle of the window, do we? */
132 dialogBox->setSizeGripEnabled( false );
134 /* Add a tooltip */
135 dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
136 dialogBox->setMinimumHeight( 250 );
138 // But hide the two OK/Cancel buttons. Enable them for debug.
139 QDialogButtonBox *fileDialogAcceptBox =
140 dialogBox->findChildren<QDialogButtonBox*>()[0];
141 fileDialogAcceptBox->hide();
143 /* Ugly hacks to get the good Widget */
144 //This lineEdit is the normal line in the fileDialog.
145 QLineEdit *lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
146 /* Make a list of QLabel inside the QFileDialog to access the good ones */
147 QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
149 /* Hide the FileNames one. Enable it for debug */
150 listLabel[1]->setText( qtr( "File names:" ) );
151 /* Change the text that was uncool in the usual box */
152 listLabel[2]->setText( qtr( "Filter:" ) );
154 dialogBox->layout()->setMargin( 0 );
155 dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
157 /** END of QFileDialog tweaking **/
159 // Add the DialogBox to the layout
160 ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 );
162 CONNECT( lineFileEdit, textChanged( const QString& ), this, updateMRL() );
163 dialogBox->installEventFilter( this );
166 FileOpenPanel::~FileOpenPanel()
168 if( dialogBox )
169 getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
172 void FileOpenPanel::dragEnterEvent( QDragEnterEvent *event )
174 event->acceptProposedAction();
177 void FileOpenPanel::dragMoveEvent( QDragMoveEvent *event )
179 event->acceptProposedAction();
182 void FileOpenPanel::dragLeaveEvent( QDragLeaveEvent *event )
184 event->accept();
187 void FileOpenPanel::dropEvent( QDropEvent *event )
189 if( event->possibleActions() & Qt::CopyAction )
190 event->setDropAction( Qt::CopyAction );
191 else
192 return;
194 const QMimeData *mimeData = event->mimeData();
195 foreach( const QUrl &url, mimeData->urls() )
197 if( url.isValid() )
199 QListWidgetItem *item = new QListWidgetItem(
200 toNativeSeparators( url.toLocalFile() ),
201 ui.fileListWidg );
202 item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
203 ui.fileListWidg->addItem( item );
206 updateMRL();
207 updateButtons();
208 event->accept();
211 void FileOpenPanel::browseFile()
213 QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ;
214 foreach( const QString &file, files )
216 QListWidgetItem *item =
217 new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg );
218 item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
219 ui.fileListWidg->addItem( item );
220 savedirpathFromFile( file );
222 updateButtons();
223 updateMRL();
226 void FileOpenPanel::removeFile()
228 int i = ui.fileListWidg->currentRow();
229 if( i != -1 )
231 QListWidgetItem *temp = ui.fileListWidg->takeItem( i );
232 delete temp;
235 updateMRL();
236 updateButtons();
239 /* Show a fileBrowser to select a subtitle */
240 void FileOpenPanel::browseFileSub()
242 // TODO Handle selection of more than one subtitles file
243 QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
244 EXT_FILTER_SUBTITLE, p_intf->p_sys->filepath );
246 if( files.isEmpty() ) return;
247 ui.subInput->setText( toNativeSeparators( files.join(" ") ) );
248 updateMRL();
251 void FileOpenPanel::toggleSubtitleFrame( bool b )
253 ui.subFrame->setEnabled( b );
255 /* Update the MRL */
256 updateMRL();
260 /* Update the current MRL */
261 void FileOpenPanel::updateMRL()
263 QStringList fileList;
264 QString mrl;
266 /* File Listing */
267 if( dialogBox == NULL )
268 for( int i = 0; i < ui.fileListWidg->count(); i++ )
270 if( !ui.fileListWidg->item( i )->text().isEmpty() )
271 fileList << ui.fileListWidg->item( i )->text();
273 else
274 fileList = dialogBox->selectedFiles();
276 /* Options */
277 if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) {
278 mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
279 int align = ui.alignSubComboBox->itemData(
280 ui.alignSubComboBox->currentIndex() ).toInt();
281 mrl.append( " :subsdec-align=" + QString().setNum( align ) );
282 int size = ui.sizeSubComboBox->itemData(
283 ui.sizeSubComboBox->currentIndex() ).toInt();
284 mrl.append( " :freetype-rel-fontsize=" + QString().setNum( size ) );
287 emit mrlUpdated( fileList, mrl );
288 emit methodChanged( "file-caching" );
291 /* Function called by Open Dialog when clicke on Play/Enqueue */
292 void FileOpenPanel::accept()
294 if( dialogBox )
295 p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
296 ui.fileListWidg->clear();
299 /* Function called by Open Dialog when clicked on cancel */
300 void FileOpenPanel::clear()
302 ui.fileListWidg->clear();
303 ui.subInput->clear();
306 /* Update buttons depending on current selection */
307 void FileOpenPanel::updateButtons()
309 bool b_has_files = ( ui.fileListWidg->count() > 0 );
310 ui.removeFileButton->setEnabled( b_has_files );
311 ui.subCheckBox->setEnabled( b_has_files );
314 /**************************************************************************
315 * Open Discs ( DVD, CD, VCD and similar devices ) *
316 **************************************************************************/
317 DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
318 OpenPanel( _parent, _p_intf )
320 ui.setupUi( this );
322 /* Get the default configuration path for the devices */
323 psz_dvddiscpath = var_InheritString( p_intf, "dvd" );
324 psz_vcddiscpath = var_InheritString( p_intf, "vcd" );
325 psz_cddadiscpath = var_InheritString( p_intf, "cd-audio" );
327 /* State to avoid overwritting the users changes with the configuration */
328 b_firstdvd = true;
329 b_firstvcd = true;
330 b_firstcdda = true;
332 ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
333 ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
335 #ifdef WIN32 /* Disc drives probing for Windows */
336 char szDrives[512];
337 szDrives[0] = '\0';
338 if( GetLogicalDriveStringsA( sizeof( szDrives ) - 1, szDrives ) )
340 char *drive = szDrives;
341 UINT oldMode = SetErrorMode( SEM_FAILCRITICALERRORS );
342 while( *drive )
344 if( GetDriveTypeA(drive) == DRIVE_CDROM )
345 ui.deviceCombo->addItem( drive );
347 /* go to next drive */
348 while( *(drive++) );
350 SetErrorMode(oldMode);
352 #else /* Use a Completer under Linux */
353 QCompleter *discCompleter = new QCompleter( this );
354 discCompleter->setModel( new QDirModel( discCompleter ) );
355 ui.deviceCombo->setCompleter( discCompleter );
356 #endif
358 /* CONNECTs */
359 BUTTONACT( ui.dvdRadioButton, updateButtons() );
360 BUTTONACT( ui.vcdRadioButton, updateButtons() );
361 BUTTONACT( ui.audioCDRadioButton, updateButtons() );
362 BUTTONACT( ui.dvdsimple, updateButtons() );
363 BUTTONACT( ui.browseDiscButton, browseDevice() );
364 BUTTON_SET_ACT_I( ui.ejectButton, "", toolbar/eject, qtr( "Eject the disc" ),
365 eject() );
367 CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
368 CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
369 CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
370 CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
371 CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
373 /* Run once the updateButtons function in order to fill correctly the comboBoxes */
374 updateButtons();
377 DiscOpenPanel::~DiscOpenPanel()
379 free( psz_dvddiscpath );
380 free( psz_vcddiscpath );
381 free( psz_cddadiscpath );
384 void DiscOpenPanel::clear()
386 ui.titleSpin->setValue( 0 );
387 ui.chapterSpin->setValue( 0 );
388 ui.subtitlesSpin->setValue( -1 );
389 ui.audioSpin->setValue( -1 );
390 b_firstcdda = true;
391 b_firstdvd = true;
392 b_firstvcd = true;
395 #ifdef WIN32
396 #define setDrive( psz_name ) {\
397 int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
398 if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
399 #else
400 #define setDrive( psz_name ) {\
401 ui.deviceCombo->setEditText( qfu( psz_name ) ); }
402 #endif
404 /* update the buttons according the type of device */
405 void DiscOpenPanel::updateButtons()
407 if ( ui.dvdRadioButton->isChecked() )
409 if( b_firstdvd )
411 setDrive( psz_dvddiscpath );
412 b_firstdvd = false;
414 ui.titleLabel->setText( qtr("Title") );
415 ui.chapterLabel->show();
416 ui.chapterSpin->show();
417 ui.diskOptionBox_2->show();
418 ui.dvdsimple->setEnabled( true );
420 else if ( ui.vcdRadioButton->isChecked() )
422 if( b_firstvcd )
424 setDrive( psz_vcddiscpath );
425 b_firstvcd = false;
427 ui.titleLabel->setText( qtr("Entry") );
428 ui.chapterLabel->hide();
429 ui.chapterSpin->hide();
430 ui.diskOptionBox_2->show();
431 ui.dvdsimple->setEnabled( false );
433 else /* CDDA */
435 if( b_firstcdda )
437 setDrive( psz_cddadiscpath );
438 b_firstcdda = false;
440 ui.titleLabel->setText( qtr("Track") );
441 ui.chapterLabel->hide();
442 ui.chapterSpin->hide();
443 ui.diskOptionBox_2->hide();
444 ui.dvdsimple->setEnabled( false );
447 updateMRL();
450 #undef setDrive
452 /* Update the current MRL */
453 void DiscOpenPanel::updateMRL()
455 QString mrl = "";
456 QStringList fileList;
458 /* CDDAX and VCDX not implemented. TODO ? No. */
459 /* DVD */
460 if( ui.dvdRadioButton->isChecked() ) {
461 if( !ui.dvdsimple->isChecked() )
462 mrl = "dvd://";
463 else
464 mrl = "dvdsimple://";
465 mrl += ui.deviceCombo->currentText();
466 if( !ui.dvdsimple->isChecked() )
467 emit methodChanged( "dvdnav-caching" );
468 else
469 emit methodChanged( "dvdread-caching" );
471 if ( ui.titleSpin->value() > 0 ) {
472 mrl += QString("@%1").arg( ui.titleSpin->value() );
473 if ( ui.chapterSpin->value() > 0 ) {
474 mrl+= QString(":%1").arg( ui.chapterSpin->value() );
478 /* VCD */
479 } else if ( ui.vcdRadioButton->isChecked() ) {
480 mrl = "vcd://" + ui.deviceCombo->currentText();
481 emit methodChanged( "vcd-caching" );
483 if( ui.titleSpin->value() > 0 ) {
484 mrl += QString("@E%1").arg( ui.titleSpin->value() );
487 /* CDDA */
488 } else {
489 mrl = "cdda://" + ui.deviceCombo->currentText();
490 emit methodChanged( "cdda-caching" );
493 fileList << mrl; mrl = "";
495 if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
497 if ( ui.audioSpin->value() >= 0 ) {
498 mrl += " :audio-track=" +
499 QString("%1").arg( ui.audioSpin->value() );
501 if ( ui.subtitlesSpin->value() >= 0 ) {
502 mrl += " :sub-track=" +
503 QString("%1").arg( ui.subtitlesSpin->value() );
506 else
508 if( ui.titleSpin->value() > 0 )
509 mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
511 emit mrlUpdated( fileList, mrl );
514 void DiscOpenPanel::browseDevice()
516 QString dir = QFileDialog::getExistingDirectory( this,
517 qtr( I_DEVICE_TOOLTIP ) );
518 if (!dir.isEmpty())
519 ui.deviceCombo->setEditText( toNativeSepNoSlash( dir ) );
521 updateMRL();
524 void DiscOpenPanel::eject()
526 intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
529 void DiscOpenPanel::accept()
532 /**************************************************************************
533 * Open Network streams and URL pages *
534 **************************************************************************/
535 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
536 OpenPanel( _parent, _p_intf )
538 ui.setupUi( this );
540 /* CONNECTs */
541 CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
543 if( var_InheritBool( p_intf, "qt-recentplay" ) )
545 mrlList = new QStringListModel(
546 getSettings()->value( "Open/netMRL" ).toStringList() );
547 QCompleter *completer = new QCompleter( mrlList, this );
548 ui.urlText->setCompleter( completer );
550 CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
552 else
553 mrlList = NULL;
556 NetOpenPanel::~NetOpenPanel()
558 if( !mrlList ) return;
560 QStringList tempL = mrlList->stringList();
561 while( tempL.size() > 8 ) tempL.removeFirst();
563 getSettings()->setValue( "Open/netMRL", tempL );
565 delete mrlList;
568 void NetOpenPanel::clear()
571 static int strcmp_void( const void *k, const void *e )
573 return strcmp( (const char *)k, (const char *)e );
576 void NetOpenPanel::updateMRL()
578 static const struct caching_map
580 char proto[6];
581 char caching[6];
582 } schemes[] =
583 { /* KEEP alphabetical order on first column!! */
584 { "dccp", "rtp" },
585 { "ftp", "ftp" },
586 { "ftps", "ftp" },
587 { "http", "http" },
588 { "https", "http" },
589 { "mms", "mms" },
590 { "mmsh", "mms" },
591 { "mmst", "mms" },
592 { "mmsu", "mms" },
593 { "sftp", "sftp" },
594 { "smb", "smb" },
595 { "rtmp", "rtmp" },
596 { "rtp", "rtp" },
597 { "rtsp", "rtsp" },
598 { "udp", "udp" },
601 QString url = ui.urlText->text();
602 if( !url.contains( "://") )
603 return; /* nothing to do this far */
605 /* Match the correct item in the comboBox */
606 QString proto = url.section( ':', 0, 0 );
607 const struct caching_map *r = (const struct caching_map *)
608 bsearch( qtu(proto), schemes, sizeof(schemes) / sizeof(schemes[0]),
609 sizeof(schemes[0]), strcmp_void );
610 if( r )
611 emit methodChanged( qfu( r->caching ) + qfu( "-caching" ) );
613 QStringList qsl;
614 qsl << url;
615 emit mrlUpdated( qsl, "" );
618 void NetOpenPanel::updateCompleter()
620 assert( mrlList );
621 QStringList tempL = mrlList->stringList();
622 if( !tempL.contains( ui.urlText->text() ) )
623 tempL.append( ui.urlText->text() );
624 mrlList->setStringList( tempL );
627 /**************************************************************************
628 * Open Capture device ( DVB, PVR, V4L, and similar ) *
629 **************************************************************************/
630 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
631 OpenPanel( _parent, _p_intf )
633 isInitialized = false;
636 void CaptureOpenPanel::initialize()
638 if( isInitialized ) return;
640 msg_Dbg( p_intf, "Initialization of Capture device panel" );
641 isInitialized = true;
643 ui.setupUi( this );
645 BUTTONACT( ui.advancedButton, advancedDialog() );
647 /* Create two stacked layouts in the main comboBoxes */
648 QStackedLayout *stackedDevLayout = new QStackedLayout;
649 ui.cardBox->setLayout( stackedDevLayout );
651 QStackedLayout *stackedPropLayout = new QStackedLayout;
652 ui.optionsBox->setLayout( stackedPropLayout );
654 /* Creation and connections of the WIdgets in the stacked layout */
655 #define addModuleAndLayouts( number, name, label, layout ) \
656 QWidget * name ## DevPage = new QWidget( this ); \
657 QWidget * name ## PropPage = new QWidget( this ); \
658 stackedDevLayout->addWidget( name ## DevPage ); \
659 stackedPropLayout->addWidget( name ## PropPage ); \
660 layout * name ## DevLayout = new layout; \
661 layout * name ## PropLayout = new layout; \
662 name ## DevPage->setLayout( name ## DevLayout ); \
663 name ## PropPage->setLayout( name ## PropLayout ); \
664 ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
666 #define CuMRL( widget, slot ) CONNECT( widget , slot , this, updateMRL() );
668 #ifdef WIN32
669 /*********************
670 * DirectShow Stuffs *
671 *********************/
672 if( module_exists( "dshow" ) ){
673 addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow", QGridLayout );
675 /* dshow Main */
676 int line = 0;
677 module_config_t *p_config =
678 config_FindConfig( VLC_OBJECT(p_intf), "dshow-vdev" );
679 vdevDshowW = new StringListConfigControl(
680 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
681 line++;
683 p_config = config_FindConfig( VLC_OBJECT(p_intf), "dshow-adev" );
684 adevDshowW = new StringListConfigControl(
685 VLC_OBJECT(p_intf), p_config, this, false, dshowDevLayout, line );
686 line++;
688 /* dshow Properties */
689 QLabel *dshowVSizeLabel = new QLabel( qtr( "Video size" ) );
690 dshowPropLayout->addWidget( dshowVSizeLabel, 0, 0 );
692 dshowVSizeLine = new QLineEdit;
693 dshowPropLayout->addWidget( dshowVSizeLine, 0, 1);
694 dshowPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
695 1, 0, 3, 1 );
697 /* dshow CONNECTs */
698 CuMRL( vdevDshowW->combo, currentIndexChanged ( int ) );
699 CuMRL( adevDshowW->combo, currentIndexChanged ( int ) );
700 CuMRL( dshowVSizeLine, textChanged( const QString& ) );
703 /**************
704 * BDA Stuffs *
705 **************/
706 if( module_exists( "bda" ) ){
707 addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow", QGridLayout );
709 /* bda Main */
710 QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
712 bdas = new QRadioButton( "DVB-S" );
713 bdas->setChecked( true );
714 bdac = new QRadioButton( "DVB-C" );
715 bdat = new QRadioButton( "DVB-T" );
716 bdaa = new QRadioButton( "ATSC" );
718 bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
719 bdaDevLayout->addWidget( bdas, 0, 1 );
720 bdaDevLayout->addWidget( bdac, 0, 2 );
721 bdaDevLayout->addWidget( bdat, 0, 3 );
722 bdaDevLayout->addWidget( bdaa, 0, 4 );
724 /* bda Props */
725 QLabel *bdaFreqLabel =
726 new QLabel( qtr( "Transponder/multiplex frequency" ) );
727 bdaPropLayout->addWidget( bdaFreqLabel, 0, 0 );
729 bdaFreq = new QSpinBox;
730 bdaFreq->setAlignment( Qt::AlignRight );
731 bdaFreq->setSuffix(" kHz");
732 bdaFreq->setSingleStep( 1000 );
733 setSpinBoxFreq( bdaFreq )
734 bdaPropLayout->addWidget( bdaFreq, 0, 1 );
736 bdaSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
737 bdaPropLayout->addWidget( bdaSrateLabel, 1, 0 );
739 bdaSrate = new QSpinBox;
740 bdaSrate->setAlignment( Qt::AlignRight );
741 bdaSrate->setSuffix(" kHz");
742 setSpinBoxFreq( bdaSrate );
743 bdaPropLayout->addWidget( bdaSrate, 1, 1 );
745 bdaBandLabel = new QLabel( qtr( "Bandwidth" ) );
746 bdaPropLayout->addWidget( bdaBandLabel, 2, 0 );
748 bdaBandBox = new QComboBox;
749 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
750 bdaPropLayout->addWidget( bdaBandBox, 2, 1 );
752 bdaBandLabel->hide();
753 bdaBandBox->hide();
754 bdaPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
755 2, 0, 2, 1 );
757 /* bda CONNECTs */
758 CuMRL( bdaFreq, valueChanged ( int ) );
759 CuMRL( bdaSrate, valueChanged ( int ) );
760 CuMRL( bdaBandBox, currentIndexChanged ( int ) );
761 BUTTONACT( bdas, updateButtons() );
762 BUTTONACT( bdat, updateButtons() );
763 BUTTONACT( bdac, updateButtons() );
764 BUTTONACT( bdaa, updateButtons() );
765 BUTTONACT( bdas, updateMRL() );
766 BUTTONACT( bdat, updateMRL() );
767 BUTTONACT( bdac, updateMRL() );
768 BUTTONACT( bdaa, updateMRL() );
771 #else /* WIN32 */
772 /*******
773 * V4L2*
774 *******/
775 if( module_exists( "v4l2" ) ){
776 addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2", QGridLayout );
778 /* V4l Main panel */
779 QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
780 v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
782 v4l2VideoDevice = new QLineEdit;
783 v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
785 QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
786 v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
788 v4l2AudioDevice = new QLineEdit;
789 v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
791 /* v4l2 Props panel */
792 QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
793 v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
795 v4l2StdBox = new QComboBox;
796 setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
797 v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
798 v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
799 1, 0, 3, 1 );
801 /* v4l2 CONNECTs */
802 CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
803 CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
804 CuMRL( v4l2StdBox, currentIndexChanged ( int ) );
807 /*******
808 * V4L *
809 *******/
810 if( module_exists( "v4l" ) ){
811 addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux", QGridLayout );
813 /* V4l Main panel */
814 QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
815 v4lDevLayout->addWidget( v4lVideoDeviceLabel, 0, 0 );
817 v4lVideoDevice = new QLineEdit;
818 v4lDevLayout->addWidget( v4lVideoDevice, 0, 1 );
820 QLabel *v4lAudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
821 v4lDevLayout->addWidget( v4lAudioDeviceLabel, 1, 0 );
823 v4lAudioDevice = new QLineEdit;
824 v4lDevLayout->addWidget( v4lAudioDevice, 1, 1 );
826 /* V4l Props panel */
827 QLabel *v4lNormLabel = new QLabel( qtr( "Norm" ) );
828 v4lPropLayout->addWidget( v4lNormLabel, 0 , 0 );
830 v4lNormBox = new QComboBox;
831 setfillVLCConfigCombo( "v4l-norm", p_intf, v4lNormBox );
832 v4lPropLayout->addWidget( v4lNormBox, 0 , 1 );
834 QLabel *v4lFreqLabel = new QLabel( qtr( "Frequency" ) );
835 v4lPropLayout->addWidget( v4lFreqLabel, 1 , 0 );
837 v4lFreq = new QSpinBox;
838 v4lFreq->setAlignment( Qt::AlignRight );
839 v4lFreq->setSuffix(" kHz");
840 setSpinBoxFreq( v4lFreq );
841 v4lPropLayout->addWidget( v4lFreq, 1 , 1 );
842 v4lPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
843 2, 0, 2, 1 );
845 /* v4l CONNECTs */
846 CuMRL( v4lVideoDevice, textChanged( const QString& ) );
847 CuMRL( v4lAudioDevice, textChanged( const QString& ) );
848 CuMRL( v4lFreq, valueChanged ( int ) );
849 CuMRL( v4lNormBox, currentIndexChanged ( int ) );
852 /*******
853 * JACK *
854 *******/
855 if( module_exists( "jack" ) ){
856 addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit",
857 QGridLayout);
859 /* Jack Main panel */
860 /* Channels */
861 QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
862 jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
864 jackChannels = new QSpinBox;
865 setSpinBoxFreq( jackChannels );
866 jackChannels->setMaximum(255);
867 jackChannels->setValue(2);
868 jackChannels->setAlignment( Qt::AlignRight );
869 jackDevLayout->addWidget( jackChannels, 1, 1 );
871 /* Selected ports */
872 QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
873 jackDevLayout->addWidget( jackPortsLabel, 0 , 0 );
875 jackPortsSelected = new QLineEdit( qtr( ".*") );
876 jackPortsSelected->setAlignment( Qt::AlignRight );
877 jackDevLayout->addWidget( jackPortsSelected, 0, 1 );
879 /* Jack Props panel */
881 /* Caching */
882 QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
883 jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
884 jackCaching = new QSpinBox;
885 setSpinBoxFreq( jackCaching );
886 jackCaching->setSuffix( " ms" );
887 jackCaching->setValue(1000);
888 jackCaching->setAlignment( Qt::AlignRight );
889 jackPropLayout->addWidget( jackCaching, 1 , 2 );
891 /* Pace */
892 jackPace = new QCheckBox(qtr( "Use VLC pace" ));
893 jackPropLayout->addWidget( jackPace, 2, 1 );
895 /* Auto Connect */
896 jackConnect = new QCheckBox( qtr( "Auto connnection" ));
897 jackPropLayout->addWidget( jackConnect, 2, 2 );
899 /* Jack CONNECTs */
900 CuMRL( jackChannels, valueChanged( int ) );
901 CuMRL( jackCaching, valueChanged( int ) );
902 CuMRL( jackPace, stateChanged( int ) );
903 CuMRL( jackConnect, stateChanged( int ) );
904 CuMRL( jackPortsSelected, textChanged( const QString& ) );
907 /************
908 * PVR *
909 ************/
910 if( module_exists( "pvr" ) ){
911 addModuleAndLayouts( PVR_DEVICE, pvr, "PVR", QGridLayout );
913 /* PVR Main panel */
914 QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
915 pvrDevLayout->addWidget( pvrDeviceLabel, 0, 0 );
917 pvrDevice = new QLineEdit;
918 pvrDevLayout->addWidget( pvrDevice, 0, 1 );
920 QLabel *pvrRadioDeviceLabel = new QLabel( qtr( "Radio device name" ) );
921 pvrDevLayout->addWidget( pvrRadioDeviceLabel, 1, 0 );
923 pvrRadioDevice = new QLineEdit;
924 pvrDevLayout->addWidget( pvrRadioDevice, 1, 1 );
926 /* PVR props panel */
927 QLabel *pvrNormLabel = new QLabel( qtr( "Norm" ) );
928 pvrPropLayout->addWidget( pvrNormLabel, 0, 0 );
930 pvrNormBox = new QComboBox;
931 setfillVLCConfigCombo( "pvr-norm", p_intf, pvrNormBox );
932 pvrPropLayout->addWidget( pvrNormBox, 0, 1 );
934 QLabel *pvrFreqLabel = new QLabel( qtr( "Frequency" ) );
935 pvrPropLayout->addWidget( pvrFreqLabel, 1, 0 );
937 pvrFreq = new QSpinBox;
938 pvrFreq->setAlignment( Qt::AlignRight );
939 pvrFreq->setSuffix(" kHz");
940 setSpinBoxFreq( pvrFreq );
941 pvrPropLayout->addWidget( pvrFreq, 1, 1 );
943 QLabel *pvrBitrLabel = new QLabel( qtr( "Bitrate" ) );
944 pvrPropLayout->addWidget( pvrBitrLabel, 2, 0 );
946 pvrBitr = new QSpinBox;
947 pvrBitr->setAlignment( Qt::AlignRight );
948 pvrBitr->setSuffix(" kHz");
949 setSpinBoxFreq( pvrBitr );
950 pvrPropLayout->addWidget( pvrBitr, 2, 1 );
951 pvrPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
952 3, 0, 1, 1 );
954 /* PVR CONNECTs */
955 CuMRL( pvrDevice, textChanged( const QString& ) );
956 CuMRL( pvrRadioDevice, textChanged( const QString& ) );
958 CuMRL( pvrFreq, valueChanged ( int ) );
959 CuMRL( pvrBitr, valueChanged ( int ) );
960 CuMRL( pvrNormBox, currentIndexChanged ( int ) );
963 /**************
964 * DVB Stuffs *
965 **************/
966 if( module_exists( "dvb" ) ){
967 addModuleAndLayouts( DVB_DEVICE, dvb, "DVB", QGridLayout );
969 /* DVB Main */
970 QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
971 QLabel *dvbTypeLabel = new QLabel( qtr( "DVB Type:" ) );
973 dvbCard = new QSpinBox;
974 dvbCard->setAlignment( Qt::AlignRight );
975 dvbCard->setPrefix( "/dev/dvb/adapter" );
977 dvbDevLayout->addWidget( dvbDeviceLabel, 0, 0 );
978 dvbDevLayout->addWidget( dvbCard, 0, 2, 1, 2 );
980 dvbs = new QRadioButton( "DVB-S" );
981 dvbs->setChecked( true );
982 dvbc = new QRadioButton( "DVB-C" );
983 dvbt = new QRadioButton( "DVB-T" );
985 dvbDevLayout->addWidget( dvbTypeLabel, 1, 0 );
986 dvbDevLayout->addWidget( dvbs, 1, 1 );
987 dvbDevLayout->addWidget( dvbc, 1, 2 );
988 dvbDevLayout->addWidget( dvbt, 1, 3 );
990 /* DVB Props panel */
991 QLabel *dvbFreqLabel =
992 new QLabel( qtr( "Transponder/multiplex frequency" ) );
993 dvbPropLayout->addWidget( dvbFreqLabel, 0, 0 );
995 dvbFreq = new QSpinBox;
996 dvbFreq->setAlignment( Qt::AlignRight );
997 dvbFreq->setSuffix(" kHz");
998 dvbFreq->setSingleStep( 1000 );
999 setSpinBoxFreq( dvbFreq );
1000 dvbPropLayout->addWidget( dvbFreq, 0, 1 );
1002 dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
1003 dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
1005 dvbSrate = new QSpinBox;
1006 dvbSrate->setAlignment( Qt::AlignRight );
1007 dvbSrate->setSuffix(" kHz");
1008 setSpinBoxFreq( dvbSrate );
1009 dvbPropLayout->addWidget( dvbSrate, 1, 1 );
1011 dvbBandLabel = new QLabel( qtr( "Bandwidth" ) );
1012 dvbPropLayout->addWidget( dvbBandLabel, 2, 0 );
1014 dvbBandBox = new QComboBox;
1015 /* This doesn't work since dvb-bandwidth doesn't seem to be a
1016 list of Integers
1017 setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
1019 dvbBandBox->addItem( qtr( "Auto" ), 0 );
1020 dvbBandBox->addItem( qtr( "6 MHz" ), 6 );
1021 dvbBandBox->addItem( qtr( "7 MHz" ), 7 );
1022 dvbBandBox->addItem( qtr( "8 MHz" ), 8 );
1023 dvbPropLayout->addWidget( dvbBandBox, 2, 1 );
1025 dvbBandLabel->hide();
1026 dvbBandBox->hide();
1028 dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
1029 2, 0, 2, 1 );
1031 /* DVB CONNECTs */
1032 CuMRL( dvbCard, valueChanged ( int ) );
1033 CuMRL( dvbFreq, valueChanged ( int ) );
1034 CuMRL( dvbSrate, valueChanged ( int ) );
1035 CuMRL( dvbBandBox, currentIndexChanged ( int ) );
1037 BUTTONACT( dvbs, updateButtons() );
1038 BUTTONACT( dvbt, updateButtons() );
1039 BUTTONACT( dvbc, updateButtons() );
1040 BUTTONACT( dvbs, updateMRL() );
1041 BUTTONACT( dvbt, updateMRL() );
1042 BUTTONACT( dvbc, updateMRL() );
1045 #endif
1048 /**********
1049 * Screen *
1050 **********/
1051 addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop", QGridLayout );
1052 QLabel *screenLabel = new QLabel( qtr( "Your display will be "
1053 "opened and played in order to stream or save it." ) );
1054 screenLabel->setWordWrap( true );
1055 screenDevLayout->addWidget( screenLabel, 0, 0 );
1057 QLabel *screenFPSLabel = new QLabel(
1058 qtr( "Desired frame rate for the capture." ) );
1059 screenPropLayout->addWidget( screenFPSLabel, 0, 0 );
1061 screenFPS = new QDoubleSpinBox;
1062 screenFPS->setValue( 1. );
1063 screenFPS->setRange( .01, 100. );
1064 screenFPS->setAlignment( Qt::AlignRight );
1065 /* xgettext: frames per second */
1066 screenFPS->setSuffix( qtr( " f/s" ) );
1067 screenPropLayout->addWidget( screenFPS, 0, 1 );
1069 /* Screen connect */
1070 CuMRL( screenFPS, valueChanged( double ) );
1072 /* General connects */
1073 CONNECT( ui.deviceCombo, activated( int ) ,
1074 stackedDevLayout, setCurrentIndex( int ) );
1075 CONNECT( ui.deviceCombo, activated( int ),
1076 stackedPropLayout, setCurrentIndex( int ) );
1077 CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
1078 CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
1080 #undef CuMRL
1081 #undef addModuleAndLayouts
1084 CaptureOpenPanel::~CaptureOpenPanel()
1088 void CaptureOpenPanel::clear()
1090 advMRL.clear();
1093 void CaptureOpenPanel::updateMRL()
1095 QString mrl = "";
1096 QStringList fileList;
1097 int i_devicetype = ui.deviceCombo->itemData(
1098 ui.deviceCombo->currentIndex() ).toInt();
1099 switch( i_devicetype )
1101 #ifdef WIN32
1102 case BDA_DEVICE:
1103 if( bdas->isChecked() ) mrl = "dvb-s://";
1104 else if( bdat->isChecked() ) mrl = "dvb-t://";
1105 else if( bdac->isChecked() ) mrl = "dvb-c://";
1106 else if( bdaa->isChecked() ) mrl = "atsc://";
1107 else return;
1108 mrl += "frequency=" + QString::number( bdaFreq->value() );
1109 if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked() )
1110 mrl +="000";
1111 fileList << mrl; mrl = "";
1113 if( bdas->isChecked() || bdac->isChecked() )
1114 mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
1115 else if( bdat->isChecked() || bdaa->isChecked() )
1116 mrl += " :dvb-bandwidth=" +
1117 QString::number( bdaBandBox->itemData(
1118 bdaBandBox->currentIndex() ).toInt() );
1119 emit methodChanged( "dvb-caching" );
1120 break;
1121 case DSHOW_DEVICE:
1122 fileList << "dshow://";
1123 mrl+= " :dshow-vdev=" +
1124 colon_escape( QString("%1").arg( vdevDshowW->getValue() ) );
1125 mrl+= " :dshow-adev=" +
1126 colon_escape( QString("%1").arg( adevDshowW->getValue() ) )+" ";
1127 if( dshowVSizeLine->isModified() )
1128 mrl += ":dshow-size=" + dshowVSizeLine->text();
1129 emit methodChanged( "dshow-caching" );
1130 break;
1131 #else
1132 case V4L_DEVICE:
1133 fileList << "v4l://" + v4lVideoDevice->text();
1134 mrl += " :input-slave=alsa://" + v4lAudioDevice->text();
1135 mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
1136 mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
1137 break;
1138 case V4L2_DEVICE:
1139 fileList << "v4l2://" + v4l2VideoDevice->text();
1140 mrl += " :input-slave=alsa://" + v4l2AudioDevice->text();
1141 mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
1142 break;
1143 case JACK_DEVICE:
1144 mrl = "jack://";
1145 mrl += "channels=" + QString::number( jackChannels->value() );
1146 mrl += ":ports=" + jackPortsSelected->text();
1147 fileList << mrl; mrl = "";
1149 mrl += " :jack-input-caching=" + QString::number( jackCaching->value() );
1150 if ( jackPace->isChecked() )
1152 mrl += " :jack-input-use-vlc-pace";
1154 if ( jackConnect->isChecked() )
1156 mrl += " :jack-input-auto-connect";
1158 break;
1159 case PVR_DEVICE:
1160 fileList << "pvr://";
1161 mrl += " :pvr-device=" + pvrDevice->text();
1162 mrl += " :pvr-radio-device=" + pvrRadioDevice->text();
1163 mrl += " :pvr-norm=" + QString::number( pvrNormBox->currentIndex() );
1164 if( pvrFreq->value() )
1165 mrl += " :pvr-frequency=" + QString::number( pvrFreq->value() );
1166 if( pvrBitr->value() )
1167 mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
1168 break;
1169 case DVB_DEVICE:
1170 mrl = "dvb://";
1171 mrl += "frequency=" + QString::number( dvbFreq->value() );
1172 if( dvbc->isChecked() || dvbt->isChecked() )
1173 mrl +="000";
1174 fileList << mrl; mrl= "";
1176 mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
1177 if( dvbs->isChecked() || dvbc->isChecked() )
1178 mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
1179 else if( dvbt->isChecked() )
1180 mrl += " :dvb-bandwidth=" +
1181 QString::number( dvbBandBox->itemData(
1182 dvbBandBox->currentIndex() ).toInt() );
1184 break;
1185 #endif
1186 case SCREEN_DEVICE:
1187 fileList << "screen://";
1188 mrl = " :screen-fps=" + QString::number( screenFPS->value(), 'f' );
1189 emit methodChanged( "screen-caching" );
1190 updateButtons();
1191 break;
1194 if( !advMRL.isEmpty() ) mrl += advMRL;
1196 emit mrlUpdated( fileList, mrl );
1200 * Update the Buttons (show/hide) for the GUI as all device type don't
1201 * use the same ui. elements.
1203 void CaptureOpenPanel::updateButtons()
1205 /* Be sure to display the ui Elements in case they were hidden by
1206 * some Device Type (like Screen://) */
1207 ui.optionsBox->show();
1208 ui.advancedButton->show();
1209 /* Get the current Device Number */
1210 int i_devicetype = ui.deviceCombo->itemData(
1211 ui.deviceCombo->currentIndex() ).toInt();
1212 switch( i_devicetype )
1214 #ifdef WIN32
1215 case BDA_DEVICE:
1216 if( bdas->isChecked() || bdac->isChecked() )
1218 bdaSrate->show();
1219 bdaSrateLabel->show();
1220 bdaBandBox->hide();
1221 bdaBandLabel->hide();
1223 else if( bdat->isChecked() || bdaa->isChecked() )
1225 bdaSrate->hide();
1226 bdaSrateLabel->hide();
1227 bdaBandBox->show();
1228 bdaBandLabel->show();
1230 break;
1231 #else
1232 case DVB_DEVICE:
1233 if( dvbs->isChecked() || dvbc->isChecked() )
1235 dvbSrate->show();
1236 dvbSrateLabel->show();
1237 dvbBandBox->hide();
1238 dvbBandLabel->hide();
1240 else if( dvbt->isChecked() )
1242 dvbSrate->hide();
1243 dvbSrateLabel->hide();
1244 dvbBandBox->show();
1245 dvbBandLabel->show();
1247 break;
1248 #endif
1249 case SCREEN_DEVICE:
1250 //ui.optionsBox->hide();
1251 ui.advancedButton->hide();
1252 break;
1255 advMRL.clear();
1258 void CaptureOpenPanel::advancedDialog()
1260 /* Get selected device type */
1261 int i_devicetype = ui.deviceCombo->itemData(
1262 ui.deviceCombo->currentIndex() ).toInt();
1264 /* Get the corresponding module */
1265 module_t *p_module =
1266 module_find( psz_devModule[i_devicetype] );
1267 if( NULL == p_module ) return;
1269 /* Init */
1270 QList<ConfigControl *> controls;
1272 /* Get the confsize */
1273 unsigned int i_confsize;
1274 module_config_t *p_config;
1275 p_config = module_config_get( p_module, &i_confsize );
1277 /* New Adv Prop dialog */
1278 adv = new QDialog( this );
1279 adv->setWindowTitle( qtr( "Advanced Options" ) );
1280 adv->setWindowRole( "vlc-advanced-options" );
1282 /* A main Layout with a Frame */
1283 QVBoxLayout *mainLayout = new QVBoxLayout( adv );
1284 QScrollArea *scroll = new QScrollArea;
1285 mainLayout->addWidget( scroll );
1287 QFrame *advFrame = new QFrame;
1288 /* GridLayout inside the Frame */
1289 QGridLayout *gLayout = new QGridLayout( advFrame );
1291 scroll->setWidgetResizable( true );
1292 scroll->setWidget( advFrame );
1294 /* Create the options inside the FrameLayout */
1295 for( int n = 0; n < (int)i_confsize; n++ )
1297 module_config_t *p_item = p_config + n;
1298 ConfigControl *config = ConfigControl::createControl(
1299 VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
1300 if ( config )
1301 controls.append( config );
1304 /* Button stuffs */
1305 QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
1306 QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
1307 QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
1309 CONNECT( closeButton, clicked(), adv, accept() );
1310 CONNECT( cancelButton, clicked(), adv, reject() );
1312 advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
1313 advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
1315 mainLayout->addWidget( advButtonBox );
1317 /* Creation of the MRL */
1318 if( adv->exec() )
1320 QString tempMRL = "";
1321 for( int i = 0; i < controls.size(); i++ )
1323 ConfigControl *control = controls[i];
1325 tempMRL += (i ? " :" : ":");
1327 if( control->getType() == CONFIG_ITEM_BOOL )
1328 if( !(qobject_cast<VIntConfigControl *>(control)->getValue() ) )
1329 tempMRL += "no-";
1331 tempMRL += control->getName();
1333 switch( control->getType() )
1335 case CONFIG_ITEM_STRING:
1336 case CONFIG_ITEM_FILE:
1337 case CONFIG_ITEM_DIRECTORY:
1338 case CONFIG_ITEM_MODULE:
1339 tempMRL += colon_escape( QString("=%1").arg( qobject_cast<VStringConfigControl *>(control)->getValue() ) );
1340 break;
1341 case CONFIG_ITEM_INTEGER:
1342 tempMRL += QString("=%1").arg( qobject_cast<VIntConfigControl *>(control)->getValue() );
1343 break;
1344 case CONFIG_ITEM_FLOAT:
1345 tempMRL += QString("=%1").arg( qobject_cast<VFloatConfigControl *>(control)->getValue() );
1346 break;
1349 advMRL = tempMRL;
1350 updateMRL();
1351 msg_Dbg( p_intf, "%s", qtu( advMRL ) );
1353 for( int i = 0; i < controls.size(); i++ )
1355 ConfigControl *control = controls[i];
1356 delete control ;
1358 delete adv;
1359 module_config_free( p_config );
1360 module_release (p_module);