]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open_panels.cpp
Qt4: merge unicast and multicast UDP, add RTP - fixes #1706
[vlc] / modules / gui / qt4 / components / open_panels.cpp
index 181ec1c8a2d273f4db247e3031b7cb06ab665abc..100e52950fcad58ac7083b629bc2d09b331e4ec5 100644 (file)
@@ -81,7 +81,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     dialogBox->setSizeGripEnabled( false );
 
     /* Add a tooltip */
-    dialogBox->setToolTip( qtr( "Select one or multiple files, or a folder" ) );
+    dialogBox->setToolTip( qtr( "Select one or multiple files" ) );
 
     // But hide the two OK/Cancel buttons. Enable them for debug.
     QDialogButtonBox *fileDialogAcceptBox =
@@ -104,7 +104,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     listLabel[2]->setText( qtr( "Filter:" ) );
 
     dialogBox->layout()->setMargin( 0 );
-    dialogBox->layout()->setSizeConstraint( QLayout::SetMinimumSize );
+    dialogBox->layout()->setSizeConstraint( QLayout::SetNoConstraint );
 
     /** END of QFileDialog tweaking **/
 
@@ -161,7 +161,7 @@ void FileOpenPanel::updateMRL()
     }
 
     if( ui.subCheckBox->isChecked() ) {
-        mrl.append( " :sub-file=" + ui.subInput->text() );
+        mrl.append( " :sub-file=\"" + ui.subInput->text() + "\"" );
         int align = ui.alignSubComboBox->itemData(
                     ui.alignSubComboBox->currentIndex() ).toInt();
         mrl.append( " :subsdec-align=" + QString().setNum( align ) );
@@ -248,6 +248,7 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     BUTTONACT( ui.audioCDRadioButton, updateButtons() );
     BUTTONACT( ui.dvdsimple, updateButtons() );
     BUTTONACT( ui.browseDiscButton, browseDevice() );
+    BUTTONACT( ui.ejectButton, eject() );
 
     CONNECT( ui.deviceCombo, editTextChanged( QString ), this, updateMRL());
     CONNECT( ui.titleSpin, valueChanged( int ), this, updateMRL());
@@ -298,6 +299,7 @@ void DiscOpenPanel::updateButtons()
         ui.chapterLabel->show();
         ui.chapterSpin->show();
         ui.diskOptionBox_2->show();
+        ui.dvdsimple->setEnabled( true );
     }
     else if ( ui.vcdRadioButton->isChecked() )
     {
@@ -310,6 +312,7 @@ void DiscOpenPanel::updateButtons()
         ui.chapterLabel->hide();
         ui.chapterSpin->hide();
         ui.diskOptionBox_2->show();
+        ui.dvdsimple->setEnabled( false );
     }
     else /* CDDA */
     {
@@ -322,6 +325,7 @@ void DiscOpenPanel::updateButtons()
         ui.chapterLabel->hide();
         ui.chapterSpin->hide();
         ui.diskOptionBox_2->hide();
+        ui.dvdsimple->setEnabled( false );
     }
 
     updateMRL();
