X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Fopen_panels.cpp;h=ae087c1336af1da972160fdb2f072974cff44e79;hb=000f1e1fb9253dca219253ee54702cf044aff213;hp=a9f27f461db40ffb1caf0fd2021559f00e326f1f;hpb=31927c895c0f13237bf734cbae39f915bb2b3786;p=vlc diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp index a9f27f461d..ae087c1336 100644 --- a/modules/gui/qt4/components/open_panels.cpp +++ b/modules/gui/qt4/components/open_panels.cpp @@ -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 = @@ -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 ) ); @@ -337,9 +337,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" ); @@ -352,7 +352,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 ) { @@ -361,12 +361,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 ) { @@ -408,20 +410,28 @@ 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("HTTP", QVariant("http")); - ui.protocolCombo->addItem("HTTPS", QVariant("https")); - ui.protocolCombo->addItem("FTP", QVariant("ftp")); - ui.protocolCombo->addItem("MMS", QVariant("mms")); - ui.protocolCombo->addItem("RTSP", QVariant("rtsp")); - ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp")); - ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp")); + typedef QPair QPairString; + QMap protocols; +#define P(value,name,dsc) do { protocols[value] = QPairString( QString(dsc), QString(name) );} while(0) + P( NO_PROTO, "", "" ); + P( UDPM_PROTO, "udp", "UDP/RTP (multicast)" ); + P( HTTP_PROTO, "http", "HTTP" ); + P( HTTPS_PROTO, "https", "HTTPS" ); + P( MMS_PROTO, "mms", "MMS" ); + P( FTP_PROTO, "ftp", "FTP" ); + P( RTSP_PROTO, "rtsp", "RTSP" ); + P( UDP_PROTO, "udp", "UDP/RTP (unicast)" ); + P( RTMP_PROTO, "rtmp", "RTMP" ); +#undef P + foreach( QPairString e, protocols ) /* Sorted by key, exactly what we need */ + ui.protocolCombo->addItem( e.first, QVariant(e.second.isEmpty() ) ); } NetOpenPanel::~NetOpenPanel() @@ -431,19 +441,26 @@ 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_proto == UDP_PROTO || + idx_proto == UDPM_PROTO ); + ui.ipv6->setEnabled( idx_proto == UDP_PROTO ); + ui.addressText->setEnabled( idx_proto != UDP_PROTO ); + ui.portSpin->setEnabled( idx_proto == UDP_PROTO || + idx_proto == UDPM_PROTO ); - ui.timeShift->setEnabled( idx >= 5 ); - ui.ipv6->setEnabled( idx == 5 ); - ui.addressText->setEnabled( idx != 5 ); - ui.portSpin->setEnabled( idx >= 5 ); + 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 != UDPM_PROTO ) + addr.replace( QRegExp("^.*://@*"), proto + "://"); + else + addr.replace( QRegExp("^.*://"), proto + "://@"); ui.addressText->setText( addr ); } updateMRL(); @@ -452,53 +469,71 @@ 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 != UDPM_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() ) { + if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) + { mrl += "[::]"; } mrl += QString(":%1").arg( ui.portSpin->value() ); emit methodChanged("udp-caching"); break; - case 6: /* UDP multicast */ + case UDPM_PROTO: /* UDP multicast */ mrl = "udp://@"; /* Add [] to IPv6 */ - if ( addr.contains(':') && !addr.contains('[') ) { + if ( addr.contains(':') && !addr.contains('[') ) + { mrl += "[" + addr + "]"; - } else mrl += addr; + } + else mrl += addr; mrl += QString(":%1").arg( ui.portSpin->value() ); emit methodChanged("udp-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"; } @@ -724,7 +759,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; @@ -737,7 +772,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( ".*") ); @@ -745,7 +780,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 ); @@ -898,10 +933,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() ); @@ -1014,7 +1049,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 @@ -1106,7 +1140,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() )