]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open_panels.cpp
CaptureOpenPanel: allow alternative layout
[vlc] / modules / gui / qt4 / components / open_panels.cpp
index 0cbb871306084d38148a91d831d0cd492d21dbd5..94445afca86643d0ac498b016139333882a9243a 100644 (file)
@@ -93,7 +93,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 
     /* Connects  */
     BUTTONACT( ui.fileBrowseButton, browseFile() );
-    BUTTONACT( ui.delFileButton, deleteFile() );
+    BUTTONACT( ui.removeFileButton, removeFile() );
 
     BUTTONACT( ui.subBrowseButton, browseFileSub() );
     CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
@@ -102,6 +102,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CONNECT( ui.subInput, textChanged( const QString& ), this, updateMRL() );
     CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
     CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
+    updateButtons();
 }
 
 inline void FileOpenPanel::BuildOldPanel()
@@ -113,7 +114,7 @@ inline void FileOpenPanel::BuildOldPanel()
 
     /* Make this QFileDialog a child of tempWidget from the ui. */
     dialogBox = new FileOpenBox( ui.tempWidget, NULL,
-            qfu( p_intf->p_sys->psz_filepath ), "" );
+                                 p_intf->p_sys->filepath, "" );
 
     dialogBox->setFileMode( QFileDialog::ExistingFiles );
     dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
@@ -166,14 +167,16 @@ void FileOpenPanel::browseFile()
     QStringList files = QFileDialog::getOpenFileNames( this );
     foreach( const QString &file, files)
     {
-        QListWidgetItem *item = new QListWidgetItem( file, ui.fileListWidg );
+        QListWidgetItem *item =
+            new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg );
         item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled );
         ui.fileListWidg->addItem( item );
     }
+    updateButtons();
     updateMRL();
 }
 
-void FileOpenPanel::deleteFile()
+void FileOpenPanel::removeFile()
 {
     int i = ui.fileListWidg->currentRow();
     if( i != -1 )
@@ -183,6 +186,7 @@ void FileOpenPanel::deleteFile()
     }
 
     updateMRL();
+    updateButtons();
 }
 
 /* Show a fileBrowser to select a subtitle */
@@ -190,10 +194,10 @@ void FileOpenPanel::browseFileSub()
 {
     // TODO Handle selection of more than one subtitles file
     QStringList files = THEDP->showSimpleOpen( qtr("Open subtitles file"),
-                           EXT_FILTER_SUBTITLE, p_intf->p_sys->psz_filepath );
+                           EXT_FILTER_SUBTITLE, p_intf->p_sys->filepath );
 
     if( files.isEmpty() ) return;
-    ui.subInput->setText( files.join(" ") );
+    ui.subInput->setText( toNativeSeparators( files.join(" ") ) );
     updateMRL();
 }
 
@@ -240,8 +244,7 @@ void FileOpenPanel::updateMRL()
 /* Function called by Open Dialog when clicke on Play/Enqueue */
 void FileOpenPanel::accept()
 {
-    //FIXME
- //   p_intf->p_sys->psz_filepath = qtu( dialogBox->directory().absolutePath() );
+    p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
     ui.fileListWidg->clear();
 }
 
@@ -252,6 +255,14 @@ void FileOpenPanel::clear()
     ui.subInput->clear();
 }
 
+/* Update buttons depending on current selection */
+void FileOpenPanel::updateButtons()
+{
+    bool b_has_files = ( ui.fileListWidg->count() > 0 );
+    ui.removeFileButton->setEnabled( b_has_files );
+    ui.subCheckBox->setEnabled( b_has_files );
+}
+
 /**************************************************************************
  * Open Discs ( DVD, CD, VCD and similar devices )                        *
  **************************************************************************/
@@ -388,6 +399,8 @@ void DiscOpenPanel::updateButtons()
     updateMRL();
 }
 
+#undef setDrive
+
 /* Update the current MRL */
 void DiscOpenPanel::updateMRL()
 {
@@ -423,9 +436,6 @@ void DiscOpenPanel::updateMRL()
     /* CDDA */
     } else {
         mrl = "cdda://" + ui.deviceCombo->currentText();
-        if( ui.titleSpin->value() > 0 ) {
-            mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
-        }
     }
 
     fileList << mrl; mrl = "";
