Commit 3ae0e266 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: remove proto combo from open net tab

Now, we get the URL directly. This is much simpler and much less
confusing. Also a few missing network protocols.
parent 43925afd
...@@ -492,30 +492,16 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -492,30 +492,16 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
ui.setupUi( this ); ui.setupUi( this );
/* CONNECTs */ /* CONNECTs */
CONNECT( ui.protocolCombo, activated( int ), CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
this, updateProtocol( int ) );
CONNECT( ui.addressText, textChanged( const QString& ), this, updateMRL());
ui.protocolCombo->addItem( "" );
ui.protocolCombo->addItem("HTTP", QVariant("http"));
ui.protocolCombo->addItem("HTTPS", QVariant("https"));
ui.protocolCombo->addItem("MMS", QVariant("mms"));
ui.protocolCombo->addItem("FTP", QVariant("ftp"));
ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
ui.protocolCombo->addItem("RTP", QVariant("rtp"));
ui.protocolCombo->addItem("UDP", QVariant("udp"));
ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
updateProtocol( ui.protocolCombo->currentIndex() );
if( config_GetInt( p_intf, "qt-recentplay" ) ) if( config_GetInt( p_intf, "qt-recentplay" ) )
{ {
mrlList = new QStringListModel( mrlList = new QStringListModel(
getSettings()->value( "Open/netMRL" ).toStringList() ); getSettings()->value( "Open/netMRL" ).toStringList() );
QCompleter *completer = new QCompleter( mrlList, this ); QCompleter *completer = new QCompleter( mrlList, this );
ui.addressText->setCompleter( completer ); ui.urlText->setCompleter( completer );
CONNECT( ui.addressText, editingFinished(), this, updateCompleter() ); CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
} }
else else
mrlList = NULL; mrlList = NULL;
...@@ -536,80 +522,49 @@ NetOpenPanel::~NetOpenPanel() ...@@ -536,80 +522,49 @@ NetOpenPanel::~NetOpenPanel()
void NetOpenPanel::clear() void NetOpenPanel::clear()
{} {}
/* update the widgets according the type of protocol */ static int strcmp_void( const void *k, const void *e )
void NetOpenPanel::updateProtocol( int idx_proto ) { {
QString addr = ui.addressText->text(); return strcmp( (const char *)k, (const char *)e );
QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
if( idx_proto == NO_PROTO ) return;
/* If we already have a protocol in the address, replace it */
if( addr.contains( "://"))
{
if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
addr.replace( QRegExp("^.*://@*"), proto + "://");
else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
!addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
addr.replace( QRegExp("^.*://"), proto + "://@");
else
addr.replace( QRegExp("^.*://"), proto + "://");
addr.replace( QRegExp("@+"), "@");
ui.addressText->setText( addr );
}
updateMRL();
} }
void NetOpenPanel::updateMRL() { void NetOpenPanel::updateMRL()
QString mrl = ""; {
QString addr = ui.addressText->text(); static const struct caching_map
int idx_proto = ui.protocolCombo->currentIndex();
if( addr.contains( "://"))
{
/* Match the correct item in the comboBox */
ui.protocolCombo->setCurrentIndex(
ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
mrl = addr;
}
else
{ {
switch( idx_proto ) { char proto[6];
case HTTP_PROTO: char caching[6];
mrl = "http://" + addr; } schemes[] =
emit methodChanged("http-caching"); { /* KEEP alphabetical order on first column!! */
break; { "ftp", "ftp" },
case HTTPS_PROTO: { "ftps", "ftp" },
mrl = "https://" + addr; { "http", "http" },
emit methodChanged("http-caching"); { "https", "http" },
break; { "mms", "mms" },
case MMS_PROTO: { "mmsh", "mms" },
mrl = "mms://" + addr; { "mmst", "mms" },
emit methodChanged("mms-caching"); { "mmsu", "mms" },
break; { "sftp", "sftp" },
case FTP_PROTO: { "smb", "smb" },
mrl = "ftp://" + addr; { "rtmp", "rtmp" },
emit methodChanged("ftp-caching"); { "rtp", "rtp" },
break; { "rtsp", "rtsp" },
case RTSP_PROTO: { "udp", "udp" },
mrl = "rtsp://" + addr; };
emit methodChanged("rtsp-caching");
break; QString url = ui.urlText->text();
case RTP_PROTO: if( !url.contains( "://") )
case UDP_PROTO: return; /* nothing to do this far */
mrl = qfu(((idx_proto == RTP_PROTO) ? "rtp" : "udp"));
mrl += qfu( "://" ); /* Match the correct item in the comboBox */
mrl += addr; QString proto = url.section( ':', 0, 0 );
emit methodChanged(idx_proto == RTP_PROTO const struct caching_map *r = (const struct caching_map *)
? "rtp-caching" : "udp-caching"); bsearch( qtu(proto), schemes, sizeof(schemes) / sizeof(schemes[0]),
break; sizeof(schemes[0]), strcmp_void );
case RTMP_PROTO: if( r != NULL )
mrl = "rtmp://" + addr; emit methodChanged( qfu( r->caching ) + qfu( "-caching" ) );
emit methodChanged("rtmp-caching");
break; QStringList qsl;
} qsl << url;
}
QStringList qsl; qsl<< mrl;
emit mrlUpdated( qsl, "" ); emit mrlUpdated( qsl, "" );
} }
...@@ -617,8 +572,8 @@ void NetOpenPanel::updateCompleter() ...@@ -617,8 +572,8 @@ void NetOpenPanel::updateCompleter()
{ {
assert( mrlList ); assert( mrlList );
QStringList tempL = mrlList->stringList(); QStringList tempL = mrlList->stringList();
if( !tempL.contains( ui.addressText->text() ) ) if( !tempL.contains( ui.urlText->text() ) )
tempL.append( ui.addressText->text() ); tempL.append( ui.urlText->text() );
mrlList->setStringList( tempL ); mrlList->setStringList( tempL );
} }
......
...@@ -46,19 +46,6 @@ ...@@ -46,19 +46,6 @@
#define setSpinBoxFreq( spinbox ){ spinbox->setRange ( 0, INT_MAX ); \ #define setSpinBoxFreq( spinbox ){ spinbox->setRange ( 0, INT_MAX ); \
spinbox->setAccelerated( true ); } spinbox->setAccelerated( true ); }
enum
{
NO_PROTO,
HTTP_PROTO,
HTTPS_PROTO,
MMS_PROTO,
FTP_PROTO,
RTSP_PROTO,
RTP_PROTO,
UDP_PROTO,
RTMP_PROTO
};
enum enum
{ {
V4L_DEVICE, V4L_DEVICE,
...@@ -154,7 +141,6 @@ private: ...@@ -154,7 +141,6 @@ private:
public slots: public slots:
virtual void updateMRL(); virtual void updateMRL();
private slots: private slots:
void updateProtocol( int );
void updateCompleter(); void updateCompleter();
}; };
......
...@@ -20,25 +20,8 @@ ...@@ -20,25 +20,8 @@
<string>Network Protocol</string> <string>Network Protocol</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<item row="1" column="0" >
<widget class="QComboBox" name="protocolCombo" >
<property name="toolTip" >
<string>Select the protocol for the URL.</string>
</property>
</widget>
</item>
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="label" > <widget class="QLabel" name="label_1" >
<property name="text" >
<string>Protocol</string>
</property>
<property name="buddy" >
<cstring>protocolCombo</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="label_2" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" > <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -46,17 +29,17 @@ ...@@ -46,17 +29,17 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text" > <property name="text" >
<string>Address</string> <string>URL</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>addressText</cstring> <cstring>urlText</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="0" >
<widget class="QLineEdit" name="addressText" > <widget class="QLineEdit" name="urlText" >
<property name="toolTip" > <property name="toolTip" >
<string>Enter the URL of the network stream here, with or without the protocol.</string> <string>Enter the URL of the network stream here.</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -82,8 +65,7 @@ ...@@ -82,8 +65,7 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>protocolCombo</tabstop> <tabstop>urlText</tabstop>
<tabstop>addressText</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment