Commit bc01f895 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

[Qt] Implement a kind of rememberance in Open Network Dialog.

The code is suboptimal since it does save more often than when accept() is called. This will be fixed in the future.
parent d28937e8
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <QDirModel> #include <QDirModel>
#include <QScrollArea> #include <QScrollArea>
#include <QUrl> #include <QUrl>
#include <QStringListModel>
#define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory") #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
...@@ -447,10 +448,29 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -447,10 +448,29 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
ui.protocolCombo->addItem("RTMP", QVariant("rtmp")); ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
updateProtocol( ui.protocolCombo->currentIndex() ); updateProtocol( ui.protocolCombo->currentIndex() );
if( config_GetInt( p_intf, "qt-recentplay" ) )
{
mrlList = new QStringListModel(
getSettings()->value( "Open/netMRL" ).toStringList() );
QCompleter *completer = new QCompleter( mrlList, this );
ui.addressText->setCompleter( completer );
CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
}
else
mrlList = NULL;
} }
NetOpenPanel::~NetOpenPanel() NetOpenPanel::~NetOpenPanel()
{} {
if( !mrlList ) return;
QStringList tempL = mrlList->stringList();
while( tempL.size() > 8 ) tempL.removeFirst();
getSettings()->setValue( "Open/netMRL", tempL );
}
void NetOpenPanel::clear() void NetOpenPanel::clear()
{} {}
...@@ -557,14 +577,20 @@ void NetOpenPanel::updateMRL() { ...@@ -557,14 +577,20 @@ void NetOpenPanel::updateMRL() {
} }
} }
// Encode the boring stuffs
if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) { if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
mrl += " :access-filter=timeshift"; mrl += " :access-filter=timeshift";
} }
emit mrlUpdated( mrl ); emit mrlUpdated( mrl );
} }
void NetOpenPanel::updateCompleter()
{
assert( mrlList );
QStringList tempL = mrlList->stringList();
tempL.append( ui.addressText->text() );
mrlList->setStringList( tempL );
}
/************************************************************************** /**************************************************************************
* Open Capture device ( DVB, PVR, V4L, and similar ) * * Open Capture device ( DVB, PVR, V4L, and similar ) *
**************************************************************************/ **************************************************************************/
......
...@@ -81,6 +81,7 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda", ...@@ -81,6 +81,7 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
class QWidget; class QWidget;
class QLineEdit; class QLineEdit;
class QString; class QString;
class QStringListModel;
class OpenPanel: public QWidget class OpenPanel: public QWidget
{ {
...@@ -143,10 +144,12 @@ public: ...@@ -143,10 +144,12 @@ public:
virtual void clear() ; virtual void clear() ;
private: private:
Ui::OpenNetwork ui; Ui::OpenNetwork ui;
QStringListModel *mrlList;
public slots: public slots:
virtual void updateMRL(); virtual void updateMRL();
private slots: private slots:
void updateProtocol( int ); void updateProtocol( int );
void updateCompleter();
}; };
class DiscOpenPanel: public OpenPanel class DiscOpenPanel: public OpenPanel
......
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