Commit 2a100fcd authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: NetOpenPanel: add drop-down list

parent c04668ad
...@@ -539,21 +539,22 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -539,21 +539,22 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
ui.setupUi( this ); ui.setupUi( this );
/* CONNECTs */ /* CONNECTs */
CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL()); CONNECT( ui.urlComboBox->lineEdit(), textChanged( const QString& ), this, updateMRL());
CONNECT( ui.urlComboBox, currentIndexChanged( const QString& ), this, updateMRL());
if( var_InheritBool( p_intf, "qt-recentplay" ) ) if( var_InheritBool( 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 ); ui.urlComboBox->setModel( mrlList );
ui.urlText->setCompleter( completer ); ui.urlComboBox->clearEditText();
CONNECT( ui.urlComboBox->lineEdit(), editingFinished(), this, updateModel() );
CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
} }
else else
mrlList = NULL; mrlList = NULL;
ui.urlText->setValidator( new UrlValidator( this ) ); ui.urlComboBox->setValidator( new UrlValidator( this ) );
ui.urlComboBox->setFocus();
} }
NetOpenPanel::~NetOpenPanel() NetOpenPanel::~NetOpenPanel()
...@@ -601,7 +602,7 @@ void NetOpenPanel::updateMRL() ...@@ -601,7 +602,7 @@ void NetOpenPanel::updateMRL()
{ "udp", "udp" }, { "udp", "udp" },
}; };
QString url = ui.urlText->text(); QString url = ui.urlComboBox->lineEdit()->text();
if( !url.contains( "://") ) if( !url.contains( "://") )
return; /* nothing to do this far */ return; /* nothing to do this far */
...@@ -618,12 +619,12 @@ void NetOpenPanel::updateMRL() ...@@ -618,12 +619,12 @@ void NetOpenPanel::updateMRL()
emit mrlUpdated( qsl, "" ); emit mrlUpdated( qsl, "" );
} }
void NetOpenPanel::updateCompleter() void NetOpenPanel::updateModel()
{ {
assert( mrlList ); assert( mrlList );
QStringList tempL = mrlList->stringList(); QStringList tempL = mrlList->stringList();
if( !tempL.contains( ui.urlText->text() ) ) if( !tempL.contains( ui.urlComboBox->lineEdit()->text() ) )
tempL.append( ui.urlText->text() ); tempL.append( ui.urlComboBox->lineEdit()->text() );
mrlList->setStringList( tempL ); mrlList->setStringList( tempL );
} }
......
...@@ -146,7 +146,7 @@ private: ...@@ -146,7 +146,7 @@ private:
public slots: public slots:
virtual void updateMRL(); virtual void updateMRL();
private slots: private slots:
void updateCompleter(); void updateModel();
}; };
class UrlValidator : public QValidator class UrlValidator : public QValidator
......
...@@ -32,16 +32,6 @@ ...@@ -32,16 +32,6 @@
<property name="text"> <property name="text">
<string>Please enter a network URL:</string> <string>Please enter a network URL:</string>
</property> </property>
<property name="buddy">
<cstring>urlText</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="urlText">
<property name="toolTip">
<string>Enter the URL of the network stream here.</string>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
...@@ -52,7 +42,7 @@ ...@@ -52,7 +42,7 @@
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
p { margin: 0; -qt-block-indent: 0; text-indent: 0;} p { margin: 0; -qt-block-indent: 0; text-indent: 0;}
body { font-family: 'sans'; font-size: 8pt; font-weight: 400; } body { font-family: 'sans'; font-size: 8pt; font-weight: 400; }
p > span { color: #838383; } p &gt; span { color: #838383; }
&lt;/style&gt;&lt;/head&gt;&lt;body&gt; &lt;/style&gt;&lt;/head&gt;&lt;body&gt;
&lt;p&gt;&lt;span&gt;http://www.example.com/stream.avi&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;http://www.example.com/stream.avi&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;rtp://@:1234&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;rtp://@:1234&lt;/span&gt;&lt;/p&gt;
...@@ -68,6 +58,16 @@ p > span { color: #838383; } ...@@ -68,6 +58,16 @@ p > span { color: #838383; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QComboBox" name="urlComboBox">
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::NoInsert</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -90,7 +90,7 @@ p > span { color: #838383; } ...@@ -90,7 +90,7 @@ p > span { color: #838383; }
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>urlText</tabstop> <tabstop>urlComboBox</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