@@ -441,6 +451,11 @@ void DiscOpenPanel::updateMRL()
                 QString("%1").arg( ui.subtitlesSpin->value() );
         }
     }
+    else
+    {
+        if( ui.titleSpin->value() > 0 )
+            mrl += QString(" :cdda-track=%1").arg( ui.titleSpin->value() );
+    }
     emit mrlUpdated( fileList, mrl );
 }
 
@@ -509,6 +524,8 @@ NetOpenPanel::~NetOpenPanel()
     while( tempL.size() > 8 ) tempL.removeFirst();
 
     getSettings()->setValue( "Open/netMRL", tempL );
+
+    delete mrlList;
 }
 
 void NetOpenPanel::clear()
@@ -656,13 +673,13 @@ void CaptureOpenPanel::initialize()
     ui.optionsBox->setLayout( stackedPropLayout );
 
     /* Creation and connections of the WIdgets in the stacked layout */
-#define addModuleAndLayouts( number, name, label )                    \
+#define addModuleAndLayouts( number, name, label, layout )            \
     QWidget * name ## DevPage = new QWidget( this );                  \
     QWidget * name ## PropPage = new QWidget( this );                 \
     stackedDevLayout->addWidget( name ## DevPage );        \
     stackedPropLayout->addWidget( name ## PropPage );      \
-    QGridLayout * name ## DevLayout = new QGridLayout;                \
-    QGridLayout * name ## PropLayout = new QGridLayout;               \
+    layout * name ## DevLayout = new layout;                \
+    layout * name ## PropLayout = new layout;               \
     name ## DevPage->setLayout( name ## DevLayout );                  \
     name ## PropPage->setLayout( name ## PropLayout );                \
     ui.deviceCombo->addItem( qtr( label ), QVariant( number ) );
@@ -674,7 +691,7 @@ void CaptureOpenPanel::initialize()
      * DirectShow Stuffs *
      *********************/
     if( module_exists( "dshow" ) ){
-    addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow" );
+    addModuleAndLayouts( DSHOW_DEVICE, dshow, "DirectShow", QGridLayout );
 
     /* dshow Main */
     int line = 0;
@@ -708,7 +725,7 @@ void CaptureOpenPanel::initialize()
      * BDA Stuffs *
      **************/
     if( module_exists( "bda" ) ){
-    addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow" );
+    addModuleAndLayouts( BDA_DEVICE, bda, "DVB DirectShow", QGridLayout );
 
     /* bda Main */
     QLabel *bdaTypeLabel = new QLabel( qtr( "DVB Type:" ) );
@@ -777,7 +794,7 @@ void CaptureOpenPanel::initialize()
      * V4L2*
      *******/
     if( module_exists( "v4l2" ) ){
-    addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2" );
+    addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2", QGridLayout );
 
     /* V4l Main panel */
     QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
@@ -812,7 +829,7 @@ void CaptureOpenPanel::initialize()
      * V4L *
      *******/
     if( module_exists( "v4l" ) ){
-    addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux" );
+    addModuleAndLayouts( V4L_DEVICE, v4l, "Video for Linux", QGridLayout );
 
     /* V4l Main panel */
     QLabel *v4lVideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
@@ -857,7 +874,8 @@ void CaptureOpenPanel::initialize()
      * JACK *
      *******/
     if( module_exists( "jack" ) ){
-    addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit" );
+    addModuleAndLayouts( JACK_DEVICE, jack, "JACK Audio Connection Kit",
+                         QGridLayout);
 
     /* Jack Main panel */
     /* Channels */
@@ -911,7 +929,7 @@ void CaptureOpenPanel::initialize()
      * PVR      *
      ************/
     if( module_exists( "pvr" ) ){
-    addModuleAndLayouts( PVR_DEVICE, pvr, "PVR" );
+    addModuleAndLayouts( PVR_DEVICE, pvr, "PVR", QGridLayout );
 
     /* PVR Main panel */
     QLabel *pvrDeviceLabel = new QLabel( qtr( "Device name" ) );
@@ -967,7 +985,7 @@ void CaptureOpenPanel::initialize()
      * DVB Stuffs *
      **************/
     if( module_exists( "dvb" ) ){
-    addModuleAndLayouts( DVB_DEVICE, dvb, "DVB" );
+    addModuleAndLayouts( DVB_DEVICE, dvb, "DVB", QGridLayout );
 
     /* DVB Main */
     QLabel *dvbDeviceLabel = new QLabel( qtr( "Adapter card to tune" ) );
@@ -998,10 +1016,11 @@ void CaptureOpenPanel::initialize()
     dvbFreq = new QSpinBox;
     dvbFreq->setAlignment( Qt::AlignRight );
     dvbFreq->setSuffix(" kHz");
+    dvbFreq->setSingleStep( 1000 );
     setSpinBoxFreq( dvbFreq  );
     dvbPropLayout->addWidget( dvbFreq, 0, 1 );
 
-    QLabel *dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
+    dvbSrateLabel = new QLabel( qtr( "Transponder symbol rate" ) );
     dvbPropLayout->addWidget( dvbSrateLabel, 1, 0 );
 
     dvbSrate = new QSpinBox;
@@ -1009,6 +1028,24 @@ void CaptureOpenPanel::initialize()
     dvbSrate->setSuffix(" kHz");
     setSpinBoxFreq( dvbSrate );
     dvbPropLayout->addWidget( dvbSrate, 1, 1 );
+
+    dvbBandLabel = new QLabel( qtr( "Bandwidth" ) );
+    dvbPropLayout->addWidget( dvbBandLabel, 2, 0 );
+
+    dvbBandBox = new QComboBox;
+    /* This doesn't work since dvb-bandwidth doesn't seem to be a
+       list of Integers
+       setfillVLCConfigCombo( "dvb-bandwidth", p_intf, bdaBandBox );
+     */
+    dvbBandBox->addItem( qtr( "Auto" ), 0 );
+    dvbBandBox->addItem( qtr( "6 MHz" ), 6 );
+    dvbBandBox->addItem( qtr( "7 MHz" ), 7 );
+    dvbBandBox->addItem( qtr( "8 MHz" ), 8 );
+    dvbPropLayout->addWidget( dvbBandBox, 2, 1 );
+
+    dvbBandLabel->hide();
+    dvbBandBox->hide();
+
     dvbPropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
             2, 0, 2, 1 );
 
@@ -1016,10 +1053,14 @@ void CaptureOpenPanel::initialize()
     CuMRL( dvbCard, valueChanged ( int ) );
     CuMRL( dvbFreq, valueChanged ( int ) );
     CuMRL( dvbSrate, valueChanged ( int ) );
+    CuMRL( dvbBandBox, currentIndexChanged ( int ) );
 
     BUTTONACT( dvbs, updateButtons() );
     BUTTONACT( dvbt, updateButtons() );
     BUTTONACT( dvbc, updateButtons() );
+    BUTTONACT( dvbs, updateMRL() );
+    BUTTONACT( dvbt, updateMRL() );
+    BUTTONACT( dvbc, updateMRL() );
     }
 
 #endif
@@ -1028,9 +1069,9 @@ void CaptureOpenPanel::initialize()
     /**********
      * Screen *
      **********/
-    addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
-    QLabel *screenLabel = new QLabel( "Your display will will be "
-            "opened and played in order to stream or save it." );
+    addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop", QGridLayout );
+    QLabel *screenLabel = new QLabel( qtr( "Your display will be "
+            "opened and played in order to stream or save it." ) );
     screenLabel->setWordWrap( true );
     screenDevLayout->addWidget( screenLabel, 0, 0 );
 
@@ -1043,6 +1084,9 @@ void CaptureOpenPanel::initialize()
     screenFPS->setAlignment( Qt::AlignRight );
     screenPropLayout->addWidget( screenFPS, 0, 1 );
 
+    /* Screen connect */
+    CuMRL( screenFPS, valueChanged( int ) );
+
     /* General connects */
     CONNECT( ui.deviceCombo, activated( int ) ,
              stackedDevLayout, setCurrentIndex( int ) );
@@ -1051,7 +1095,8 @@ void CaptureOpenPanel::initialize()
     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
     CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
 
-#undef addModule
+#undef CuMRL
+#undef addModuleAndLayouts
 }
 
 CaptureOpenPanel::~CaptureOpenPanel()
@@ -1078,12 +1123,14 @@ void CaptureOpenPanel::updateMRL()
         else if(  bdac->isChecked() ) mrl = "dvb-c://";
         else if(  bdaa->isChecked() ) mrl = "atsc://";
         else return;
+        mrl += "frequency=" + QString::number( bdaFreq->value() );
+        if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked() )
+            mrl +="000";
         fileList << mrl; mrl = "";
 
-        mrl += " :dvb-frequency=" + QString::number( bdaFreq->value() );
         if( bdas->isChecked() || bdac->isChecked() )
             mrl += " :dvb-srate=" + QString::number( bdaSrate->value() );
-        else if( bdat->isChecked() )
+        else if( bdat->isChecked() || bdaa->isChecked() )
             mrl += " :dvb-bandwidth=" +
                 QString::number( bdaBandBox->itemData(
                     bdaBandBox->currentIndex() ).toInt() );
@@ -1138,10 +1185,20 @@ void CaptureOpenPanel::updateMRL()
             mrl += " :pvr-bitrate=" + QString::number( pvrBitr->value() );
         break;
     case DVB_DEVICE:
-        fileList << "dvb://";
+        mrl = "dvb://";
+        mrl += "frequency=" + QString::number( dvbFreq->value() );
+        if( dvbc->isChecked() || dvbt->isChecked() )
+            mrl +="000";
+        fileList << mrl; mrl= "";
+
         mrl += " :dvb-adapter=" + QString::number( dvbCard->value() );
-        mrl += " :dvb-frequency=" + QString::number( dvbFreq->value() );
-        mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
+        if( dvbs->isChecked() || dvbc->isChecked() )
+            mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
+        else if( dvbt->isChecked() )
+            mrl += " :dvb-bandwidth=" +
+                QString::number( dvbBandBox->itemData(
+                    dvbBandBox->currentIndex() ).toInt() );
+
         break;
 #endif
     case SCREEN_DEVICE:
@@ -1180,7 +1237,7 @@ void CaptureOpenPanel::updateButtons()
             bdaBandBox->hide();
             bdaBandLabel->hide();
         }
-        else if( bdat->isChecked() )
+        else if( bdat->isChecked() || bdaa->isChecked() )
         {
             bdaSrate->hide();
             bdaSrateLabel->hide();
@@ -1190,8 +1247,20 @@ void CaptureOpenPanel::updateButtons()
         break;
 #else
     case DVB_DEVICE:
-        if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
-        if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
+        if( dvbs->isChecked() || dvbc->isChecked() )
+        {
+            dvbSrate->show();
+            dvbSrateLabel->show();
+            dvbBandBox->hide();
+            dvbBandLabel->hide();
+        }
+        else if( dvbt->isChecked() )
+        {
+            dvbSrate->hide();
+            dvbSrateLabel->hide();
+            dvbBandBox->show();
+            dvbBandLabel->show();
+        }
         break;
 #endif
     case SCREEN_DEVICE:
@@ -1244,7 +1313,8 @@ void CaptureOpenPanel::advancedDialog()
         module_config_t *p_item = p_config + n;
         ConfigControl *config = ConfigControl::createControl(
                         VLC_OBJECT( p_intf ), p_item, advFrame, gLayout, n );
-        controls.append( config );
+        if ( config )
+            controls.append( config );
     }
 
     /* Button stuffs */
@@ -1267,11 +1337,6 @@ void CaptureOpenPanel::advancedDialog()
         for( int i = 0; i < controls.size(); i++ )
         {
             ConfigControl *control = controls[i];
-            if( !control )
-            {
-                msg_Dbg( p_intf, "This shouldn't happen, please report" );
-                continue;
-            }
 
             tempMRL += (i ? " :" : ":");
 
@@ -1301,6 +1366,11 @@ void CaptureOpenPanel::advancedDialog()
         updateMRL();
         msg_Dbg( p_intf, "%s", qtu( advMRL ) );
     }
+    for( int i = 0; i < controls.size(); i++ )
+    {
+        ConfigControl *control = controls[i];
+        delete control ;
+    }
     delete adv;
     module_config_free( p_config );
     module_release (p_module);