[vlc-devel] commit: Fix network panel behaviour ( comboBox and adress generation especially ) (Jean-Baptiste Kempf )
git version control
git at videolan.org
Wed Jun 25 03:36:53 CEST 2008
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Jun 24 18:34:06 2008 -0700| [16bf241c0ef8cb5ad5905817233af703080ed654]
Fix network panel behaviour (comboBox and adress generation especially )
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=16bf241c0ef8cb5ad5905817233af703080ed654
---
modules/gui/qt4/components/open_panels.cpp | 53 +++++++++++++++++-----------
modules/gui/qt4/components/open_panels.hpp | 13 +++++++
2 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index bcb6457..79e2a5d 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -410,13 +410,14 @@ 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"));
@@ -433,19 +434,24 @@ 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.ipv6->setEnabled( idx_proto == UDP_PROTO );
+ ui.addressText->setEnabled( idx_proto != UDP_PROTO );
+ ui.portSpin->setEnabled( idx_proto >= UDP_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 != UDPM_PROTO )
+ addr.replace( QRegExp("^.*://@*"), proto + "://");
+ else
+ addr.replace( QRegExp("^.*://"), proto + "://@");
ui.addressText->setText( addr );
}
updateMRL();
@@ -455,36 +461,41 @@ void NetOpenPanel::updateMRL() {
QString mrl = "";
QString addr = ui.addressText->text();
addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
- int proto = ui.protocolCombo->currentIndex();
+ int idx_proto = ui.protocolCombo->currentIndex();
- if( addr.contains( "://") && ( proto != 5 || proto != 6 ) )
+ if( addr.contains( "://"))
{
- mrl = addr;
+ /* 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( proto ) {
- case 0:
+ 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() )
{
@@ -493,7 +504,7 @@ void NetOpenPanel::updateMRL() {
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('[') )
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index d21a642..d79105c 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -50,6 +50,19 @@
enum
{
+ NO_PROTO,
+ HTTP_PROTO,
+ HTTPS_PROTO,
+ MMS_PROTO,
+ FTP_PROTO,
+ RTSP_PROTO,
+ UDP_PROTO,
+ UDPM_PROTO
+};
+
+
+enum
+{
V4L_DEVICE,
V4L2_DEVICE,
PVR_DEVICE,
More information about the vlc-devel
mailing list