@@ -336,9 +340,9 @@ void DiscOpenPanel::updateMRL()
     /* DVD */
     if( ui.dvdRadioButton->isChecked() ) {
         if( !ui.dvdsimple->isChecked() )
-            mrl = "dvd://";
+            mrl = "\"dvd://";
         else
-            mrl = "dvdsimple://";
+            mrl = "\"dvdsimple://";
         mrl += ui.deviceCombo->currentText();
         emit methodChanged( "dvdnav-caching" );
 
@@ -351,7 +355,7 @@ void DiscOpenPanel::updateMRL()
 
     /* VCD */
     } else if ( ui.vcdRadioButton->isChecked() ) {
-        mrl = "vcd://" + ui.deviceCombo->currentText();
+        mrl = "\"vcd://" + ui.deviceCombo->currentText();
         emit methodChanged( "vcd-caching" );
 
         if( ui.titleSpin->value() > 0 ) {
@@ -360,12 +364,14 @@ void DiscOpenPanel::updateMRL()
 
     /* CDDA */
     } else {
-        mrl = "cdda://" + ui.deviceCombo->currentText();
+        mrl = "\"cdda://" + ui.deviceCombo->currentText();
         if( ui.titleSpin->value() > 0 ) {
             QString("@%1").arg( ui.titleSpin->value() );
         }
     }
 
+    mrl += "\"";
+
     if ( ui.dvdRadioButton->isChecked() || ui.vcdRadioButton->isChecked() )
     {
         if ( ui.audioSpin->value() >= 0 ) {
@@ -390,6 +396,11 @@ void DiscOpenPanel::browseDevice()
     updateMRL();
 }
 
+void DiscOpenPanel::eject()
+{
+    intf_Eject( p_intf, qtu( ui.deviceCombo->currentText() ) );
+}
+
 void DiscOpenPanel::accept()
 {}
 
@@ -402,20 +413,23 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ui.setupUi( this );
 
     /* CONNECTs */
-    CONNECT( ui.protocolCombo, currentIndexChanged( int ),
+    CONNECT( ui.protocolCombo, activated( int ),
              this, updateProtocol( int ) );
     CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
     CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
     CONNECT( ui.timeShift, clicked(), this, updateMRL());
-    CONNECT( ui.ipv6, clicked(), this, updateMRL());
 
+    ui.protocolCombo->addItem( "" );
     ui.protocolCombo->addItem("HTTP", QVariant("http"));
     ui.protocolCombo->addItem("HTTPS", QVariant("https"));
-    ui.protocolCombo->addItem("FTP", QVariant("ftp"));
     ui.protocolCombo->addItem("MMS", QVariant("mms"));
+    ui.protocolCombo->addItem("FTP", QVariant("ftp"));
     ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
-    ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
-    ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
+    ui.protocolCombo->addItem("RTP", QVariant("rtp"));
+    ui.protocolCombo->addItem("UDP", QVariant("udp"));
+    ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
+
+    updateProtocol( ui.protocolCombo->currentIndex() );
 }
 
 NetOpenPanel::~NetOpenPanel()
@@ -425,19 +439,23 @@ void NetOpenPanel::clear()
 {}
 
 /* update the widgets according the type of protocol */
-void NetOpenPanel::updateProtocol( int idx ) {
+void NetOpenPanel::updateProtocol( int idx_proto ) {
     QString addr = ui.addressText->text();
-    QString proto = ui.protocolCombo->itemData( idx ).toString();
+    QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
 
-    ui.timeShift->setEnabled( idx >= 5 );
-    ui.ipv6->setEnabled( idx == 5 );
-    ui.addressText->setEnabled( idx != 5 );
-    ui.portSpin->setEnabled( idx >= 5 );
+    ui.timeShift->setEnabled( idx_proto == UDP_PROTO );
+    ui.portSpin->setEnabled( idx_proto == UDP_PROTO ||
+                             idx_proto == RTP_PROTO );
+
+    if( idx_proto == NO_PROTO ) return;
 
     /* If we already have a protocol in the address, replace it */
-    if( addr.contains( "://")) {
-        msg_Err( p_intf, "replace");
-        addr.replace( QRegExp("^.*://"), proto + "://");
+    if( addr.contains( "://"))
+    {
+        if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
+            addr.replace( QRegExp("^.*://@*"), proto + "://");
+        else
+             addr.replace( QRegExp("^.*://"), proto + "://@");
         ui.addressText->setText( addr );
     }
     updateMRL();
@@ -446,53 +464,70 @@ void NetOpenPanel::updateProtocol( int idx ) {
 void NetOpenPanel::updateMRL() {
     QString mrl = "";
     QString addr = ui.addressText->text();
-    int proto = ui.protocolCombo->currentIndex();
+    addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
+    int idx_proto = ui.protocolCombo->currentIndex();
 
-    if( addr.contains( "://") && proto != 5 ) {
-        mrl = addr;
-    } else {
-        switch( proto ) {
-        case 0:
+    if( addr.contains( "://"))
+    {
+        /* Match the correct item in the comboBox */
+        ui.protocolCombo->setCurrentIndex(
+                ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
+
+        if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
+            mrl = addr;
+    }
+    else
+    {
+        switch( idx_proto ) {
+        case HTTP_PROTO:
             mrl = "http://" + addr;
             emit methodChanged("http-caching");
             break;
-        case 1:
+        case HTTPS_PROTO:
             mrl = "https://" + addr;
             emit methodChanged("http-caching");
             break;
-        case 3:
+        case MMS_PROTO:
             mrl = "mms://" + addr;
             emit methodChanged("mms-caching");
             break;
-        case 2:
+        case FTP_PROTO:
             mrl = "ftp://" + addr;
             emit methodChanged("ftp-caching");
             break;
-        case 4: /* RTSP */
+        case RTSP_PROTO:
             mrl = "rtsp://" + addr;
             emit methodChanged("rtsp-caching");
             break;
-        case 5:
+        case UDP_PROTO:
             mrl = "udp://@";
-            if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
-                mrl += "[::]";
+            /* Add [] to IPv6 */
+            if ( addr.contains(':') && !addr.contains('[') )
+            {
+                mrl += "[" + addr + "]";
             }
+            else mrl += addr;
             mrl += QString(":%1").arg( ui.portSpin->value() );
             emit methodChanged("udp-caching");
             break;
-        case 6: /* UDP multicast */
-            mrl = "udp://@";
-            /* Add [] to IPv6 */
-            if ( addr.contains(':') && !addr.contains('[') ) {
-                mrl += "[" + addr + "]";
-            } else mrl += addr;
+        case RTP_PROTO:
+            mrl = "rtp://@";
+            if ( addr.contains(':') && !addr.contains('[') )
+                mrl += "[" + addr + "]"; /* Add [] to IPv6 */
+            else
+                mrl += addr;
             mrl += QString(":%1").arg( ui.portSpin->value() );
-            emit methodChanged("udp-caching");
+            emit methodChanged("rtp-caching");
+            break;
+        case RTMP_PROTO:
+            mrl = "rtmp://" + addr;
+            emit methodChanged("rtmp-caching");
+            break;
         }
     }
 
     // Encode the boring stuffs
-    mrl = QUrl( mrl ).toEncoded();
+
     if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
         mrl += " :access-filter=timeshift";
     }
@@ -718,7 +753,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 
     /* Jack Main panel */
     /* Channels */
-    QLabel *jackChannelsLabel = new QLabel( qtr( "Channels :" ) );
+    QLabel *jackChannelsLabel = new QLabel( qtr( "Channels:" ) );
     jackDevLayout->addWidget( jackChannelsLabel, 1, 0 );
 
     jackChannels = new QSpinBox;
@@ -731,7 +766,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     /* Jack Props panel */
 
     /* Selected ports */
-    QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports :" ) );
+    QLabel *jackPortsLabel = new QLabel( qtr( "Selected ports:" ) );
     jackPropLayout->addWidget( jackPortsLabel, 0 , 0 );
 
     jackPortsSelected = new QLineEdit( qtr( ".*") );
@@ -739,7 +774,7 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     jackPropLayout->addWidget( jackPortsSelected, 0, 1 );
 
     /* Caching */
-    QLabel *jackCachingLabel = new QLabel( qtr( "Input caching :" ) );
+    QLabel *jackCachingLabel = new QLabel( qtr( "Input caching:" ) );
     jackPropLayout->addWidget( jackCachingLabel, 1 , 0 );
     jackCaching = new QSpinBox;
     setSpinBoxFreq( jackCaching );
@@ -892,10 +927,10 @@ CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     screenDevLayout->addWidget( screenLabel, 0, 0 );
 
     /* General connects */
-    connect( ui.deviceCombo, SIGNAL( activated( int ) ),
-                     stackedDevLayout, SLOT( setCurrentIndex( int ) ) );
-    connect( ui.deviceCombo, SIGNAL( activated( int ) ),
-                     stackedPropLayout, SLOT( setCurrentIndex( int ) ) );
+    CONNECT( ui.deviceCombo, activated( int ) ,
+             stackedDevLayout, setCurrentIndex( int ) );
+    CONNECT( ui.deviceCombo, activated( int ),
+             stackedPropLayout, setCurrentIndex( int ) );
     CONNECT( ui.deviceCombo, activated( int ), this, updateMRL() );
     CONNECT( ui.deviceCombo, activated( int ), this, updateButtons() );
 
@@ -934,8 +969,8 @@ void CaptureOpenPanel::updateMRL()
         break;
     case DSHOW_DEVICE:
         mrl = "dshow://";
-        mrl += " :dshow-vdev=" + QString("%1").arg( vdevDshowW->getValue() );
-        mrl += " :dshow-adev=" + QString("%1").arg( adevDshowW->getValue() );
+        mrl+= " :dshow-vdev=" + QString("\"%1\"").arg( vdevDshowW->getValue() );
+        mrl+= " :dshow-adev=" + QString("\"%1\"").arg( adevDshowW->getValue() );
         if( dshowVSizeLine->isModified() )
             mrl += " :dshow-size=" + dshowVSizeLine->text();
         break;
@@ -1008,7 +1043,6 @@ void CaptureOpenPanel::updateButtons()
     /* Get the current Device Number */
     int i_devicetype = ui.deviceCombo->itemData(
                                 ui.deviceCombo->currentIndex() ).toInt();
-    msg_Dbg( p_intf, "Capture Type: %i", i_devicetype );
     switch( i_devicetype )
     {
 #ifdef WIN32
@@ -1064,7 +1098,7 @@ void CaptureOpenPanel::advancedDialog()
 
     /* New Adv Prop dialog */
     adv = new QDialog( this );
-    adv->setWindowTitle( qtr( "Advanced options..." ) );
+    adv->setWindowTitle( qtr( "Advanced Options" ) );
 
     /* A main Layout with a Frame */
     QVBoxLayout *mainLayout = new QVBoxLayout( adv );
@@ -1091,7 +1125,7 @@ void CaptureOpenPanel::advancedDialog()
 
     /* Button stuffs */
     QDialogButtonBox *advButtonBox = new QDialogButtonBox( adv );
-    QPushButton *closeButton = new QPushButton( qtr( "Ok" ) );
+    QPushButton *closeButton = new QPushButton( qtr( "OK" ) );
     QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
 
     CONNECT( closeButton, clicked(), adv, accept() );
@@ -1100,7 +1134,7 @@ void CaptureOpenPanel::advancedDialog()
     advButtonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
     advButtonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
 
-    gLayout->addWidget( advButtonBox, i_confsize + 1, 0, 1, -1  );
+    mainLayout->addWidget( advButtonBox );
 
     /* Creation of the MRL */
     if( adv->exec() )