]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open_panels.cpp
add caching emits for dvb, dshow, screen and dvdread
[vlc] / modules / gui / qt4 / components / open_panels.cpp
index 0548406b719e1b1d2da0b92eda0716f45a9f0d56..59e42b08fc049823b9a25682677ba6e6b8ed41e3 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()
@@ -163,17 +164,20 @@ FileOpenPanel::~FileOpenPanel()
 
 void FileOpenPanel::browseFile()
 {
-    QStringList files = QFileDialog::getOpenFileNames( this );
-    foreach( const QString &file, files)
+    QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ;
+    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 );
+        savedirpathFromFile( file );
     }
+    updateButtons();
     updateMRL();
 }
 
-void FileOpenPanel::deleteFile()
+void FileOpenPanel::removeFile()
 {
     int i = ui.fileListWidg->currentRow();
     if( i != -1 )
@@ -183,6 +187,7 @@ void FileOpenPanel::deleteFile()
     }
 
     updateMRL();
+    updateButtons();
 }
 
 /* Show a fileBrowser to select a subtitle */
@@ -193,7 +198,7 @@ void FileOpenPanel::browseFileSub()
                            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,7 +245,8 @@ void FileOpenPanel::updateMRL()
 /* Function called by Open Dialog when clicke on Play/Enqueue */
 void FileOpenPanel::accept()
 {
-    p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
+    if( dialogBox )
+        p_intf->p_sys->filepath = dialogBox->directory().absolutePath();
     ui.fileListWidg->clear();
 }
 
@@ -251,6 +257,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 )                        *
  **************************************************************************/
@@ -301,7 +315,7 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     BUTTONACT( ui.audioCDRadioButton, updateButtons() );
     BUTTONACT( ui.dvdsimple, updateButtons() );
     BUTTONACT( ui.browseDiscButton, browseDevice() );
-    BUTTON_SET_ACT_I( ui.ejectButton, "", eject, qtr( "Eject the disc" ),
+    BUTTON_SET_ACT_I( ui.ejectButton, "", toolbar/eject, qtr( "Eject the disc" ),
             eject() );
 
     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
@@ -387,6 +401,8 @@ void DiscOpenPanel::updateButtons()
     updateMRL();
 }
 
+#undef setDrive
+
 /* Update the current MRL */
 void DiscOpenPanel::updateMRL()
 {
@@ -401,7 +417,10 @@ void DiscOpenPanel::updateMRL()
         else
             mrl = "dvdsimple://";
         mrl += ui.deviceCombo->currentText();
-        emit methodChanged( "dvdnav-caching" );
+        if( !ui.dvdsimple->isChecked() )
+            emit methodChanged( "dvdnav-caching" );
+        else
+            emit methodChanged( "dvdread-caching" );
 
         if ( ui.titleSpin->value() > 0 ) {
             mrl += QString("@%1").arg( ui.titleSpin->value() );
@@ -422,6 +441,7 @@ void DiscOpenPanel::updateMRL()
     /* CDDA */
     } else {
         mrl = "cdda://" + ui.deviceCombo->currentText();
+        emit methodChanged( "cdda-caching" );
     }
 
     fileList << mrl; mrl = "";
@@ -510,6 +530,8 @@ NetOpenPanel::~NetOpenPanel()
     while( tempL.size() > 8 ) tempL.removeFirst();
 
     getSettings()->setValue( "Open/netMRL", tempL );
+
+    delete mrlList;
 }
 
 void NetOpenPanel::clear()
@@ -545,12 +567,7 @@ void NetOpenPanel::updateProtocol( int idx_proto ) {
 void NetOpenPanel::updateMRL() {
     QString mrl = "";
     QString addr = ui.addressText->text();
-    addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
     int idx_proto = ui.protocolCombo->currentIndex();
-    int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
-    int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
-    int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
-    int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
     if( addr.contains( "://"))
     {
         /* Match the correct item in the comboBox */
@@ -581,33 +598,40 @@ void NetOpenPanel::updateMRL() {
             mrl = "rtsp://" + addr;
             emit methodChanged("rtsp-caching");
             break;
+        case RTP_PROTO:
         case UDP_PROTO:
-            if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
-                mrl = "udp://@";
-        else
-                    mrl = "udp://";
-            /* Add [] to IPv6 */
-            if ( addr_is_ipv6  && !addr.contains('[') )
+            mrl = qfu(((idx_proto == RTP_PROTO) ? "rtp" : "udp"));
+            mrl += qfu( "://" );
+            if( addr[0] == ':' ) /* Port number without address */
+                mrl += addr;
+            else
             {
-                mrl += "[" + addr + "]";
+                mrl += qfu( "@" );
+                switch( addr.count( ":" ) )
+                {
+                    case 0: /* DNS or IPv4 literal, no port number */
+                        mrl += addr;
+                        mrl += QString(":%1").arg( ui.portSpin->value() );
+                        break;
+                    case 1: /* DNS or IPv4 literal plus port number */
+                        mrl += addr;
+                        break;
+                    default: /* IPv6 literal */
+                        if( !addr.contains( "]:" ) )
+                        {
+                            if( addr[0] != '[' ) /* Missing brackets */
+                                mrl += qfu( "[" ) + addr + qfu( "]" );
+                            else
+                                mrl += addr;
+                            mrl += QString(":%1").arg( ui.portSpin->value() );
+                        }
+                        else /* Brackets present, port present */
+                            mrl += addr;
+                        break;
+                }
             }
-            else mrl += addr;
-            if(!addr_has_port)
-                mrl += QString(":%1").arg( ui.portSpin->value() );
-            emit methodChanged("udp-caching");
-            break;
-        case RTP_PROTO:
-            if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
-                    mrl = "rtp://@";
-            else
-                    mrl = "rtp://";
-            if ( addr_is_ipv6 && !addr.contains('[') )
-                mrl += "[" + addr + "]"; /* Add [] to IPv6 */
-            else
-                mrl += addr;
-            if(!addr_has_port)
-                mrl += QString(":%1").arg( ui.portSpin->value() );
-            emit methodChanged("rtp-caching");
+            emit methodChanged(idx_proto == RTP_PROTO
+                                   ? "rtp-caching" : "udp-caching");
             break;
         case RTMP_PROTO:
             mrl = "rtmp://" + addr;
@@ -657,13 +681,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 ) );
@@ -675,7 +699,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;
@@ -709,7 +733,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:" ) );
@@ -778,7 +802,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" ) );
@@ -813,7 +837,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" ) );
@@ -858,7 +882,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 */
@@ -912,7 +937,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" ) );
@@ -968,7 +993,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" ) );
@@ -1036,10 +1061,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
@@ -1048,7 +1077,7 @@ void CaptureOpenPanel::initialize()
     /**********
      * Screen *
      **********/
-    addModuleAndLayouts( SCREEN_DEVICE, screen, "Desktop" );
+    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 );
@@ -1063,6 +1092,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 ) );
@@ -1071,7 +1103,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()
@@ -1098,15 +1131,18 @@ 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() || bdaa->isChecked() )
             mrl += " :dvb-bandwidth=" +
                 QString::number( bdaBandBox->itemData(
                     bdaBandBox->currentIndex() ).toInt() );
+        emit methodChanged( "dvb-caching" );
         break;
     case DSHOW_DEVICE:
         fileList << "dshow://";
@@ -1116,19 +1152,19 @@ void CaptureOpenPanel::updateMRL()
             colon_escape( QString("%1").arg( adevDshowW->getValue() ) );
         if( dshowVSizeLine->isModified() )
             mrl += " :dshow-size=" + dshowVSizeLine->text();
+        emit methodChanged( "dshow-caching" );
         break;
 #else
     case V4L_DEVICE:
         fileList << "v4l://";
         mrl += " :v4l-vdev=" + v4lVideoDevice->text();
-        mrl += " :v4l-adev=" + v4lAudioDevice->text();
+        mrl += " :input-slave=alsa://" + v4lAudioDevice->text();
         mrl += " :v4l-norm=" + QString::number( v4lNormBox->currentIndex() );
         mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
         break;
     case V4L2_DEVICE:
-        fileList << "v4l2://";
-        mrl += " :v4l2-dev=" + v4l2VideoDevice->text();
-        mrl += " :v4l2-adev=" + v4l2AudioDevice->text();
+        fileList << "v4l2://" + v4l2VideoDevice->text();
+        mrl += " :input-slave=alsa://" + v4l2AudioDevice->text();
         mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
         break;
     case JACK_DEVICE:
@@ -1158,9 +1194,13 @@ 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() );
         if( dvbs->isChecked() || dvbc->isChecked() )
             mrl += " :dvb-srate=" + QString::number( dvbSrate->value() );
         else if( dvbt->isChecked() )
@@ -1173,6 +1213,7 @@ void CaptureOpenPanel::updateMRL()
     case SCREEN_DEVICE:
         fileList << "screen://";
         mrl = " :screen-fps=" + QString::number( screenFPS->value() );
+        emit methodChanged( "screen-caching" );
         updateButtons();
         break;
     }
@@ -1213,16 +1254,6 @@ void CaptureOpenPanel::updateButtons()
             bdaBandBox->show();
             bdaBandLabel->show();
         }
-        if( bdas->isChecked() )
-        {
-            bdaFreq->setSuffix(" kHz");
-            bdaFreq->setSingleStep( 1000 );
-        }
-        if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked( ) )
-        {
-            bdaFreq->setSuffix(" Hz");
-            bdaFreq->setSingleStep( 100000 );
-        }
         break;
 #else
     case DVB_DEVICE:
@@ -1240,8 +1271,6 @@ void CaptureOpenPanel::updateButtons()
             dvbBandBox->show();
             dvbBandLabel->show();
         }
-        if( dvbs->isChecked() ) dvbFreq->setSuffix(" kHz");
-        if( dvbc->isChecked() || dvbt->isChecked() ) dvbFreq->setSuffix(" Hz");
         break;
 #endif
     case SCREEN_DEVICE: